From e20dae3750b363cffcf009560de066d5723fc1a9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 25 Feb 2021 12:06:36 +0100 Subject: Generic extra forms modals for all pages (refs #5052) --- ishtar_common/views.py | 5 ++++- ishtar_common/wizards.py | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 45a7530c7..cb1af7c5d 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -119,7 +119,10 @@ def index(request): """ Main page """ - dct = {'warnings': []} + dct = { + 'warnings': [], + "extra_form_modals": wizards.EXTRA_FORM_MODALS + } if settings.PROJECT_SLUG == 'default': dct['warnings'].append(_( "PROJECT_SLUG is set to \"default\". Change it in your " diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index b23069d36..e72ed2cb1 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -89,6 +89,9 @@ def filter_no_fields_form(form, other_check=None): return func +EXTRA_FORM_MODALS = ["container", "warehouse", "person", "organization"] + + class IshtarWizard(NamedUrlWizardView): def get_form_kwargs(self, step=None): kwargs = super(IshtarWizard, self).get_form_kwargs(step) @@ -99,8 +102,9 @@ class IshtarWizard(NamedUrlWizardView): def get_context_data(self, form, **kwargs): context = super(IshtarWizard, self).get_context_data(form, **kwargs) - if hasattr(form, "extra_form_modals"): - context["extra_form_modals"] = form.extra_form_modals + + context["extra_form_modals"] = form.extra_form_modals \ + if hasattr(form, "extra_form_modals") else EXTRA_FORM_MODALS open_item_id = self.request.GET.get('open_item', None) if open_item_id and self.model and \ -- cgit v1.2.3