forTestingVersioning.py 1.1 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1 2 3 4 5
from django.db import models

import reversion
from backend_app.utils import get_model_config, get_viewset_permissions

6 7 8 9 10
from .myModelVersionned import (
    MyModelVersionned,
    MyModelVersionnedSerializer,
    MyModelVersionnedViewSet,
)
Florent Chehab's avatar
Florent Chehab committed
11 12 13


@reversion.register()
14
class ForTestingVersioning(MyModelVersionned):
Florent Chehab's avatar
Florent Chehab committed
15
    """
Florent Chehab's avatar
Florent Chehab committed
16
        Simple model for testing purposes (versioning)
Florent Chehab's avatar
Florent Chehab committed
17
    """
18

19
    model_config = get_model_config("ForTestingVersioning")
Florent Chehab's avatar
Florent Chehab committed
20 21
    bbb = models.CharField(max_length=100)

22 23
    @classmethod
    def get_serializer(cls):
24
        return ForTestingVersioningSerializer
25

Florent Chehab's avatar
Florent Chehab committed
26

27
class ForTestingVersioningSerializer(MyModelVersionnedSerializer):
Florent Chehab's avatar
Florent Chehab committed
28
    """
Florent Chehab's avatar
Florent Chehab committed
29
        Simple Serializer for testing purposes (versioning)
Florent Chehab's avatar
Florent Chehab committed
30
    """
31

Florent Chehab's avatar
Florent Chehab committed
32
    class Meta:
33
        model = ForTestingVersioning
34
        fields = "__all__"
Florent Chehab's avatar
Florent Chehab committed
35 36


37
class ForTestingVersioningViewSet(MyModelVersionnedViewSet):
Florent Chehab's avatar
Florent Chehab committed
38
    """
Florent Chehab's avatar
Florent Chehab committed
39
        Simple Viewset for testing purposes (versioning)
Florent Chehab's avatar
Florent Chehab committed
40
    """
41

42
    permission_classes = get_viewset_permissions("ForTestingVersioningViewSet")
43 44
    serializer_class = ForTestingVersioningSerializer
    queryset = ForTestingVersioning.objects.all()