gestioCOF/bds/models.py
Aurélien Delobelle 29d288c567 Fix permissions setup of associations.
- Permissions of 'gestion' app are correctly added to the staff groups
of associations.
- Add tests to ensure staff groups of COF and BDS are correctly setup.
- Shortcut functions are added to retrieve COF and BDS association.
2017-09-05 15:02:33 +02:00

69 lines
2.4 KiB
Python

import os.path
from django.utils import timezone
from django.db import models
from gestion.models import Association, Profile
def get_bds_assoc():
return Association.objects.get(name='BDS')
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)
year = timezone.now().year
return "certifs/{!s}-{:d}{:s}".format(sportif, year, extension)
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")
payment_method = models.CharField('Methode de paiement',
default='CASH',
choices=PAYMENT_METHOD_CHOICES,
max_length=6)
class Meta:
verbose_name = "Profil BDS"
verbose_name_plural = "Profils BDS"
permissions = [
("member", "Is a BDS member"),
("buro", "Is part of the BDS staff")
]