universityInfo.py 1.19 KB
Newer Older
1
from django.core.validators import MinValueValidator
2
from django.db import models
3

4
from backend_app.models.abstract.module import Module, ModuleSerializer, ModuleViewSet
Florent Chehab's avatar
Florent Chehab committed
5
from backend_app.models.currency import Currency
6
from backend_app.models.university import University
7 8


9
class UniversityInfo(Module):
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
38
    # permission_classes = (ReadOnly,)
39
    end_point_route = "universityInfo"