summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_files_pdl/templates/ishtar/wizard/wizard_preventiveplanning.html116
-rw-r--r--ishtar_common/widgets.py58
2 files changed, 34 insertions, 140 deletions
diff --git a/archaeological_files_pdl/templates/ishtar/wizard/wizard_preventiveplanning.html b/archaeological_files_pdl/templates/ishtar/wizard/wizard_preventiveplanning.html
deleted file mode 100644
index 95e8e8841..000000000
--- a/archaeological_files_pdl/templates/ishtar/wizard/wizard_preventiveplanning.html
+++ /dev/null
@@ -1,116 +0,0 @@
-{% extends "ishtar/wizard/default_wizard.html" %}
-{% load i18n range table_form %}
-{% block wizard_form %}
-<form action="." method="post" name='wizard'{% if wizard.form.file_upload %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}
-<div class='form'>
-{{ wizard.form.media }}
-{{ wizard.management_form }}
-
-<table>
-
-{% if wizard.form.name.errors %}<tr>
- <td colspan="2">{{wizard.form.name.errors}}</td>
-</tr>{% endif %}
-
-<tr class='required'>
- <th><label for="id_preventiveplanning-{{CURRENT_ACTION}}-name">Nom de l'aménagement</label></th>
-</tr>
-<tr class='required'>
- <td>{{wizard.form.name|safe}}</td>
-</tr>
-
-</table>
-
-<h4>Localisation</h4>
-<table>
-
-{% if wizard.form.main_town.errors %}<tr>
- <td colspan="2">{{wizard.form.main_town.errors}}</td>
-</tr>{% endif %}
-<tr>
- <th colspan='2'><label for="id_preventiveplanning-{{CURRENT_ACTION}}-towns">{% trans "Towns" %}</label></th>
-</tr>
-<tr>
- <td>{{wizard.form.town|safe}}</td>
-</tr>
-
-{% if wizard.form.department.errors %}<tr>
- <td colspan="2">{{wizard.form.department.errors}}</td>
-</tr>{% endif %}
-<tr>
- <th colspan='2'><label for="id_preventiveplanning-{{CURRENT_ACTION}}-department">{% trans "Departments" %}</label></th>
-</tr>
-<tr>
- <td>{{wizard.form.department|safe}}</td>
-</tr>
-
-{% if wizard.form.locality.errors %}<tr>
- <td colspan="2">{{wizard.form.locality.errors}}</td>
-</tr>{% endif %}
-<tr>
- <th colspan='2'><label for="id_preventiveplanning-{{CURRENT_ACTION}}-locality">Lieu-dit</label></th>
-</tr>
-<tr>
- <td colspan='2'>{{wizard.form.locality|safe}}</td>
-</tr>
-
-{% if wizard.form.address.errors %}<tr>
- <td colspan="2">{{wizard.form.address.errors}}</td>
-</tr>{% endif %}
-<tr>
- <th colspan='2'><label for="id_preventiveplanning-{{CURRENT_ACTION}}-address">Adresse</label></th>
-</tr>
-<tr>
- <td colspan='2'>{{wizard.form.address|safe}}</td>
-</tr>
-
-{% if wizard.form.postal_code.errors %}<tr>
- <td colspan="2">{{wizard.form.postal_code.errors}}</td>
-</tr>{% endif %}
-<tr>
- <th colspan='2'><label for="id_preventiveplanning-{{CURRENT_ACTION}}-postal_code">Code postal</label></th>
-</tr>
-<tr>
- <td colspan='2'>{{wizard.form.postal_code|safe}}</td>
-</tr>
-
-</table>
-
-<h4>Surfaces</h4>
-<table>
-
-{% if wizard.form.total_surface.errors %}<tr>
- <td colspan="2">{{wizard.form.total_surface.errors}}</td>
-</tr>{% endif %}
-<tr>
- <th><label for="id_preventiveplanning-{{CURRENT_ACTION}}-total_surface">Surface totale des terrains</label></th>
-</tr>
-<tr>
- <td>{{wizard.form.total_surface|safe}}</td>
-</tr>
-
-{% if wizard.form.total_developed_surface.errors %}<tr>
- <td colspan="2">{{wizard.form.total_developed_surface.errors}}</td>
-</tr>{% endif %}
-<tr>
- <th><label for="id_preventiveplanning-{{CURRENT_ACTION}}-total_developed_surface">Surface totale aménagée</label></th>
-</tr>
-<tr>
- <td>{{wizard.form.total_developed_surface|safe}}</td>
-</tr>
-
-</table>
-
-<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
-{{ previous_fields|safe }}
- {% block "footer" %}
- <div id="footer">
- {% block "validation_bar" %}
- {% include 'ishtar/wizard/validation_bar.html' %}
- {% endblock %}
- {% include 'ishtar/blocks/footer.html' %}
- </div>
- {% endblock %}
-</div>
-</form>
-{% endblock %}
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index d75769ffa..bf0f90a6c 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -599,13 +599,17 @@ class ModelJQueryAutocompleteField(ModelFieldMixin, forms.CharField):
class JQueryAutoComplete(forms.TextInput):
def __init__(self, source, associated_model=None, options=None, attrs=None,
new=False, url_new='', multiple=False, limit=None,
- dynamic_limit=None):
+ dynamic_limit=None, tips=""):
"""
Source can be a list containing the autocomplete values or a
string containing the url used for the request.
"""
self.source = source
self.associated_model = associated_model
+ if callable(tips):
+ self.tips = tips()
+ else:
+ self.tips = tips
self.options = None
if options and len(options) > 0:
@@ -702,29 +706,35 @@ class JQueryAutoComplete(forms.TextInput):
attrs_select['class'] += ' form-control'
new = ''
html = u""
- if self.new:
- # WARNING: the modal for the form must be in the main template
- # "extra_form_modals" list is used for that in form or view
-
- html = u"<div class='input-group'>"
- model_name = self.associated_model._meta.object_name.lower()
- limits = []
- for k in self.limit:
- limits.append(k + "__" + "-".join(
- [str(v) for v in self.limit[k]]))
- args = [attrs_select['id']]
- if limits:
- args.append(';'.join(limits))
- url_new = 'new-' + model_name
- if self.url_new:
- url_new = self.url_new
- url_new = reverse(url_new, args=args)
- 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, model_name, model_name)
+ if self.tips or self.new:
+ html = "<div class='input-group'>"
+ if self.tips:
+ new = """<span class="input-group-append">
+ <span class="add-button input-group-text"><em>{}</em></span></span>
+ """.format(self.tips)
+ if self.new:
+ # WARNING: the modal for the form must be in the main template
+ # "extra_form_modals" list is used for that in form or view
+
+ model_name = self.associated_model._meta.object_name.lower()
+ limits = []
+ for k in self.limit:
+ limits.append(k + "__" + "-".join(
+ [str(v) for v in self.limit[k]]))
+ args = [attrs_select['id']]
+ if limits:
+ args.append(';'.join(limits))
+ url_new = 'new-' + model_name
+ if self.url_new:
+ url_new = self.url_new
+ url_new = reverse(url_new, args=args)
+ new += """
+ <span class="input-group-append">
+ <a href="#" class="add-button input-group-text"
+ onclick="dt_qa_open('{}', 'modal-dynamic-form-{}');">+</a>
+ </span>
+ """.format(url_new, model_name, model_name)
+ new += "</div>"
old_value = ""
if 'value' in attrs_select and attrs_select['value']: