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 | 9b6160b263f737271a0f1aad44b02bca0a70b878 (patch) | |
tree | e359f8b361a947954622d6d6069995ef30bd5104 /ishtar_common | |
parent | 58dccb1cdf436f84827e20c40c96296a3778621d (diff) | |
download | Ishtar-9b6160b263f737271a0f1aad44b02bca0a70b878.tar.bz2 Ishtar-9b6160b263f737271a0f1aad44b02bca0a70b878.zip |
Force filtering on "own" items on selection for modification
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/static/media/style.css | 1 | ||||
-rw-r--r-- | ishtar_common/views.py | 4 | ||||
-rw-r--r-- | ishtar_common/wizards.py | 18 |
3 files changed, 20 insertions, 3 deletions
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 46ee8c331..fdde40cb0 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -898,6 +898,7 @@ div.form p.alert{ #window p.alert{ background-color:#EEE; + padding-left: 30px; } #window p.alert label{ diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 79e816bcb..a18673b44 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -321,7 +321,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[], """ Generic treatment of tables """ - def func(request, data_type='json', full=False, **dct): + def func(request, data_type='json', full=False, force_own=False, **dct): # check rights own = True # more restrictive by default allowed = False @@ -337,6 +337,8 @@ def get_item(model, func_name, default_name, extra_request_keys=[], if "_own_" not in perm: own = False break # max right reach + if force_own: + own = True EMPTY = '' if 'type' in dct: data_type = dct.pop('type') 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): |