semester.py 547 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2
3
from rest_framework import permissions
from backend.models.my_model import MyModel, MyModelSerializer, MyModelViewSet
Florent Chehab's avatar
Florent Chehab committed
4
5


6
class Semester(MyModel):
Florent Chehab's avatar
Florent Chehab committed
7
8
9
    code = models.CharField(primary_key=True, max_length=6)


10
class SemesterSerializer(MyModelSerializer):
Florent Chehab's avatar
Florent Chehab committed
11
12
13
14
15
    class Meta:
        model = Semester
        fields = '__all__'


16
class SemesterViewSet(MyModelViewSet):
Florent Chehab's avatar
Florent Chehab committed
17
18
19
    permission_classes = (permissions.IsAdminUser,)
    queryset = Semester.objects.all()  # pylint: disable=E1101
    serializer_class = SemesterSerializer