summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-08-12 12:06:39 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-08-12 12:06:39 +0200
commitf7fc78c06ce15b9562058bd7c9f697431b258c77 (patch)
tree2261de7f931e0d08e266b35e88a3f436a41dedf7
parent4e04a8854572cc6dbde34cb05854112320da8295 (diff)
downloadIshtar-f7fc78c06ce15b9562058bd7c9f697431b258c77.tar.bz2
Ishtar-f7fc78c06ce15b9562058bd7c9f697431b258c77.zip
Temporary fix to prevent a mystorious infinite loop on wizard condition check
-rw-r--r--ishtar_common/wizards.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index e974942b7..48ea03e24 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -91,6 +91,25 @@ def check_rights_condition(rights):
return func
+def _check_right(step, condition=True):
+ '''Return a method to check the right for a specific step'''
+ def check_right(self):
+ cond = condition
+ # TODO: cond.__name__ != 'check_right' prevent unexplicated
+ # infinite loop... to be fixed
+ if callable(cond) and cond.__name__ != 'check_right':
+ cond = cond(self)
+ if not cond:
+ return False
+ return True
+ # TODO: to be check
+ if not hasattr(self.request.user, 'ishtaruser'):
+ return False
+ return self.request.user.ishtaruser.has_right(
+ ('administrator', step), session=self.request.session)
+ return check_right
+
+
class Wizard(NamedUrlWizardView):
model = None
label = ''
@@ -105,31 +124,12 @@ class Wizard(NamedUrlWizardView):
filter_owns = {}
current_obj_slug = ''
- @staticmethod
- def _check_right(step, condition=True):
- '''Return a method to check the right for a specific step'''
- def check_right(self):
- cond = condition
- if callable(condition):
- cond = condition(self)
- if not cond:
- return False
- return True
- # TODO: to be check
- if not hasattr(self.request.user, 'ishtaruser'):
- return False
- return self.request.user.ishtaruser.has_right(
- ('administrator', step), session=self.request.session)
- return check_right
-
def __init__(self, *args, **kwargs):
"""Check right for each step of the wizard"""
super(Wizard, self).__init__(*args, **kwargs)
for form_key in self.form_list.keys()[:-1]:
- condition = True
- if form_key in self.condition_dict:
- condition = self.condition_dict.get(form_key, True)
- cond = self._check_right(form_key, condition)
+ condition = self.condition_dict.get(form_key, True)
+ cond = _check_right(form_key, condition)
self.condition_dict[form_key] = cond
def dispatch(self, request, *args, **kwargs):