semester.py 674 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2 3 4 5 6
from backend_app.models.abstract.my_model import (
    MyModel,
    MyModelSerializer,
    MyModelViewSet,
)
Florent Chehab's avatar
Florent Chehab committed
7
from backend_app.utils import get_model_config, get_viewset_permissions
Florent Chehab's avatar
Florent Chehab committed
8 9


10
class Semester(MyModel):
Florent Chehab's avatar
Florent Chehab committed
11
    model_config = get_model_config("Semester")
Florent Chehab's avatar
Florent Chehab committed
12 13 14
    code = models.CharField(primary_key=True, max_length=6)


15
class SemesterSerializer(MyModelSerializer):
Florent Chehab's avatar
Florent Chehab committed
16 17
    class Meta:
        model = Semester
18
        fields = "__all__"
Florent Chehab's avatar
Florent Chehab committed
19 20


21
class SemesterViewSet(MyModelViewSet):
22
    permission_classes = get_viewset_permissions("SemesterViewSet")
Florent Chehab's avatar
Florent Chehab committed
23 24
    queryset = Semester.objects.all()  # pylint: disable=E1101
    serializer_class = SemesterSerializer