2019-07-17 14:34:18 +02:00
|
|
|
from datetime import date
|
|
|
|
from os.path import splitext
|
|
|
|
|
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.db import models
|
2019-10-06 19:03:19 +02:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2019-07-17 14:34:18 +02:00
|
|
|
|
|
|
|
from shared.utils import choices_length
|
|
|
|
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
|
|
|
|
|
|
class BDSProfile(models.Model):
|
|
|
|
OCCUPATION_CHOICES = (
|
|
|
|
("EXT", "Extérieur"),
|
|
|
|
("1A", "1A"),
|
|
|
|
("2A", "2A"),
|
|
|
|
("3A", "3A"),
|
|
|
|
("4A", "4A"),
|
|
|
|
("MAG", "Magistérien"),
|
|
|
|
("ARC", "Archicube"),
|
|
|
|
("DOC", "Doctorant"),
|
|
|
|
("CST", "CST"),
|
|
|
|
("PER", "Personnel ENS"),
|
|
|
|
)
|
|
|
|
|
|
|
|
TYPE_COTIZ_CHOICES = (
|
|
|
|
("ETU", "Étudiant"),
|
|
|
|
("NOR", "Normalien"),
|
|
|
|
("EXT", "Extérieur"),
|
|
|
|
("ARC", "Archicube"),
|
|
|
|
)
|
|
|
|
|
|
|
|
COTIZ_DURATION_CHOICES = (
|
|
|
|
("ANN", "Année"),
|
|
|
|
("SE1", "Premier semestre"),
|
|
|
|
("SE2", "Deuxième semestre"),
|
|
|
|
("NO", "Aucune"),
|
|
|
|
)
|
|
|
|
|
|
|
|
def get_certificate_filename(instance, filename):
|
|
|
|
_, ext = splitext(filename) # récupère l'extension du fichier
|
|
|
|
year = str(date.now().year)
|
|
|
|
return "certifs/{username}-{year}.{ext}".format(
|
|
|
|
username=instance.user.username, year=year, ext=ext
|
|
|
|
)
|
|
|
|
|
|
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="bds")
|
2019-10-06 19:03:19 +02:00
|
|
|
phone = models.CharField(_("téléphone"), max_length=20, blank=True)
|
2019-07-17 14:34:18 +02:00
|
|
|
occupation = models.CharField(
|
2019-10-06 19:03:19 +02:00
|
|
|
_("occupation"),
|
2019-07-17 14:34:18 +02:00
|
|
|
default="1A",
|
|
|
|
choices=OCCUPATION_CHOICES,
|
|
|
|
max_length=choices_length(OCCUPATION_CHOICES),
|
|
|
|
)
|
2019-10-06 19:03:19 +02:00
|
|
|
departement = models.CharField(_("département"), max_length=50, blank=True)
|
2019-07-17 14:34:18 +02:00
|
|
|
birthdate = models.DateField(
|
|
|
|
auto_now_add=False,
|
|
|
|
auto_now=False,
|
2019-10-06 19:03:19 +02:00
|
|
|
verbose_name=_("date de naissance"),
|
2019-07-17 14:34:18 +02:00
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
2019-10-06 19:03:19 +02:00
|
|
|
mails_bds = models.BooleanField(_("recevoir les mails du BDS"), default=False)
|
2019-07-17 14:34:18 +02:00
|
|
|
|
2019-10-06 19:03:19 +02:00
|
|
|
has_certificate = models.BooleanField(_("certificat médical"), default=False)
|
2019-07-17 14:34:18 +02:00
|
|
|
certificate_file = models.FileField(
|
2019-10-06 19:03:19 +02:00
|
|
|
_("fichier de certificat médical"),
|
2019-07-17 14:34:18 +02:00
|
|
|
upload_to=get_certificate_filename,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
ASPSL_number = models.CharField(
|
2019-10-06 19:03:19 +02:00
|
|
|
_("numéro AS PSL"), max_length=50, blank=True, null=True
|
|
|
|
)
|
|
|
|
FFSU_number = models.CharField(
|
|
|
|
_("numéro FFSU"), max_length=50, blank=True, null=True
|
2019-07-17 14:34:18 +02:00
|
|
|
)
|
|
|
|
|
2019-12-26 23:19:41 +01:00
|
|
|
is_member = models.BooleanField(_("adhérent⋅e du BDS"), default=False)
|
2019-07-17 14:34:18 +02:00
|
|
|
cotisation_period = models.CharField(
|
2019-10-06 19:03:19 +02:00
|
|
|
_("inscription"), default="NO", choices=COTIZ_DURATION_CHOICES, max_length=3
|
2019-07-17 14:34:18 +02:00
|
|
|
)
|
|
|
|
registration_date = models.DateField(
|
2019-10-06 19:03:19 +02:00
|
|
|
auto_now_add=True, verbose_name=_("date d'inscription")
|
2019-07-17 14:34:18 +02:00
|
|
|
)
|
2019-12-22 11:15:16 +01:00
|
|
|
cotisation_type = models.CharField(
|
|
|
|
_("type de cotisation"), choices=TYPE_COTIZ_CHOICES, max_length=9
|
|
|
|
)
|
2019-07-17 14:34:18 +02:00
|
|
|
|
|
|
|
class Meta:
|
2019-10-06 19:03:19 +02:00
|
|
|
verbose_name = _("Profil BDS")
|
|
|
|
verbose_name_plural = _("Profils BDS")
|
2019-12-20 23:49:24 +01:00
|
|
|
permissions = (("is_team", _("est membre du burô")),)
|
2019-07-17 14:34:18 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.user.username
|