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

####################
# CultureAndStudentLife
###################


class CampusCultureAndStudentLife(BasicModule):
    campus = models.OneToOneField(
        Campus, on_delete=models.CASCADE, related_name='campus_culture_and_sl', primary_key=True)

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

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

class CampusCultureAndStudentLifeSerializer(BasicModuleSerializer):
    class Meta:
        model = CampusCultureAndStudentLife
        fields = '__all__'


25
class CampusCultureAndStudentLifeViewSet(BasicModuleViewSet):
Florent Chehab's avatar
Florent Chehab committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    queryset = CampusCultureAndStudentLife.objects.all()  # pylint: disable=E1101
    serializer_class = CampusCultureAndStudentLifeSerializer

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


####################
# CampusAccommodation
###################

class CampusAccommodation(BasicModule):
    campus = models.OneToOneField(
        Campus, on_delete=models.CASCADE, related_name='campus_accomodation', primary_key=True)

41
42
43
44
    @classmethod
    def get_serializer(cls):
        return CampusAccommodationSerializer

Florent Chehab's avatar
Florent Chehab committed
45
46
47
48
49
50
51

class CampusAccommodationSerializer(BasicModuleSerializer):
    class Meta:
        model = CampusAccommodation
        fields = '__all__'


52
class CampusAccommodationViewSet(BasicModuleViewSet):
Florent Chehab's avatar
Florent Chehab committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    queryset = CampusAccommodation.objects.all()  # pylint: disable=E1101
    serializer_class = CampusAccommodationSerializer

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


####################
# Transport
###################

class CampusTransport(BasicModule):
    campus = models.OneToOneField(
        Campus, on_delete=models.CASCADE, related_name='campus_transport', primary_key=True)

68
69
70
71
    @classmethod
    def get_serializer(cls):
        return CampusTransportSerializer

Florent Chehab's avatar
Florent Chehab committed
72
73
74
75
76
77
78

class CampusTransportSerializer(BasicModuleSerializer):
    class Meta:
        model = CampusTransport
        fields = '__all__'


79
class CampusTransportViewSet(BasicModuleViewSet):
Florent Chehab's avatar
Florent Chehab committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    queryset = CampusTransport.objects.all()  # pylint: disable=E1101
    serializer_class = CampusTransportSerializer


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


####################
# OtherStuff
###################

class CampusOtherStuff(BasicModule):
    campus = models.OneToOneField(
        Campus, on_delete=models.CASCADE, related_name='campus_other_stuff', primary_key=True)

96
97
98
99
    @classmethod
    def get_serializer(cls):
        return CampusOtherStuffSerializer

Florent Chehab's avatar
Florent Chehab committed
100
101
102
103
104
105
106

class CampusOtherStuffSerializer(BasicModuleSerializer):
    class Meta:
        model = CampusOtherStuff
        fields = '__all__'


107
class CampusOtherStuffViewSet(BasicModuleViewSet):
Florent Chehab's avatar
Florent Chehab committed
108
109
    queryset = CampusOtherStuff.objects.all()  # pylint: disable=E1101
    serializer_class = CampusOtherStuffSerializer