universityBasicModules.py 3.59 KB
Newer Older
1
from django.db import models
2
3
from backend.models.module import BasicModule
from backend.models.university import University
4
from rest_framework import viewsets, permissions
5
from backend.models.module import BasicModuleSerializer
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

####################
# Insurance
###################


class UniversityInsurance(BasicModule):
    university = models.OneToOneField(
        University, on_delete=models.CASCADE, related_name='university_insurances', primary_key=True)


class UniversityInsuranceSerializer(BasicModuleSerializer):
    class Meta:
        model = UniversityInsurance
        fields = '__all__'


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

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


####################
# Culture
###################

class UniversityCulture(BasicModule):
    university = models.OneToOneField(
        University, on_delete=models.CASCADE, related_name='university_culture', primary_key=True)


class UniversityCultureSerializer(BasicModuleSerializer):
    class Meta:
        model = UniversityCulture
        fields = '__all__'


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

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


####################
# Courses
###################

class UniversityCourses(BasicModule):
    university = models.OneToOneField(
        University, on_delete=models.CASCADE, related_name='university_courses', primary_key=True)


class UniversityCoursesSerializer(BasicModuleSerializer):
    class Meta:
        model = UniversityCourses
        fields = '__all__'


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


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


####################
# SpecialOffer
###################
# TODO clarify this

class UniversitySpecialOffer(BasicModule):
    university = models.OneToOneField(
        University, on_delete=models.CASCADE, related_name='university_special_offer', primary_key=True)


class UniversitySpecialOfferSerializer(BasicModuleSerializer):
    class Meta:
        model = UniversitySpecialOffer
        fields = '__all__'


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


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


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

class UniversityOtherStuff(BasicModule):
    university = models.OneToOneField(
        University, on_delete=models.CASCADE, related_name='university_other_stuff', primary_key=True)


class UniversityOtherStuffSerializer(BasicModuleSerializer):
    class Meta:
        model = UniversityOtherStuff
        fields = '__all__'


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