forked from DGNum/gestioCOF
Init app + models
Le modèle de profil BDS est le seul utile pour l'instant ; c'est un mix entre `CofProfile` et les modèles de Sport@Ulm.
This commit is contained in:
parent
4da5add25a
commit
bc7c30e2ee
6 changed files with 100 additions and 0 deletions
0
bds/__init__.py
Normal file
0
bds/__init__.py
Normal file
1
bds/admin.py
Normal file
1
bds/admin.py
Normal file
|
@ -0,0 +1 @@
|
|||
# Register your models here.
|
5
bds/apps.py
Normal file
5
bds/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BdsConfig(AppConfig):
|
||||
name = "bds"
|
0
bds/migrations/__init__.py
Normal file
0
bds/migrations/__init__.py
Normal file
93
bds/models.py
Normal file
93
bds/models.py
Normal file
|
@ -0,0 +1,93 @@
|
|||
from datetime import date
|
||||
from os.path import splitext
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
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")
|
||||
phone = models.CharField(_("Téléphone"), max_length=20, blank=True)
|
||||
occupation = models.CharField(
|
||||
_("Occupation"),
|
||||
default="1A",
|
||||
choices=OCCUPATION_CHOICES,
|
||||
max_length=choices_length(OCCUPATION_CHOICES),
|
||||
)
|
||||
departement = models.CharField(_("Département"), max_length=50, blank=True)
|
||||
birthdate = models.DateField(
|
||||
auto_now_add=False,
|
||||
auto_now=False,
|
||||
verbose_name="Date de naissance",
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
mails_bds = models.BooleanField(_("Recevoir les mails du BDS"), default=False)
|
||||
is_buro = models.BooleanField(_("Membre du Burô du BDS"), default=False)
|
||||
|
||||
has_certificate = models.BooleanField(_("Certificat médical"), default=False)
|
||||
certificate_file = models.FileField(
|
||||
_("Fichier de certificat médical"),
|
||||
upload_to=get_certificate_filename,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
ASPSL_number = models.CharField(
|
||||
"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)
|
||||
|
||||
cotisation_period = models.CharField(
|
||||
"Inscription", default="NO", choices=COTIZ_DURATION_CHOICES, max_length=3
|
||||
)
|
||||
|
||||
registration_date = models.DateField(
|
||||
auto_now_add=True, verbose_name="Date d'inscription"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Profil BDS"
|
||||
verbose_name_plural = "Profils BDS"
|
||||
|
||||
def __str__(self):
|
||||
return self.user.username
|
1
bds/views.py
Normal file
1
bds/views.py
Normal file
|
@ -0,0 +1 @@
|
|||
# Create your views here.
|
Loading…
Reference in a new issue