universityScholarship.py 766 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2
from backend.models.university import University
3
from backend.models.module import Scholarship, ScholarshipSerializer, ScholarshipViewSet
Florent Chehab's avatar
Florent Chehab committed
4 5 6


class UniversityScholarship(Scholarship):
Florent Chehab's avatar
Florent Chehab committed
7 8 9
    university = models.ForeignKey(
        University, on_delete=models.PROTECT, null=False, related_name="univScholarship")

10 11 12 13
    @classmethod
    def get_serializer(cls):
        return UniversityScholarshipSerializer

Florent Chehab's avatar
Florent Chehab committed
14

15
class UniversityScholarshipSerializer(ScholarshipSerializer):
Florent Chehab's avatar
Florent Chehab committed
16 17 18

    class Meta:
        model = UniversityScholarship
Florent Chehab's avatar
Florent Chehab committed
19
        fields = '__all__'
Florent Chehab's avatar
Florent Chehab committed
20 21


22
class UniversityScholarshipViewSet(ScholarshipViewSet):
Florent Chehab's avatar
Florent Chehab committed
23 24
    queryset = UniversityScholarship.objects.all()  # pylint: disable=E1101
    serializer_class = UniversityScholarshipSerializer