universityScholarship.py 965 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.abstract.scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
Florent Chehab's avatar
Florent Chehab committed
4
from backend.utils import get_model_config, get_viewset_permissions
Florent Chehab's avatar
Florent Chehab committed
5
6
7


class UniversityScholarship(Scholarship):
Florent Chehab's avatar
Florent Chehab committed
8
    model_config = get_model_config("UniversityScholarship")
9
    university = models.ManyToManyField(University, related_name="university_scholarships")
Florent Chehab's avatar
Florent Chehab committed
10

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

Florent Chehab's avatar
Florent Chehab committed
15

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

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


23
class UniversityScholarshipViewSet(ScholarshipViewSet):
24
25
    permission_classes = get_viewset_permissions(
        "UniversityScholarshipViewSet")
Florent Chehab's avatar
Florent Chehab committed
26
27
    queryset = UniversityScholarship.objects.all()  # pylint: disable=E1101
    serializer_class = UniversityScholarshipSerializer