2017-02-11 17:13:48 +01:00
|
|
|
import os.path
|
2017-02-09 21:04:32 +01:00
|
|
|
|
2017-02-11 20:36:16 +01:00
|
|
|
from django.utils import timezone
|
2017-02-11 17:13:48 +01:00
|
|
|
from django.db import models
|
2017-02-10 20:10:45 +01:00
|
|
|
|
|
|
|
from gestion.models import Profile
|
|
|
|
|
2017-02-11 20:36:16 +01:00
|
|
|
|
2017-02-11 17:13:48 +01:00
|
|
|
class BdsProfile(models.Model):
|
|
|
|
profile = models.OneToOneField(Profile,
|
|
|
|
related_name='bds',
|
|
|
|
on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
def issue_file_name(sportif, filename):
|
|
|
|
fn, extension = os.path.splitext(filename)
|
2017-02-11 20:36:16 +01:00
|
|
|
year = timezone.now().year
|
|
|
|
return "certifs/{!s}-{:d}{:s}".format(sportif, year, extension)
|
2017-02-11 17:13:48 +01:00
|
|
|
|
|
|
|
COTIZ_DURATION_CHOICES = (
|
|
|
|
('ANN', 'Année'),
|
|
|
|
('SE1', 'Premier semestre'),
|
|
|
|
('SE2', 'Deuxième semestre'),
|
|
|
|
)
|
|
|
|
|
|
|
|
PAYMENT_METHOD_CHOICES = (
|
|
|
|
('CASH', 'Liquide'),
|
|
|
|
('BANK', 'Transfer bancaire'),
|
|
|
|
('CHEQUE', 'Cheque'),
|
|
|
|
('OTHER', 'Autre'),
|
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
have_certificate = models.BooleanField("Certificat médical",
|
|
|
|
default=False)
|
|
|
|
certificate_file = models.FileField("Fichier de certificat médical",
|
|
|
|
upload_to=issue_file_name,
|
|
|
|
blank=True)
|
|
|
|
|
|
|
|
cotisation_period = models.CharField("Inscription",
|
|
|
|
default="ANN",
|
|
|
|
choices=COTIZ_DURATION_CHOICES,
|
|
|
|
max_length=3)
|
|
|
|
registration_date = models.DateField(auto_now_add=True,
|
|
|
|
verbose_name="Date d'inscription")
|
2017-02-10 20:10:45 +01:00
|
|
|
|
2017-02-11 17:13:48 +01:00
|
|
|
payment_method = models.CharField('Methode de paiement',
|
|
|
|
default='CASH',
|
|
|
|
choices=PAYMENT_METHOD_CHOICES,
|
|
|
|
max_length=6)
|
2017-02-22 18:19:49 +01:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = "Profil BDS"
|
|
|
|
verbose_name_plural = "Profils BDS"
|
|
|
|
permissions = [
|
|
|
|
("member", "Is a BDS member"),
|
|
|
|
("buro", "Is part of the BDS staff")
|
|
|
|
]
|