From 9f5c2d43992e898acaf91cc95c5f2755aeb628b9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 13 Sep 2019 19:29:09 +0200 Subject: Redirect to search after Person edit --- .../templates/ishtar/wizard/default_wizard.html | 1 + ishtar_common/templates/ishtar/wizard/search.html | 9 ++++++--- ishtar_common/wizards.py | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index 732a0a64f..b5ea4207c 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -61,6 +61,7 @@ $(document).ready(function(){ } return false; }); + {% if open_url %}load_window("{{open_url}}");{% endif %} }); {% endblock %} diff --git a/ishtar_common/templates/ishtar/wizard/search.html b/ishtar_common/templates/ishtar/wizard/search.html index a7a6faec7..2e7e9bb08 100644 --- a/ishtar_common/templates/ishtar/wizard/search.html +++ b/ishtar_common/templates/ishtar/wizard/search.html @@ -5,11 +5,14 @@ {% endblock %} {% block content %}

{{wizard_label}}

-{% if default_search_vector %} +{% if default_search_vector or open_url %} {% endif %} diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 65a37a860..5eb8e0ad1 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -101,6 +101,15 @@ class IshtarWizard(NamedUrlWizardView): context = super(IshtarWizard, self).get_context_data(form, **kwargs) if hasattr(form, "extra_form_modals"): context["extra_form_modals"] = form.extra_form_modals + + open_item_id = self.request.GET.get('open_item', None) + if open_item_id and self.model and \ + getattr(self.model, "SHOW_URL", None): + url = reverse(self.model.SHOW_URL, args=[open_item_id]) + if not url.endswith("/"): + url += "/" + context["open_url"] = url + return context @@ -944,6 +953,12 @@ class Wizard(IshtarWizard): self.request.session[self.get_object_name(obj)] = str(obj.pk) dct = {'item': obj} self.current_object = obj + + if self.redirect_url: + return HttpResponseRedirect( + reverse(self.redirect_url) + "?open_item={}".format(obj.pk) + ) + # force evaluation of lazy urls wizard_done_window = str(self.wizard_done_window) if wizard_done_window: @@ -1722,6 +1737,7 @@ class PersonWizard(Wizard): wizard_templates = { 'identity-person_creation': "ishtar/wizard/wizard_person.html"} wizard_done_window = reverse_lazy('show-person') + redirect_url = "person_modification" class PersonModifWizard(PersonWizard): -- cgit v1.2.3