countryDri.py 738 Bytes
Newer Older
1
from django.db import models
2

3
from backend_app.models.abstract.module import Module, ModuleSerializer, ModuleViewSet
4 5
from backend_app.models.country import Country
from backend_app.permissions.app_permissions import IsStaff, IsDri, NoPost
6 7


8
class CountryDri(Module):
9
    countries = models.ManyToManyField(Country, related_name="country_dri")
10 11


12
class CountryDriSerializer(ModuleSerializer):
13 14
    class Meta:
        model = CountryDri
15
        fields = "__all__"
16 17


18
class CountryDriViewSet(ModuleViewSet):
19 20
    queryset = CountryDri.objects.all()  # pylint: disable=E1101
    serializer_class = CountryDriSerializer
21
    permission_classes = (IsStaff | IsDri | NoPost,)
22 23
    end_point_route = "countryDri"
    filterset_fields = ("countries",)