From 183c1422d978e2b1cbb1d47e0a024dcee57ae3f9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 27 Oct 2021 11:55:34 +0200 Subject: Syndication - search UI --- ishtar_common/wizards.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ishtar_common/wizards.py') diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index a22901953..2c2d4f6f9 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -100,6 +100,8 @@ EXTRA_FORM_MODALS = ["container", "warehouse", "person", "organization"] class IshtarWizard(NamedUrlWizardView): + model = None + def get_form_kwargs(self, step=None): kwargs = super(IshtarWizard, self).get_form_kwargs(step) if ( @@ -117,6 +119,18 @@ class IshtarWizard(NamedUrlWizardView): if hasattr(form, "extra_form_modals") else EXTRA_FORM_MODALS ) + if ( + self.model + and "pk" in form.fields + and self.request.session.get("EXTERNAL_SOURCES", {}) + ): + model_name = f"{self.model._meta.app_label}-{self.model.__name__.lower()}" + context["external_sources"] = [ + source.split("-") + for source in self.request.session["EXTERNAL_SOURCES"] + if model_name in self.request.session["EXTERNAL_SOURCES"][source] + ] + form.fields["pk"].widget.external_sources = context["external_sources"] open_item_id = self.request.GET.get("open_item", None) if open_item_id and self.model and getattr(self.model, "SHOW_URL", None): -- cgit v1.2.3