countryDri.py 834 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.basic_module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
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 CountryDri(BasicModule):
Florent Chehab's avatar
Florent Chehab committed
8
    model_config = get_model_config("CountryDri")
Florent Chehab's avatar
Florent Chehab committed
9
10
11
    country = models.ManyToManyField(
        Country, related_name="country_dri")

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

Florent Chehab's avatar
Florent Chehab committed
16

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

    class Meta:
        model = CountryDri
        fields = '__all__'


24
class CountryDriViewSet(BasicModuleViewSet):
25
    permission_classes = get_viewset_permissions("CountryDriViewSet")
Florent Chehab's avatar
Florent Chehab committed
26
27
    queryset = CountryDri.objects.all()  # pylint: disable=E1101
    serializer_class = CountryDriSerializer