countryScholarship.py 912 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2 3
from backend.models.country import Country
from backend.models.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 CountryScholarship(Scholarship):
Florent Chehab's avatar
Florent Chehab committed
8
    model_config = get_model_config("CountryScholarship")
Florent Chehab's avatar
Florent Chehab committed
9 10 11
    country = models.ManyToManyField(
        Country, related_name="country_scholarhip")

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

Florent Chehab's avatar
Florent Chehab committed
16

17
class CountryScholarshipSerializer(ScholarshipSerializer):
Florent Chehab's avatar
Florent Chehab committed
18 19 20 21 22 23

    class Meta:
        model = CountryScholarship
        fields = '__all__'


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