universityScholarship.py 997 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
4
from backend.utils import get_moderation_level, get_viewset_permissions
Florent Chehab's avatar
Florent Chehab committed
5
6
7


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

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

Florent Chehab's avatar
Florent Chehab committed
16

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

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


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