campus.py 999 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
2
3
4
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
30
31
32
33
from django.db import models
from rex.models.module import Module
from rex.models.localization import City
from django.core.validators import MinValueValidator, MaxValueValidator


class Campus(Module):
    name = models.CharField(max_length=200, null=True)
    comment = models.TextField(null=True, blank=True)
    city = models.ForeignKey(City, on_delete=models.PROTECT, null=False)

    lat = models.DecimalField(
        max_digits=10,
        decimal_places=6,
        validators=[MinValueValidator(-85.05112878),
                    MaxValueValidator(85.05112878)]
    )

    lon = models.DecimalField(
        max_digits=10,
        decimal_places=6,
        validators=[MinValueValidator(-180),
                    MaxValueValidator(180)]
    )

    class Meta:
        abstract = True


class MainCampus(Campus):
    module_icon = "You forget to override the icon in the sub-class : I know"
    module_name = "Campus principal"
    module_description = "Campus principal de l'université."