specialty.py 746 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
Florent Chehab's avatar
Florent Chehab committed
2
from backend_app.models.other_core import Department
3 4 5 6 7
from backend_app.models.abstract.my_model import (
    MyModel,
    MyModelSerializer,
    MyModelViewSet,
)
Florent Chehab's avatar
Florent Chehab committed
8 9


10
class Specialty(MyModel):
11

Florent Chehab's avatar
Florent Chehab committed
12 13 14 15 16 17
    code = models.CharField(max_length=6)
    department = models.ForeignKey(Department, on_delete=models.PROTECT)
    name = models.CharField(max_length=100)
    active = models.BooleanField()

    class Meta:
18 19
        unique_together = ("code", "department")

Florent Chehab's avatar
Florent Chehab committed
20

21
class SpecialtySerializer(MyModelSerializer):
Florent Chehab's avatar
Florent Chehab committed
22 23
    class Meta:
        model = Specialty
24
        fields = "__all__"
Florent Chehab's avatar
Florent Chehab committed
25 26


27
class SpecialtyViewSet(MyModelViewSet):
Florent Chehab's avatar
Florent Chehab committed
28 29
    queryset = Specialty.objects.all()  # pylint: disable=E1101
    serializer_class = SpecialtySerializer