serializers.py 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
from backend_app.models.abstract.base import BaseModelSerializer
from backend_app.models.abstract.essentialModule import EssentialModuleSerializer
from backend_app.models.course import Course
from backend_app.models.courseFeedback import CourseFeedback
from backend_app.models.exchange import Exchange


class CourseFeedbackSerializer(EssentialModuleSerializer):
    class Meta:
        model = CourseFeedback
        fields = EssentialModuleSerializer.Meta.fields + (
12
            "language",
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
            "comment",
            "adequation",
            "working_dose",
            "language_following_ease",
        )


class CourseSerializer(BaseModelSerializer):
    course_feedback = CourseFeedbackSerializer(many=False, read_only=True)

    class Meta:
        model = Course
        fields = BaseModelSerializer.Meta.fields + (
            "course_feedback",
            "code",
            "title",
            "link",
            "nb_credit",
            "category",
            "profile",
            "tsh_profile",
        )
        read_only_fields = ("course_feedback",)


class ExchangeSerializer(BaseModelSerializer):
    exchange_courses = CourseSerializer(many=True, read_only=True)

    class Meta:
        model = Exchange
        fields = BaseModelSerializer.Meta.fields + (
            "year",
            "semester",
            "duration",
            "dual_degree",
            "master_obtained",
            "student_major",
            "student_minor",
            "student_option",
            "exchange_courses",
        )