From 5ab090fa72d941eff6650f584ed7c876ab8d0cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Thu, 26 Oct 2017 14:04:15 +0200 Subject: [PATCH] rm cofprofile.num, add PEI / GRATIS --- cof/forms.py | 6 +----- cof/models.py | 21 +++++++++++-------- gestion/migrations/0001_initial.py | 2 +- gestion/models.py | 33 ++++++++++++++++++++---------- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/cof/forms.py b/cof/forms.py index a9d91ed6..b4b7236c 100644 --- a/cof/forms.py +++ b/cof/forms.py @@ -165,14 +165,10 @@ class RegistrationPassUserForm(RegistrationUserForm): class RegistrationCofProfileForm(forms.ModelForm): - def __init__(self, *args, **kwargs): - super(RegistrationCofProfileForm, self).__init__(*args, **kwargs) - self.fields['num'].widget.attrs['readonly'] = True - class Meta: model = CofProfile fields = [ - "num", "type_cotiz", + "type_cotiz", "mailing", "mailing_bda", "mailing_bda_revente", ] diff --git a/cof/models.py b/cof/models.py index 4aba0ad3..28f7291d 100644 --- a/cof/models.py +++ b/cof/models.py @@ -16,19 +16,22 @@ def get_cof_assoc(): return Association.objects.get(name='COF') -TYPE_COTIZ_CHOICES = ( - ('etudiant', _("Normalien étudiant")), - ('normalien', _("Normalien élève")), - ('exterieur', _("Extérieur")), -) - - class CofProfile(models.Model): + COTIZ_ETUDIANT = "etudiant" + COTIZ_NORMALIEN = "normalien" + COTIZ_EXTE = "exterieur" + COTIZ_GRATIS = "gratis" + + TYPE_COTIZ_CHOICES = ( + (COTIZ_ETUDIANT, _("Normalien étudiant")), + (COTIZ_NORMALIEN, _("Normalien élève")), + (COTIZ_EXTE, _("Extérieur")), + (COTIZ_GRATIS, _("Gratuit")), + ) + profile = models.OneToOneField(Profile, on_delete=models.CASCADE, related_name="cof") - - num = models.IntegerField("Numéro d'adhérent", blank=True, default=0) type_cotiz = models.CharField(_("Type de cotisation"), default="normalien", choices=TYPE_COTIZ_CHOICES, diff --git a/gestion/migrations/0001_initial.py b/gestion/migrations/0001_initial.py index 5f251978..585e7109 100644 --- a/gestion/migrations/0001_initial.py +++ b/gestion/migrations/0001_initial.py @@ -20,7 +20,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)), ('login_clipper', models.CharField(verbose_name='login clipper', max_length=8, blank=True)), ('phone', models.CharField(verbose_name='téléphone', max_length=20, blank=True)), - ('occupation', models.CharField(choices=[('exterieur', 'Extérieur'), ('1A', '1A'), ('2A', '2A'), ('3A', '3A'), ('4A', '4A'), ('archicube', 'Archicube'), ('doctorant', 'Doctorant'), ('CST', 'CST')], verbose_name='occupation', max_length=9, default='1A')), + ('occupation', models.CharField(choices=[('exterieur', 'Extérieur'), ('1A', '1A'), ('2A', '2A'), ('3A', '3A'), ('4A', '4A'), ('archicube', 'Archicube'), ('doctorant', 'Doctorant'), ('CST', 'CST'), ('PEI', 'PEI')], verbose_name='occupation', max_length=9, default='1A')), ('departement', models.CharField(verbose_name='département', max_length=50, blank=True)), ('comments', models.TextField(verbose_name="commentaires visibles par l'utilisateur", blank=True)), ('user', models.OneToOneField( diff --git a/gestion/models.py b/gestion/models.py index a4881f8c..54c259c5 100644 --- a/gestion/models.py +++ b/gestion/models.py @@ -12,19 +12,30 @@ from cof.petits_cours_models import choices_length # User management # --- -OCCUPATION_CHOICES = ( - ('exterieur', _("Extérieur")), - ('1A', _("1A")), - ('2A', _("2A")), - ('3A', _("3A")), - ('4A', _("4A")), - ('archicube', _("Archicube")), - ('doctorant', _("Doctorant")), - ('CST', _("CST")), -) - class Profile(models.Model): + STATUS_EXTE = "exterieur" + STATUS_1A = "1A" + STATUS_2A = "2A" + STATUS_3A = "3A" + STATUS_4A = "4A" + STATUS_ARCHI = "archicube" + STATUS_DOCTORANT = "doctorant" + STATUS_CST = "CST" + STATUS_PEI = "PEI" + + OCCUPATION_CHOICES = ( + (STATUS_EXTE, _("Extérieur")), + (STATUS_1A, _("1A")), + (STATUS_2A, _("2A")), + (STATUS_3A, _("3A")), + (STATUS_4A, _("4A")), + (STATUS_ARCHI, _("Archicube")), + (STATUS_DOCTORANT, _("Doctorant")), + (STATUS_CST, _("CST")), + (STATUS_PEI, _("PEI")), + ) + user = models.OneToOneField( User, on_delete=models.CASCADE,