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

4
from backend.models.user import UserRestrictedModule, UserRestrictedModuleSerializer, UserRestrictedModuleViewSet
5
from backend.models.user import PreviousDeparture
6 7 8 9 10 11 12
from django.contrib.postgres.fields import JSONField


class PreviousDepartureFeedback(UserRestrictedModule):
    departure = models.OneToOneField(
        PreviousDeparture, on_delete=models.CASCADE)

Florent Chehab's avatar
Florent Chehab committed
13
    courses_and_courses_feedback = JSONField(default=dict)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    adequation_comment = models.TextField()
    integration_comment = models.TextField()
    adequation_grate = models.PositiveIntegerField(
        validators=[MaxValueValidator(20)])
    integration_grade = models.PositiveIntegerField(
        validators=[MaxValueValidator(20)])
    # TODO check on save that courses are coherent with Previous Departure


class PreviousDepartureFeedbackSerializer(UserRestrictedModuleSerializer):

    class Meta:
        model = PreviousDepartureFeedback
        fields = '__all__'


30
class PreviousDepartureFeedbackViewSet(UserRestrictedModuleViewSet):
31 32
    queryset = PreviousDepartureFeedback.objects.all()  # pylint: disable=E1101
    serializer_class = PreviousDepartureFeedbackSerializer