From 881cd88f48367cae5e6365d7331f23df49bc72c1 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <ynerant@crans.org>
Date: Sun, 5 Sep 2021 20:10:21 +0200
Subject: [PATCH] [WEI] Fix permission check for information json

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
---
 apps/wei/views.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/apps/wei/views.py b/apps/wei/views.py
index cb8e3646..b3d2c3a4 100644
--- a/apps/wei/views.py
+++ b/apps/wei/views.py
@@ -704,7 +704,8 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
     def get_form(self, form_class=None):
         form = super().get_form(form_class)
         form.fields["user"].disabled = True
-        if not self.object.first_year:
+        # The auto-json-format may cause issues with the default field remove
+        if not PermissionBackend.check_perm(self.request, 'wei.change_weiregistration_information_json', self.object):
             del form.fields["information_json"]
         return form
 
-- 
GitLab