diff options
-rw-r--r-- | ishtar_common/templates/ishtar/wizard/default_wizard.html | 1 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/wizard/search.html | 9 | ||||
-rw-r--r-- | ishtar_common/wizards.py | 16 |
3 files changed, 23 insertions, 3 deletions
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 %} }); </script> {% 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 %} <h3>{{wizard_label}}</h3> -{% if default_search_vector %} +{% if default_search_vector or open_url %} <script type="text/javascript"> - var default_search_vector = "{{default_search_vector|safe}}".replace(/''/g, '"'); + {% if default_search_vector %} + var default_search_vector = "{{default_search_vector|safe}}".replace(/''/g, '"');{% endif %} $(document).ready(function() { - $("#id_search_vector").val(default_search_vector.replace(/''/g, '"')); + {% if default_search_vector %} + $("#id_search_vector").val(default_search_vector.replace(/''/g, '"'));{% endif %} + {% if open_url %}load_window("{{open_url}}");{% endif %} }); </script> {% 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): |