userData.py 909 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from django.db import models
from rest_framework import viewsets, permissions
from rex.models.tools import UsefullLinksField

from django.contrib.postgres.fields import JSONField
from rex.models.user import UserRestrictedModule, UserRestrictedModuleSerializer


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__'


class UserDataViewSet(viewsets.ModelViewSet):
    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