diff options
| -rw-r--r-- | ishtar_common/forms_common.py | 6 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/forms/qa_new_item.html | 8 | ||||
| -rw-r--r-- | ishtar_common/views_item.py | 5 | 
3 files changed, 14 insertions, 5 deletions
| 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 %} -<p>{{new_item_label}} {% trans "created." %}</p> +{% if new_item_pk %} +<p>{% if new_item_label %}{{new_item_label}}{% else %}{% trans "Item" %}{% endif %} {% trans "created." %}</p>  {% else %}      {% bs_compact_form form %}  {% endif %}  {% endblock %}  {% block footer %} -{% if new_item_label %} +{% if new_item_pk %}  <button type="button" data-dismiss="modal"          aria-label="Close" class="btn btn-secondary">      {% trans "Close" %} @@ -21,7 +21,7 @@  {% endblock %}  {% block js_ready %} -{% if new_item_label %} +{% if new_item_pk %}  save_and_close_window{% if many %}_many{% endif %}_data(null, "{{parent_name}}", "{{parent_pk}}", "{{new_item_label|safe}}", "{{new_item_pk}}");  {% endif %}  {% endblock %}
\ No newline at end of file diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index ea76380fa..4e29a2bcf 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -160,7 +160,10 @@ def new_qa_item(model, frm, many=False):              dct['form'] = frm(request.POST, limits=limits)              if dct['form'].is_valid():                  new_item = dct['form'].save(request.user) -                dct['new_item_label'] = str(new_item) +                lbl = str(new_item) +                if not lbl and hasattr(new_item, "_generate_cached_label"): +                    lbl = new_item._generate_cached_label() +                dct['new_item_label'] = lbl                  dct['new_item_pk'] = new_item.pk                  dct['parent_pk'] = parent_name                  if dct['parent_pk'] and '_select_' in dct['parent_pk']: | 
