countryScholarship.py 728 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2

3
4
5
6
7
from backend_app.models.abstract.scholarship import (
    Scholarship,
    ScholarshipSerializer,
    ScholarshipViewSet,
)
8
from backend_app.models.country import Country
Florent Chehab's avatar
Florent Chehab committed
9
10
11


class CountryScholarship(Scholarship):
12
    countries = models.ManyToManyField(Country, related_name="country_scholarships")
Florent Chehab's avatar
Florent Chehab committed
13
14


15
class CountryScholarshipSerializer(ScholarshipSerializer):
Florent Chehab's avatar
Florent Chehab committed
16
17
    class Meta:
        model = CountryScholarship
18
        fields = "__all__"
Florent Chehab's avatar
Florent Chehab committed
19
20


21
class CountryScholarshipViewSet(ScholarshipViewSet):
Florent Chehab's avatar
Florent Chehab committed
22
23
    queryset = CountryScholarship.objects.all()  # pylint: disable=E1101
    serializer_class = CountryScholarshipSerializer
24
25
    end_point_route = "countryScholarships"
    filterset_fields = ("countries",)