universityInfo.py 1.12 KB
Newer Older
1
from django.db import models
2
from backend.models.module import BasicModule, BasicModuleSerializer, BasicModuleViewSet
3
4
from backend.models.university import University
from backend.models.module import Currency
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.core.validators import MinValueValidator


class UniversityInfo(BasicModule):

    university = models.OneToOneField(
        University, on_delete=models.CASCADE, related_name='university_info', primary_key=True, null=False)

    cost_exchange = models.DecimalField(
        decimal_places=2,
        max_digits=20,
        validators=[MinValueValidator(0)],
        null=True
    )

    cost_double_degree = models.DecimalField(
        decimal_places=2,
        max_digits=20,
        validators=[MinValueValidator(0)],
        null=True
    )

    costs_currency = models.ForeignKey(Currency, on_delete=models.PROTECT)


Florent Chehab's avatar
Florent Chehab committed
30
class UniversityInfoSerializer(BasicModuleSerializer):
31
32
33

    class Meta:
        model = UniversityInfo
Florent Chehab's avatar
Florent Chehab committed
34
        fields = '__all__'
35
36


37
class UniversityInfoViewSet(BasicModuleViewSet):
38
39
    queryset = UniversityInfo.objects.all()  # pylint: disable=E1101
    serializer_class = UniversityInfoSerializer