From 5cdb7b1b30db484ffdff2698928d376d7c809883 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 19 Mar 2020 14:31:41 +0100 Subject: Autocomplete widget: fix modify action to autocomplete field --- ishtar_common/widgets.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'ishtar_common/widgets.py') diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 904036deb..28bd9bdd9 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -653,7 +653,11 @@ class JQueryAutoComplete(forms.TextInput): dct = {'source': mark_safe(source), 'field_id': field_id, 'safe_field_id': field_id.replace("-", "_"), + "modify": self.modify, 'dynamic_limit': dynamic_limit} + if self.associated_model: + model_name = self.associated_model._meta.object_name.lower() + dct["model_name"] = model_name if self.detail: model_name = self.associated_model._meta.object_name.lower() url_detail = '/detail-{}/'.format(model_name) @@ -727,16 +731,15 @@ class JQueryAutoComplete(forms.TextInput): new += """ {} """.format(self.tips) - if self.modify and len(values) == 1: - url_modify = 'modify-' + model_name - url_modify = reverse(url_modify, args=[attrs_select['id'], - values[0]]) + if self.modify: new += """ - + - """.format(url_modify, model_name, model_name) + """.format( + attrs_hidden['id'], + name.replace("-", "_")) if self.new: limits = [] for k in self.limit: -- cgit v1.2.3