Commit 5fea2bde authored by LEVY-FALK Hugo's avatar LEVY-FALK Hugo Committed by root

Inchallah ça va mieux marcher (fix la modification des fields pendant le parcours).

parent bd57e39e
......@@ -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]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment