From 1c52222d9a64161542970590376658818d00361f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 19 Feb 2019 20:27:30 +0100 Subject: Refactor to prevent DB access before app ready --- ishtar_common/forms.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ishtar_common/forms.py') diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 311f6fee4..448c06ceb 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -660,6 +660,10 @@ class ClosingDateFormSelection(IshtarForm): super(ClosingDateFormSelection, self).__init__(*args, **kwargs) +def has_map(): + return models.get_current_profile().mapping + + def get_form_selection( class_name, label, key, model, base_form, get_url, not_selected_error=_(u"You should select an item."), new=False, @@ -688,8 +692,8 @@ def get_form_selection( widget_kwargs['source_full'] = reverse_lazy(get_full_url) if gallery: widget_kwargs['gallery'] = True - if map and models.get_current_profile().mapping: - widget_kwargs['map'] = True + if map: + widget_kwargs['map'] = has_map attrs[key] = forms.IntegerField( label="", required=False, validators=[models.valid_id(model)], -- cgit v1.2.3