diff options
| author | Cefin <kevon@tuta.io> | 2022-01-19 08:49:56 +0000 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:20:59 +0100 | 
| commit | 2328ef8e3099bf7aaf3b84a7508860fa85023d46 (patch) | |
| tree | 10eb0d034e8a929d7877bd39ef3ddb2611fafac1 | |
| parent | bdf926910d290b7a6628326d709c0dc6d26c732f (diff) | |
| download | Ishtar-2328ef8e3099bf7aaf3b84a7508860fa85023d46.tar.bz2 Ishtar-2328ef8e3099bf7aaf3b84a7508860fa85023d46.zip | |
Operation Parcels extraction wizard - issue with initial and template
| -rw-r--r-- | archaeological_operations/templates/ishtar/forms/operation_modify_parcels.html | 43 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 26 | 
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,      }) | 
