previousDepartureFeedback.py 1.4 KB
Newer Older
1
2
3
from django.db import models
from django.core.validators import MaxValueValidator

4
5
6
7
8
from backend_app.models.user import (
    UserRestrictedModule,
    UserRestrictedModuleSerializer,
    UserRestrictedModuleViewSet,
)
Florent Chehab's avatar
Florent Chehab committed
9
10
11
from backend_app.models.user import PreviousDeparture
from backend_app.fields import JSONField
from backend_app.utils import get_model_config, get_viewset_permissions
12
13
14


class PreviousDepartureFeedback(UserRestrictedModule):
Florent Chehab's avatar
Florent Chehab committed
15
    model_config = get_model_config("Country")
16
    departure = models.OneToOneField(PreviousDeparture, on_delete=models.CASCADE)
17

Florent Chehab's avatar
Florent Chehab committed
18
    courses_and_courses_feedback = JSONField(default=dict)
19
20
21
22
    adequation_comment = models.CharField(default="", blank=True, max_length=5000)
    integration_comment = models.CharField(default="", blank=True, max_length=5000)
    adequation_grate = models.PositiveIntegerField(validators=[MaxValueValidator(20)])
    integration_grade = models.PositiveIntegerField(validators=[MaxValueValidator(20)])
23
24
25
26
27


class PreviousDepartureFeedbackSerializer(UserRestrictedModuleSerializer):
    class Meta:
        model = PreviousDepartureFeedback
28
        fields = "__all__"
29
30


31
class PreviousDepartureFeedbackViewSet(UserRestrictedModuleViewSet):
32
    permission_classes = get_viewset_permissions("PreviousDepartureFeedbackViewSet")
33
34
    queryset = PreviousDepartureFeedback.objects.all()  # pylint: disable=E1101
    serializer_class = PreviousDepartureFeedbackSerializer