summaryrefslogtreecommitdiff
path: root/ishtar_common/widgets.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-03-19 14:31:41 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2020-03-19 14:31:41 +0100
commit9543b8ff37df9434efcf71d7e500d84b56ac2bb0 (patch)
treeb2f693dcf3478a86adefdd98d80ac53501b44e44 /ishtar_common/widgets.py
parent5d4d3dfbcc3b149e50289c029549f099655c5bf7 (diff)
downloadIshtar-9543b8ff37df9434efcf71d7e500d84b56ac2bb0.tar.bz2
Ishtar-9543b8ff37df9434efcf71d7e500d84b56ac2bb0.zip
Autocomplete widget: fix modify action to autocomplete field
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r--ishtar_common/widgets.py17
1 files changed, 10 insertions, 7 deletions
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 += """<span class="input-group-append">
<span class="add-button input-group-text"><em>{}</em></span></span>
""".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 += """
<span class="input-group-append">
- <a href="#" class="modify-button input-group-text"
- onclick="dt_qa_open('{}', 'modal-dynamic-form-{}');">
+ <a href="#" id="{}-modify" class="modify-button input-group-text"
+ onclick="{}_modify();">
<i class="fa fa-pencil"></i></a>
- </span>""".format(url_modify, model_name, model_name)
+ </span>""".format(
+ attrs_hidden['id'],
+ name.replace("-", "_"))
if self.new:
limits = []
for k in self.limit: