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
This commit is contained in:
parent
d2ba9471da
commit
4d5419fdbc
2 changed files with 23 additions and 1 deletions
22
bds/migrations/0003_staff_permission.py
Normal file
22
bds/migrations/0003_staff_permission.py
Normal file
|
@ -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",),
|
||||||
|
]
|
|
@ -63,7 +63,6 @@ class BDSProfile(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
mails_bds = models.BooleanField(_("recevoir les mails du BDS"), default=False)
|
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)
|
has_certificate = models.BooleanField(_("certificat médical"), default=False)
|
||||||
certificate_file = models.FileField(
|
certificate_file = models.FileField(
|
||||||
|
@ -90,6 +89,7 @@ class BDSProfile(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Profil BDS")
|
verbose_name = _("Profil BDS")
|
||||||
verbose_name_plural = _("Profils BDS")
|
verbose_name_plural = _("Profils BDS")
|
||||||
|
permissions = (("is_team", _("est membre du burô")),)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
|
Loading…
Reference in a new issue