tag.py 735 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
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
27
28
from django.db import models
from rest_framework import permissions
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.models.tools import IsAdminOrReadOnly
from django.contrib.postgres.fields import JSONField


class Tag(MyModel):
    """
    TODO description
    """
    name = models.CharField(max_length=100)
    config = JSONField(blank=True, default=dict)


class TagSerializer(MyModelSerializer):
    class Meta:
        model = Tag
        fields = '__all__'


class TagViewSet(MyModelViewSet):
    permission_classes = (
        permissions.IsAuthenticated,
        IsAdminOrReadOnly
    )
    queryset = Tag.objects.all()  # pylint: disable=E1101
    serializer_class = TagSerializer