tag.py 718 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2 3
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
from backend.fields import JSONField
Florent Chehab's avatar
Florent Chehab committed
4
from backend.utils import get_viewset_permissions, get_model_config
Florent Chehab's avatar
Florent Chehab committed
5 6 7 8 9 10


class Tag(MyModel):
    """
    TODO description
    """
Florent Chehab's avatar
Florent Chehab committed
11
    model_config = get_model_config("Tag")
12

Florent Chehab's avatar
Florent Chehab committed
13
    name = models.CharField(max_length=100, unique=True)
Florent Chehab's avatar
Florent Chehab committed
14
    config = JSONField(default=dict)
Florent Chehab's avatar
Florent Chehab committed
15 16 17 18 19 20 21 22 23


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


class TagViewSet(MyModelViewSet):
24
    permission_classes = get_viewset_permissions("TagViewSet")
Florent Chehab's avatar
Florent Chehab committed
25 26
    queryset = Tag.objects.all()  # pylint: disable=E1101
    serializer_class = TagSerializer