university.py 1.06 KB
Newer Older
1
from django.conf import settings
2
from django.db import models
3

4 5 6 7 8
from backend_app.models.abstract.essentialModule import (
    EssentialModule,
    EssentialModuleSerializer,
    EssentialModuleViewSet,
)
9
from backend_app.validation.validators import PathExtensionValidator
Florent Chehab's avatar
Florent Chehab committed
10

11

12
class University(EssentialModule):
13 14 15
    """
    Model storing information about universities
    """
16

17
    name = models.CharField(max_length=200)
18 19
    acronym = models.CharField(max_length=20, default="", blank=True)
    logo = models.URLField(
20 21 22
        default="",
        blank=True,
        validators=[PathExtensionValidator(settings.ALLOWED_PHOTOS_EXTENSION)],
23 24
    )
    website = models.URLField(default="", blank=True, max_length=300)
25 26 27
    utc_id = models.IntegerField(unique=True)


28
class UniversitySerializer(EssentialModuleSerializer):
29 30
    class Meta:
        model = University
31
        exclude = ("utc_id",)
Florent Chehab's avatar
Florent Chehab committed
32 33


34
class UniversityViewSet(EssentialModuleViewSet):
35 36
    serializer_class = UniversitySerializer
    queryset = University.objects.all()  # pylint: disable=E1101
37
    end_point_route = "universities"