mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 01:03:09 +00:00
Inchallah ça va mieux marcher (fix la modification des fields pendant le parcours).
This commit is contained in:
parent
bd57e39ee9
commit
5fea2bdebd
1 changed files with 5 additions and 2 deletions
|
@ -60,15 +60,18 @@ class FieldPermissionModel(FieldPermissionModelMixin, models.Model):
|
|||
|
||||
class FieldPermissionFormMixin:
|
||||
"""
|
||||
Construit le formulaire et retire les champs interdits
|
||||
Construit le formulaire et retire les champs interdits
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
user = kwargs.pop('user')
|
||||
|
||||
super(FieldPermissionFormMixin, self).__init__(*args, **kwargs)
|
||||
to_be_deleted = []
|
||||
for name in self.fields:
|
||||
if not self.instance.has_field_perm(user, field=name):
|
||||
self.remove_unauthorized_field(name)
|
||||
to_be_deleted.append(name)
|
||||
for name in to_be_deleted:
|
||||
self.remove_unauthorized_field(name)
|
||||
|
||||
def remove_unauthorized_field(self, name):
|
||||
del self.fields[name]
|
||||
|
|
Loading…
Reference in a new issue