universityInfo.py 1.11 KB
Newer Older
1
from django.db import models
2
from backend_app.models.abstract.module import Module, ModuleSerializer, ModuleViewSet
Florent Chehab's avatar
Florent Chehab committed
3
4
from backend_app.models.university import University
from backend_app.models.currency import Currency
5
6
7
from django.core.validators import MinValueValidator


8
class UniversityInfo(Module):
9
10

    university = models.OneToOneField(
11
12
13
14
15
16
        University,
        on_delete=models.CASCADE,
        related_name="university_info",
        primary_key=True,
        null=False,
    )
17
18

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

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

26
    costs_currency = models.ForeignKey(Currency, on_delete=models.PROTECT, null=True)
27
28


29
class UniversityInfoSerializer(ModuleSerializer):
30
31
    class Meta:
        model = UniversityInfo
32
        fields = "__all__"
33
34


35
class UniversityInfoViewSet(ModuleViewSet):
36
37
    queryset = UniversityInfo.objects.all()  # pylint: disable=E1101
    serializer_class = UniversityInfoSerializer