From 3555eccdccc0ea67459fabf0a12b85e31b017758 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 8 Nov 2018 20:33:26 +0100 Subject: Allow deactivation of "auto-pin" and of "pin menu" in the profile (refs #4307) --- ishtar_common/wizards.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 499f008b4..d0a7df84b 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -906,10 +906,13 @@ class Wizard(IshtarWizard): # post save/m2m specific fix obj.fix() - # make the new object a default - if self.current_obj_slug: - self.request.session[self.current_obj_slug] = unicode(obj.pk) - self.request.session[self.get_object_name(obj)] = unicode(obj.pk) + ishtaruser = self.request.user.ishtaruser \ + if hasattr(self.request.user, 'ishtaruser') else None + if ishtaruser and ishtaruser.current_profile.auto_pin: + # make the new object a default + if self.current_obj_slug: + self.request.session[self.current_obj_slug] = unicode(obj.pk) + self.request.session[self.get_object_name(obj)] = unicode(obj.pk) dct = {'item': obj} self.current_object = obj # force evaluation of lazy urls @@ -1384,8 +1387,11 @@ class Wizard(IshtarWizard): current_step = step or self.steps.current c_form = self.form_list[current_step] - # make the current object the default item for the session - self.request.session[self.get_object_name(obj)] = unicode(obj.pk) + ishtaruser = self.request.user.ishtaruser \ + if hasattr(self.request.user, 'ishtaruser') else None + if ishtaruser and ishtaruser.current_profile.auto_pin: + # make the current object the default item for the session + self.request.session[self.get_object_name(obj)] = unicode(obj.pk) initial = MultiValueDict() # posted data or already in session -- cgit v1.2.3