countryBasicModules.py 4.92 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2
3
from backend.models.module import BasicModule
from backend.models.location import Country
Florent Chehab's avatar
Florent Chehab committed
4
from rest_framework import viewsets, permissions
5
from backend.models.module import BasicModuleSerializer
Florent Chehab's avatar
Florent Chehab committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134


####################
# CountryVisaAdministrative
###################

class CountryVisaAdministrative(BasicModule):
    country = models.OneToOneField(
        Country, on_delete=models.CASCADE, related_name='country_visa_administrative', primary_key=True)


class CountryVisaAdministrativeSerializer(BasicModuleSerializer):
    class Meta:
        model = CountryVisaAdministrative
        fields = '__all__'


# TODO switch to dict
class CountryVisaAdministrativeViewSet(viewsets.ModelViewSet):
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = CountryVisaAdministrative.objects.all()  # pylint: disable=E1101
    serializer_class = CountryVisaAdministrativeSerializer


#####################
#####################


####################
# CountryHealthInsurance
###################


class CountryHealthInsurance(BasicModule):
    country = models.OneToOneField(
        Country, on_delete=models.CASCADE, related_name='country_health_insurances', primary_key=True)


class CountryHealthInsuranceSerializer(BasicModuleSerializer):
    class Meta:
        model = CountryHealthInsurance
        fields = '__all__'


# TODO switch to dict
class CountryHealthInsuranceViewSet(viewsets.ModelViewSet):
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = CountryHealthInsurance.objects.all()  # pylint: disable=E1101
    serializer_class = CountryHealthInsuranceSerializer

#####################
#####################


####################
# Other Insurance
###################


class CountryOtherInsurance(BasicModule):
    country = models.OneToOneField(
        Country, on_delete=models.CASCADE, related_name='country_other_insurances', primary_key=True)


class CountryOtherInsuranceSerializer(BasicModuleSerializer):
    class Meta:
        model = CountryOtherInsurance
        fields = '__all__'


# TODO switch to dict
class CountryOtherInsuranceViewSet(viewsets.ModelViewSet):
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = CountryOtherInsurance.objects.all()  # pylint: disable=E1101
    serializer_class = CountryOtherInsuranceSerializer

#####################
#####################


####################
# CountryCulture
###################

class CountryCulture(BasicModule):
    country = models.OneToOneField(
        Country, on_delete=models.CASCADE, related_name='country_culture', primary_key=True)


class CountryCultureSerializer(BasicModuleSerializer):
    class Meta:
        model = CountryCulture
        fields = '__all__'


class CountryCultureViewSet(viewsets.ModelViewSet):  # TODO switch to dict
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = CountryCulture.objects.all()  # pylint: disable=E1101
    serializer_class = CountryCultureSerializer

#####################
#####################


####################
# CountryTransport
###################

class CountryTransport(BasicModule):
    country = models.OneToOneField(
        Country, on_delete=models.CASCADE, related_name='country_transport', primary_key=True)


class CountryTransportSerializer(BasicModuleSerializer):
    class Meta:
        model = CountryTransport
        fields = '__all__'


class CountryTransportViewSet(viewsets.ModelViewSet):  # TODO switch to dict
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = CountryTransport.objects.all()  # pylint: disable=E1101
    serializer_class = CountryTransportSerializer


#####################
#####################


Florent Chehab's avatar
Florent Chehab committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
####################
# CountryTourism
###################

class CountryTourism(BasicModule):
    country = models.OneToOneField(
        Country, on_delete=models.CASCADE, related_name='country_tourism', primary_key=True)


class CountryTourismSerializer(BasicModuleSerializer):
    class Meta:
        model = CountryTourism
        fields = '__all__'


class CountryTourismViewSet(viewsets.ModelViewSet):  # TODO switch to dict
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = CountryTourism.objects.all()  # pylint: disable=E1101
    serializer_class = CountryTourismSerializer


#####################
#####################


Florent Chehab's avatar
Florent Chehab committed
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
####################
# CountryOtherStuff
###################

class CountryOtherStuff(BasicModule):
    country = models.OneToOneField(
        Country, on_delete=models.CASCADE, related_name='country_other_stuff', primary_key=True)


class CountryOtherStuffSerializer(BasicModuleSerializer):
    class Meta:
        model = CountryOtherStuff
        fields = '__all__'


# TODO switch to dict
class CountryOtherStuffViewSet(viewsets.ModelViewSet):
    permission_classes = (permissions.DjangoModelPermissions,)
    queryset = CountryOtherStuff.objects.all()  # pylint: disable=E1101
    serializer_class = CountryOtherStuffSerializer