diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-12-14 21:44:48 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-12-14 21:44:48 +0100 | 
| commit | 08811d24b0a1869322db82b65c4fbd8a35bc7327 (patch) | |
| tree | e359f8b361a947954622d6d6069995ef30bd5104 /ishtar_common/wizards.py | |
| parent | 5b5497b31e5796b1fecfc0641e337ffb8d7792a1 (diff) | |
| download | Ishtar-08811d24b0a1869322db82b65c4fbd8a35bc7327.tar.bz2 Ishtar-08811d24b0a1869322db82b65c4fbd8a35bc7327.zip | |
Force filtering on "own" items on selection for modification
Diffstat (limited to 'ishtar_common/wizards.py')
| -rw-r--r-- | ishtar_common/wizards.py | 18 | 
1 files changed, 16 insertions, 2 deletions
| diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 23469c659..29496d21b 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -85,10 +85,8 @@ def check_rights_condition(rights):          if request.user.ishtaruser.has_right('administrator', request.session):              return True          for right in rights: -            print(right)              if request.user.ishtaruser.has_right(right, request.session):                  return True -        print('hop')          return False      return func @@ -104,6 +102,7 @@ class Wizard(NamedUrlWizardView):      wizard_done_window = ''      wizard_confirm = 'ishtar/wizard/confirm_wizard.html'      wizard_templates = {} +    filter_owns = {}      @staticmethod      def _check_right(step, condition=True): @@ -153,6 +152,10 @@ class Wizard(NamedUrlWizardView):                      current_object and not current_object.is_own(request.user):                  self.session_reset(request, self.url_name)                  return HttpResponseRedirect('/') +            # extra filter on forms +            self.filter_owns_items = True +        else: +            self.filter_owns_items = False          return super(Wizard, self).dispatch(request, *args, **kwargs) @@ -671,10 +674,21 @@ class Wizard(NamedUrlWizardView):                  and form.forms[0].fields.keys():              frm = form.forms[0]          if frm: +            # autofocus on first field              first_field = frm.fields[frm.fields.keyOrder[0]]              attrs = first_field.widget.attrs              attrs.update({'autofocus': "autofocus"})              first_field.widget.attrs = attrs +            if not step: +                step = self.steps.current +            if self.filter_owns_items and self.filter_owns \ +                    and step in self.filter_owns: +                for key in self.filter_owns[step]: +                    frm.fields[key].widget.source = unicode( +                        frm.fields[key].widget.source) + "own/" +                    if frm.fields[key].widget.source_full is not None: +                        frm.fields[key].widget.source_full = unicode( +                            frm.fields[key].widget.source_full) + "own/"          return form      def render_next_step(self, form, **kwargs): | 
