From 5fea2bdebd62dd5c4d3e32b495735cf2ab63f6e3 Mon Sep 17 00:00:00 2001 From: LEVY-FALK Hugo 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]