From 801e31fc093bc554ae62ff50a5540659634098b4 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 13 Sep 2019 12:28:23 +0200 Subject: Fix organization form - fix quick add with delayed cached_label --- ishtar_common/forms_common.py | 6 ++++++ ishtar_common/templates/ishtar/forms/qa_new_item.html | 8 ++++---- ishtar_common/views_item.py | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 1a9043370..235138eea 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -348,6 +348,12 @@ class OrganizationForm(ManageOldType, NewItemForm): dct['history_modifier'] = user dct['organization_type'] = models.OrganizationType.objects.get( pk=dct['organization_type']) + if dct["precise_town"]: + try: + dct["precise_town"] = models.Town.objects.get( + pk=dct["precise_town"]) + except models.Town.DoesNotExist: + dct.pop("precise_town") new_item = models.Organization(**dct) new_item.save() return new_item diff --git a/ishtar_common/templates/ishtar/forms/qa_new_item.html b/ishtar_common/templates/ishtar/forms/qa_new_item.html index 78162d759..ae57adfc2 100644 --- a/ishtar_common/templates/ishtar/forms/qa_new_item.html +++ b/ishtar_common/templates/ishtar/forms/qa_new_item.html @@ -2,15 +2,15 @@ {% load i18n inline_formset table_form %} {% block main_form %} -{% if new_item_label %} -

{{new_item_label}} {% trans "created." %}

+{% if new_item_pk %} +

{% if new_item_label %}{{new_item_label}}{% else %}{% trans "Item" %}{% endif %} {% trans "created." %}

{% else %} {% bs_compact_form form %} {% endif %} {% endblock %} {% block footer %} -{% if new_item_label %} +{% if new_item_pk %}