summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/templates/ishtar/forms/operation_modify_parcels.html43
-rw-r--r--archaeological_operations/views.py26
2 files changed, 45 insertions, 24 deletions
diff --git a/archaeological_operations/templates/ishtar/forms/operation_modify_parcels.html b/archaeological_operations/templates/ishtar/forms/operation_modify_parcels.html
index 64619a6f4..9aebe20fa 100644
--- a/archaeological_operations/templates/ishtar/forms/operation_modify_parcels.html
+++ b/archaeological_operations/templates/ishtar/forms/operation_modify_parcels.html
@@ -14,27 +14,38 @@
<div class='form'>
{% block main_form %}
{{ formset.management_form }}
- {{ formset_general.management_form }}
{% if formset.non_form_errors %}
- {{ formset.non_form_errors }}
+ <div class="alert alert-danger" role="alert">
+ {{ formset.non_form_errors }}
+ </div>
{% endif %}
<table>
- {% for form in formset %}
- <th></th>
- <tr>
- <td>{{ form }}</td>
- </tr>
- {% endfor %}
- </table>
+ <tr>
+ {% for form in formset %}
+ {{form}}
+ {% if form.name != 'pk' %}
+ {% if form.required %}
+ <th
+ {% else %}
+ <td
+ {% endif %}
+ {% if not forloop.last %}
+ rowspan='2'
+ {% endif %}>
+ {{ form.label}}
+ {% endif %}
+ </td>
+ {% endfor %}
+ </tr>
- <table>
- {% for form_g in formset_general %}
- <th></th>
- <tr>
- <td>{{ form_g }}</td>
- </tr>
- {% endfor %}
+ <tr>
+ <td>
+ ({% trans "all"%}
+ <input type='checkbox' name='check-all' class='check-all'/>)
+ </td>
+ </tr>
</table>
+
{% endblock %}
</div>
</div>
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index c3442b5b5..f8976bd5d 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -415,24 +415,34 @@ def operation_delete(request, pk):
def operation_modify_parcels(request, pk):
formset = None
+ operation = models.Operation.objects.get(pk=pk)
parcels = models.Parcel.objects.filter(operation=pk).all()
+ data = {}
if request.method == 'POST': #TODO
formset = SelectedParcelFormSet(request.POST, request.FILES)
if formset.is_valid():
pass
else:
- formset = SelectedParcelFormSet
+ formset = SelectedParcelFormSet()
else:
- data = [{
- 'parcels': parcel,
- 'selected_town': parcel.town
- } for parcel in parcels]
- formset = SelectedParcelFormSet(initial=data)
- formset_general = SelectedParcelGeneralFormSet(initial=data)
+ i = 0
+ towns_array = []
+ parcels_array = []
+ info = {}
+ for parcel in parcels:
+ towns_array.append(parcel.town)
+ parcels_array.append(parcel.pk)
+ # data['parcel'] = parcel.pk
+ i += 1
+ data['TOWNS'] = towns_array
+ # data['PARCELS'] = parcels_array
+ data['form-TOTAL_FORMS'] = '1'
+ data['form-INITIAL_FORMS'] = '0'
+ formset = SelectedParcelFormSet(intial=data)
+ #formset = SelectedParcelGeneralFormSet()
return render(request, 'ishtar/forms/operation_modify_parcels.html', {
'formset': formset,
- 'formset_general': formset_general,
})