From 4d5419fdbc84ad580303f9121b131e6e54661039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 20 Dec 2019 23:49:24 +0100 Subject: [PATCH 1/3] Use permissions to authenticate bds buro members I prefer using a permission (namely `bds.is_team`) to determine if a user is member of the BDS staff rather that using a `is_buro` boolean field. We already use this approach is the kfet app --- bds/migrations/0003_staff_permission.py | 22 ++++++++++++++++++++++ bds/models.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 bds/migrations/0003_staff_permission.py diff --git a/bds/migrations/0003_staff_permission.py b/bds/migrations/0003_staff_permission.py new file mode 100644 index 00000000..1f038eaa --- /dev/null +++ b/bds/migrations/0003_staff_permission.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.8 on 2019-12-20 22:48 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bds", "0002_bds_group"), + ] + + operations = [ + migrations.AlterModelOptions( + name="bdsprofile", + options={ + "permissions": (("is_team", "est membre du burô"),), + "verbose_name": "Profil BDS", + "verbose_name_plural": "Profils BDS", + }, + ), + migrations.RemoveField(model_name="bdsprofile", name="is_buro",), + ] diff --git a/bds/models.py b/bds/models.py index f262ee26..eb5a67aa 100644 --- a/bds/models.py +++ b/bds/models.py @@ -63,7 +63,6 @@ class BDSProfile(models.Model): ) 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( @@ -90,6 +89,7 @@ class BDSProfile(models.Model): class Meta: verbose_name = _("Profil BDS") verbose_name_plural = _("Profils BDS") + permissions = (("is_team", _("est membre du burô")),) def __str__(self): return self.user.username From 8bae013152ecbbf403196763e5d59960f1bcc9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 22 Dec 2019 11:15:16 +0100 Subject: [PATCH 2/3] BDSProfile: add is_member & cotisation_type fields --- bds/migrations/0004_is_member_cotiz_type.py | 34 +++++++++++++++++++++ bds/models.py | 5 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 bds/migrations/0004_is_member_cotiz_type.py diff --git a/bds/migrations/0004_is_member_cotiz_type.py b/bds/migrations/0004_is_member_cotiz_type.py new file mode 100644 index 00000000..53d332d8 --- /dev/null +++ b/bds/migrations/0004_is_member_cotiz_type.py @@ -0,0 +1,34 @@ +# Generated by Django 2.2.8 on 2019-12-22 10:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bds", "0003_staff_permission"), + ] + + operations = [ + migrations.AddField( + model_name="bdsprofile", + name="cotisation_type", + field=models.CharField( + choices=[ + ("ETU", "Étudiant"), + ("NOR", "Normalien"), + ("EXT", "Extérieur"), + ("ARC", "Archicube"), + ], + default="Normalien", + max_length=9, + verbose_name="type de cotisation", + ), + preserve_default=False, + ), + migrations.AddField( + model_name="bdsprofile", + name="is_member", + field=models.BooleanField(default=False, verbose_name="membre du BDS"), + ), + ] diff --git a/bds/models.py b/bds/models.py index eb5a67aa..60778f4d 100644 --- a/bds/models.py +++ b/bds/models.py @@ -78,13 +78,16 @@ class BDSProfile(models.Model): _("numéro FFSU"), max_length=50, blank=True, null=True ) + is_member = models.BooleanField(_("membre du BDS"), default=False) 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") ) + cotisation_type = models.CharField( + _("type de cotisation"), choices=TYPE_COTIZ_CHOICES, max_length=9 + ) class Meta: verbose_name = _("Profil BDS") From 858759865e29f7661fe00f6e613b50c00aa286f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Thu, 26 Dec 2019 23:19:41 +0100 Subject: [PATCH 3/3] =?UTF-8?q?BDSProfile:=20s/membre/adh=C3=A9rent?= =?UTF-8?q?=E2=8B=85e/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bds/migrations/0004_is_member_cotiz_type.py | 2 +- bds/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bds/migrations/0004_is_member_cotiz_type.py b/bds/migrations/0004_is_member_cotiz_type.py index 53d332d8..2910ee85 100644 --- a/bds/migrations/0004_is_member_cotiz_type.py +++ b/bds/migrations/0004_is_member_cotiz_type.py @@ -29,6 +29,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name="bdsprofile", name="is_member", - field=models.BooleanField(default=False, verbose_name="membre du BDS"), + field=models.BooleanField(default=False, verbose_name="adhérent⋅e du BDS"), ), ] diff --git a/bds/models.py b/bds/models.py index 60778f4d..1d0072a6 100644 --- a/bds/models.py +++ b/bds/models.py @@ -78,7 +78,7 @@ class BDSProfile(models.Model): _("numéro FFSU"), max_length=50, blank=True, null=True ) - is_member = models.BooleanField(_("membre du BDS"), default=False) + is_member = models.BooleanField(_("adhérent⋅e du BDS"), default=False) cotisation_period = models.CharField( _("inscription"), default="NO", choices=COTIZ_DURATION_CHOICES, max_length=3 )