From 3a4b72c01b5f61611180b67c08ff0812749434a5 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Sat, 30 Dec 2017 01:44:32 +0100 Subject: [PATCH] =?UTF-8?q?Inchallah=20=C3=A7a=20va=20mieux=20marcher=20(f?= =?UTF-8?q?ix=20la=20modification=20des=20fields=20pendant=20le=20parcours?= =?UTF-8?q?).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- re2o/field_permissions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/re2o/field_permissions.py b/re2o/field_permissions.py index 4a229c9c..172f4f95 100644 --- a/re2o/field_permissions.py +++ b/re2o/field_permissions.py @@ -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]