userData.py 942 Bytes
Newer Older
1
from django.db import models
2
from rest_framework import permissions
3
from backend.models.tools import UsefullLinksField
4
5

from django.contrib.postgres.fields import JSONField
6
from backend.models.user import UserRestrictedModule, UserRestrictedModuleSerializer, UserRestrictedModuleViewSet
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21


class UserData(UserRestrictedModule):
    contact_info = UsefullLinksField(null=True)
    contact_info_is_public = models.BooleanField(default=False)
    config = JSONField(null=True, default={})
    other_data = JSONField(null=True, default={})


class UserDataSerializer(UserRestrictedModuleSerializer):
    class Meta:
        model = UserData
        fields = '__all__'


22
class UserDataViewSet(UserRestrictedModuleViewSet):
23
24
25
26
    permission_classes = (permissions.IsAdminUser,)  # TODO change
    queryset = UserData.objects.all()  # pylint: disable=E1101
    serializer_class = UserDataSerializer
    # TODO change to require a login not display all