cityBasicModules.py 1.99 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
2
from backend.models.module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
3
from backend.models.location import City
Florent Chehab's avatar
Florent Chehab committed
4 5 6 7 8 9 10 11 12 13


####################
# CityTransport
###################

class CityTransport(BasicModule):
    city = models.OneToOneField(
        City, on_delete=models.CASCADE, related_name='city_transport', primary_key=True)

14 15
    @classmethod
    def get_serializer(cls):
16 17
        return CityTransportSerializer

Florent Chehab's avatar
Florent Chehab committed
18 19 20 21 22 23 24

class CityTransportSerializer(BasicModuleSerializer):
    class Meta:
        model = CityTransport
        fields = '__all__'


25 26
class CityTransportViewSet(BasicModuleViewSet):

Florent Chehab's avatar
Florent Chehab committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    queryset = CityTransport.objects.all()  # pylint: disable=E1101
    serializer_class = CityTransportSerializer


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


####################
# CityTourism
###################

class CityTourism(BasicModule):
    city = models.OneToOneField(
        City, on_delete=models.CASCADE, related_name='city_tourism', primary_key=True)

43 44 45 46
    @classmethod
    def get_serializer(cls):
        return CityTourismSerializer

Florent Chehab's avatar
Florent Chehab committed
47 48 49 50 51 52 53

class CityTourismSerializer(BasicModuleSerializer):
    class Meta:
        model = CityTourism
        fields = '__all__'


54 55
class CityTourismViewSet(BasicModuleViewSet):

Florent Chehab's avatar
Florent Chehab committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    queryset = CityTourism.objects.all()  # pylint: disable=E1101
    serializer_class = CityTourismSerializer


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


####################
# CityOtherStuff
###################

class CityOtherStuff(BasicModule):
    city = models.OneToOneField(
        City, on_delete=models.CASCADE, related_name='city_other_stuff', primary_key=True)

72 73 74 75
    @classmethod
    def get_serializer(cls):
        return CityOtherStuffSerializer

Florent Chehab's avatar
Florent Chehab committed
76 77 78 79 80 81 82

class CityOtherStuffSerializer(BasicModuleSerializer):
    class Meta:
        model = CityOtherStuff
        fields = '__all__'


83 84
class CityOtherStuffViewSet(BasicModuleViewSet):

Florent Chehab's avatar
Florent Chehab committed
85 86
    queryset = CityOtherStuff.objects.all()  # pylint: disable=E1101
    serializer_class = CityOtherStuffSerializer