summaryrefslogtreecommitdiff
path: root/ishtar_common/widgets.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-06-10 18:47:17 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:21 +0100
commit8b7c617c7ac7f752646bd48f39da97dcfbaaaab2 (patch)
treec0a931af3e3be561d3779811e70eeaf2c995f332 /ishtar_common/widgets.py
parent6d030c2e804b5c8f73a6e6aa9510ea23afaeeaa3 (diff)
downloadIshtar-8b7c617c7ac7f752646bd48f39da97dcfbaaaab2.tar.bz2
Ishtar-8b7c617c7ac7f752646bd48f39da97dcfbaaaab2.zip
Documents: better form - improve select2 widget to manage new
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r--ishtar_common/widgets.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index e5f4c67b1..7d954f378 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -270,10 +270,13 @@ class Select2Base(Select2Media):
if self.new:
html = u"<div class='input-group'>"
url_new = 'new-' + self.model.SLUG
- url_new = reverse(url_new)
- new = u'<span class="input-group-append">' \
- u'<a href="#" class="add-button input-group-text" ' \
- u'onclick="open_window(\'%s\');">+</a></span></div>' % url_new
+ url_new = reverse(url_new, args=["id_" + name])
+ # WARNING: the modal for the form must be in the main template
+ # "extra_form_modals" list is used for that in form or view
+ new = """<span class="input-group-append">"""\
+ """<a href="#" class="add-button input-group-text" """\
+ """onclick="dt_qa_open('{}', 'modal-dynamic-form-{}');">"""\
+ """+</a></span></div>""".format(url_new, self.model.SLUG)
html += super(Select2Base, self).render(name, value, attrs)
html += new
@@ -641,7 +644,8 @@ class JQueryAutoComplete(forms.TextInput):
try:
source = "'" + str(self.source) + "'"
except:
- raise ValueError('source type is not valid')
+ raise ValueError('{} source type is not valid'.format(
+ self.source))
dynamic_limit = []
for lim in self.dynamic_limit:
field_ids = field_id.split('-')