previousDeparture.py 1.36 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from django.db import models
from rest_framework import viewsets, permissions
from django.core.validators import MaxValueValidator

from rex.models.otherCore.specialty import Specialty
from rex.models.otherCore.semester import Semester
from rex.models.university import University

from rex.models.user import UserRestrictedModule, UserRestrictedModuleSerializer


class PreviousDeparture(UserRestrictedModule):
    semester = models.ForeignKey(Semester, on_delete=models.PROTECT)
    university = models.ForeignKey(University, on_delete=models.PROTECT)
    specialty = models.ForeignKey(Specialty, on_delete=models.PROTECT)
    # TODO check where we store specialty or at least check that it is coherent with user

    adequation_comment = models.TextField()
    integration_comment = models.TextField()
    adequation_grate = models.PositiveIntegerField(
        validators=[MaxValueValidator(20)])
    integration_grade = models.PositiveIntegerField(
        validators=[MaxValueValidator(20)])


class PreviousDepartureSerializer(UserRestrictedModuleSerializer):

    class Meta:
        model = PreviousDeparture
        fields = '__all__'


class PreviousDepartureViewSet(viewsets.ModelViewSet):
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = PreviousDeparture.objects.all()  # pylint: disable=E1101
    serializer_class = PreviousDepartureSerializer