department.py 745 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2
from backend.models.abstract.my_model import MyModel, MyModelSerializer, MyModelViewSet
Florent Chehab's avatar
Florent Chehab committed
3
from backend.utils import get_model_config, get_viewset_permissions
Florent Chehab's avatar
Florent Chehab committed
4 5


6
class Department(MyModel):
Florent Chehab's avatar
Florent Chehab committed
7
    model_config = get_model_config("Department")
8

Florent Chehab's avatar
Florent Chehab committed
9 10 11 12 13
    code = models.CharField(primary_key=True, max_length=6)
    name = models.CharField(max_length=100)
    active = models.BooleanField()


14
class DepartmentSerializer(MyModelSerializer):
Florent Chehab's avatar
Florent Chehab committed
15 16 17 18 19
    class Meta:
        model = Department
        fields = '__all__'


20
class DepartmentViewSet(MyModelViewSet):
21
    permission_classes = get_viewset_permissions("DepartmentViewSet")
Florent Chehab's avatar
Florent Chehab committed
22 23
    queryset = Department.objects.all()  # pylint: disable=E1101
    serializer_class = DepartmentSerializer