summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms.py6
-rw-r--r--ishtar_common/forms_common.py4
-rw-r--r--ishtar_common/models.py1
-rw-r--r--ishtar_common/static/media/style.css16
-rw-r--r--ishtar_common/templates/blocks/form_snippet.html (renamed from ishtar_common/templates/form_snippet.html)0
-rw-r--r--ishtar_common/templates/blocks/inline_formset.html25
-rw-r--r--ishtar_common/templates/ishtar/sheet.html (renamed from ishtar_common/templates/sheet.html)0
-rw-r--r--ishtar_common/templates/ishtar/wizard/default_wizard.html4
-rw-r--r--ishtar_common/templates/ishtar/wizard/parcels_wizard.html28
-rw-r--r--ishtar_common/templates/ishtar/wizard/towns_wizard.html10
-rw-r--r--ishtar_common/templates/sheet_contextrecord.html135
-rw-r--r--ishtar_common/templates/sheet_contextrecord_window.html3
-rw-r--r--ishtar_common/templates/sheet_file.html132
-rw-r--r--ishtar_common/templates/sheet_file_pdf.html18
-rw-r--r--ishtar_common/templates/sheet_file_window.html3
-rw-r--r--ishtar_common/templates/sheet_operation.html183
-rw-r--r--ishtar_common/templates/sheet_operation_pdf.html18
-rw-r--r--ishtar_common/templates/sheet_operation_window.html3
-rw-r--r--ishtar_common/templatetags/inline_formset.py18
-rw-r--r--ishtar_common/templatetags/table_form.py2
-rw-r--r--ishtar_common/views.py25
-rw-r--r--ishtar_common/widgets.py8
-rw-r--r--ishtar_common/wizards.py21
23 files changed, 139 insertions, 524 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index d66d6d4cc..cb007442e 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2011 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -101,6 +101,10 @@ class FormSet(BaseFormSet):
form.fields[DELETION_FIELD_NAME].label = ''
form.fields[DELETION_FIELD_NAME].widget = widgets.DeleteWidget()
+class TableSelect(forms.Form):
+ def get_input_ids(self):
+ return self.fields.keys()
+
def get_now():
format = formats.get_format('DATE_INPUT_FORMATS')[0]
value = datetime.datetime.now().strftime(format)
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 34a930e36..52fcfc97a 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -37,7 +37,7 @@ from django.utils.translation import ugettext_lazy as _
import models
import widgets
-from forms import FinalForm, FormSet, reverse_lazy, name_validator
+from forms import FinalForm, FormSet, reverse_lazy, name_validator, TableSelect
def get_town_field(label=_(u"Town"), required=True):
help_text = _(u"<p>Type name, department code and/or postal code of the "
@@ -234,7 +234,7 @@ class SourceForm(forms.Form):
super(SourceForm, self).__init__(*args, **kwargs)
self.fields['source_type'].choices = models.SourceType.get_types()
-class SourceSelect(forms.Form):
+class SourceSelect(TableSelect):
authors = forms.IntegerField(
widget=widgets.JQueryAutoComplete("/" + settings.URL_PATH + \
'autocomplete-author', associated_model=models.Author),
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index e5d966bf9..fd5bb5871 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -451,6 +451,7 @@ class Dashboard:
operation_mode_pk = self.get_mode(dict(zip(operations,
operation_numbers)))
if operation_mode_pk:
+ from archaeological_operations.models import Operation
self.operation_mode = unicode(Operation.objects.get(
pk=operation_mode_pk))
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css
index 2aa673b51..fe078fa3c 100644
--- a/ishtar_common/static/media/style.css
+++ b/ishtar_common/static/media/style.css
@@ -528,3 +528,19 @@ a.remove{
border:1px solid;
}
+.form table.inline-table th{
+ text-align:center;
+ font-weight:bold;
+}
+
+.form table.inline-table td{
+ text-align:center;
+}
+
+.inline-table input[type=text]{
+ width:60px;
+}
+
+.widget-parcel{
+ width:60px;
+}
diff --git a/ishtar_common/templates/form_snippet.html b/ishtar_common/templates/blocks/form_snippet.html
index 2f841e078..2f841e078 100644
--- a/ishtar_common/templates/form_snippet.html
+++ b/ishtar_common/templates/blocks/form_snippet.html
diff --git a/ishtar_common/templates/blocks/inline_formset.html b/ishtar_common/templates/blocks/inline_formset.html
new file mode 100644
index 000000000..e36405118
--- /dev/null
+++ b/ishtar_common/templates/blocks/inline_formset.html
@@ -0,0 +1,25 @@
+{% load i18n %}
+ {% if extra_formset.non_form_errors %}<div class='errors'>{{extra_formset.non_form_errors.as_ul}}</div>{% endif %}
+ {% if header %}<table class='inline-table'>
+ <caption>{% trans caption %}</caption>
+ {% endif %}{% for frm in formset%}{% if header %}<thead>
+ <tr>{% for field in frm.visible_fields%}
+ <th>{{field.label}}</th>{%endfor%}
+ </tr>
+ </thead>{% endif %}
+ {% if forloop.first and not skip %}<tbody>{%endif%}
+ {% if not skip or not forloop.first %}<tr>{% endif %}{% for field in frm.visible_fields %}
+ <td>
+ {% if field.errors %}<div class='errors'>{{ field.errors.as_ul }}</div>{% endif %}
+ {{ field }}
+ {# Include the hidden fields in the form #}
+ {% if forloop.first %}
+ {{ formset.management_form }}
+ {% for hidden in frm.hidden_fields %}
+ {{ hidden }}
+ {% endfor %}
+ {% endif %}
+ </td>{% endfor %}
+ {% if not skip or not forloop.last %}</tr>{% endif %}{%endfor%}
+ {% if not skip %}</tbody>{% endif %}{% if header %}
+ </table>{% endif %}
diff --git a/ishtar_common/templates/sheet.html b/ishtar_common/templates/ishtar/sheet.html
index 5608a684f..5608a684f 100644
--- a/ishtar_common/templates/sheet.html
+++ b/ishtar_common/templates/ishtar/sheet.html
diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html
index e2abc80b6..b56324a78 100644
--- a/ishtar_common/templates/ishtar/wizard/default_wizard.html
+++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html
@@ -6,6 +6,7 @@
{{form.media}}
{% endblock %}
{% block content %}
+{% block wizard_head %}
<h2>{{wizard_label}}</h2>
<form action="." method="post" name='wizard'>{% csrf_token %}
<ul id='form_path'>
@@ -17,6 +18,8 @@
<li>&raquo;&nbsp;<button name="form_prev_step" value="{{forloop.counter|add:previous_step_counter}}">{{step.form_label}}</button></li>
{% endfor %}
</ul>
+{% endblock %}
+{% block wizard_form %}
<div class='form'>
{% if reminder %}<div class='reminder'>{{ reminder }}</div>{%endif%}
{{ wizard.form.media }}
@@ -43,3 +46,4 @@
</div>
</form>
{% endblock %}
+{% endblock %}
diff --git a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html
new file mode 100644
index 000000000..94e9820ab
--- /dev/null
+++ b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html
@@ -0,0 +1,28 @@
+{% extends "ishtar/wizard/default_wizard.html" %}
+{% load i18n range inline_formset %}
+{% block extra_head %}
+{{wizard.form.media}}
+{% endblock %}
+{% block wizard_form %}
+<div class='form'>
+{% if reminder %}<div class='reminder'>{{ reminder }}</div>{%endif%}
+{{ wizard.form.media }}
+{{ wizard.management_form }}
+ {{ wizard.form.management_form }}
+<div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div>
+ {%if wizard.form.non_form_errors%}
+<table class='formset'>
+<tr class='error'><th colspan='2'>{{wizard.form.non_form_errors}}</th></tr>
+</table>{%endif%}
+<table class='inline-table'>
+ <tr>{% for field in wizard.form.forms.0 %}<th>{{ field.label_tag }}</th>{% endfor %}</tr>
+ {% inline_formset 'Parcels' wizard.form.forms False %}
+</table>
+<p><button name="formset_modify" value="{{wizard.steps.current}}">{% trans "Add/Modify" %}</button></p>
+<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
+{{ previous_fields|safe }}
+<input type="submit" id="submit_form" name='validate' value="{% trans "Validate" %}"/>
+{% if next_steps %}<input type="submit" id="submit_end_form" name='validate_and_end' value="{% trans "Validate and end" %}"/>{% endif %}
+</div>
+</form>
+{% endblock %}
diff --git a/ishtar_common/templates/ishtar/wizard/towns_wizard.html b/ishtar_common/templates/ishtar/wizard/towns_wizard.html
index cd40e6049..cc3487df3 100644
--- a/ishtar_common/templates/ishtar/wizard/towns_wizard.html
+++ b/ishtar_common/templates/ishtar/wizard/towns_wizard.html
@@ -4,15 +4,7 @@
{% block extra_head %}
{{wizard.form.media}}
{% endblock %}
-{% block content %}
-<h2>{{wizard_label}}</h2>
-<form action="." method="post" name='wizard'>{% csrf_token %}
-<ul id='form_path'>
-{% for step in previous_steps %}
- <li>&raquo;&nbsp;<button name="form_prev_step" value="{{forloop.counter0}}">{{step.form_label}}</button></li>
-{% endfor %}
- <li class='current'>&raquo;&nbsp;<a href='#'>{{current_step.form_label}}</a></li>
-</ul>
+{% block wizard_form %}
<div class='form'>
{% if TOWNS %}
{% if wizard.form.forms %}
diff --git a/ishtar_common/templates/sheet_contextrecord.html b/ishtar_common/templates/sheet_contextrecord.html
deleted file mode 100644
index 806b06288..000000000
--- a/ishtar_common/templates/sheet_contextrecord.html
+++ /dev/null
@@ -1,135 +0,0 @@
-{% extends "sheet.html" %}
-{% load i18n %}
-{% block content %}
-<div class='tool'>{%trans "Export as:"%} <a href='{% url show-file item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-file item.pk "pdf" %}'>{%trans "PDF file"%}</a></div>
-
-<h3>{% trans "Context Record"%}</h3>
-
-{% if item.operation.code_patriarche %}
-<p><label>{%trans "Complete ID:"%}</label>
-{% else %}
-<p class='alert'><label>{%trans "Patriarche OA code not yet recorded!"%}</label></p>
-<p><label>{%trans "Temporary ID:"%}</label>
-{%endif%}
-<span class='value'>{{item.full_label}}</span></p>
-{%if item.unit %}
-<p><label>{% trans "Type:" %}</label> <span class='value'>{{ item.unit }}</span></p>
-{%endif%}
-<p><label>{% trans "Chronology:" %}</label> <span class='value'>{{ item.datings.all|join:", " }}</span></p>
-<p><label>{% trans "Place:" %}</label> <span class='value'>{{ item.parcel.town }}</span></p>
-<p><label>{% trans "Parcel:" %}</label> <span class='value'>{{ item.parcel.short_label }}</span></p>
-
-{% if item.description or item.lenght or item.width or item.depth %}
-<h3>{% trans "Description"%}</h3>
-
-<p><label>{% trans "Description:" %}</label> <span class='value'>{{ item.description }}</span></p>
-{% if item.lenght %}<p><label>{% trans "Length (cm):" %}</label> <span class='value'>{{ item.length }}</span></p>{%endif%}
-{% if item.width %}<p><label>{% trans "Width (cm):" %}</label> <span class='value'>{{ item.width }}</span></p>{%endif%}
-{% if item.depth %}<p><label>{% trans "Depth (cm):" %}</label> <span class='value'>{{ item.depth }}</span></p>{%endif%}
-{% endif %}
-
-{% if item.activity or item.identification or item.interpretation %}
-<h3>{% trans "Interpretation"%}</h3>
-
-{% if item.activity %}<p><label>{% trans "Activity:" %}</label> <span class='value'>{{ item.activity }}</span></p>{%endif%}
-{% if item.identification %}<p><label>{% trans "Identification:" %}</label> <span class='value'>{{ item.identification }}</span></p>{%endif%}
-{% if item.interpretation %}<p><label>{% trans "Interpretation:" %}</label> <span class='value'>{{ item.interpretation }}</span></p>{%endif%}
-{% endif %}
-
-{% if item.taq or item.taq_estimated or item.tpq or item.tpq_estimated %}
-<h3>{% trans "Datations"%}</h3>
-{% if item.taq %}<p><label>{% trans "TAQ:" %}</label> <span class='value'>{{ item.taq }}</span></p>{%endif%}
-{% if item.taq_estimated %}<p><label>{% trans "TAQ estimated:" %}</label> <span class='value'>{{ item.taq_estimated }}</span></p>{%endif%}
-{% if item.tpq %}<p><label>{% trans "TPQ:" %}</label> <span class='value'>{{ item.tpq }}</span></p>{%endif%}
-{% if item.tpq_estimated %}<p><label>{% trans "TPQ estimated:" %}</label> <span class='value'>{{ item.tpq_estimated }}</span></p>{%endif%}
-{%endif%}
-
-{% if item.operation %}
-<h3>{% trans "Operation resume"%}</h3>
-<p><label>{%trans "Year:"%}</label> <span class='value'>{{ item.operation.year }}</span></p>
-<p><label>{%trans "Numerical reference:"%}</label> <span class='value'>{{ item.operation.operation_code }}</span></p>
-{% if item.operation.code_patriarche %}
-<p><label>{%trans "Patriarche OA code:"%}</label>
-<span class='value'>{{ item.operation.code_patriarche }}</span></p>
-{% else %}<p class='alert'><label>{%trans "Patriarche OA code not yet recorded!"%}</label></p>
-{%endif%}
-{#<p><label>{%trans "Operation's name:"%}</label><span class='value'>{{ item.operation.internal_reference }}</span></p>#}
-<p><label>{%trans "Head scientist:"%}</label>
-<span class='value'>{{ item.operation.in_charge.full_label }}</span></p>
-<p><label>{%trans "State:"%}</label>
-{% if item.operation.is_active %}
-<span class='value'>{%trans "Active file"%}</span></p>
-{% else %}
-<span class='value'>{%trans "Closed operation"%}</span></p>
-<p><label>{%trans "Closing date:"%}</label> <span class='value'>{{ item.operation.closing.date }}
-<strong>{%trans "by" %}</strong> {{ item.operation.closing.user }}</span></p>
-{% endif %}
-<p><label>{%trans "Type:"%}</label> <span class='value'>{{ item.operation.operation_type }}</span></p>
-<p><label>{%trans "Remains:"%}</label> <span class='value'>{{ item.operation.remains.all|join:", " }}</span></p>
-<p><label>{%trans "Periods:"%}</label> <span class='value'>{{ item.operation.periods.all|join:", " }}</span></p>
-{% if item.operation.comment %}<p><label>{%trans "Comment:"%}</label> <span class='value'>{{ item.operation.comment }}</span></p>{%endif%}
-<h3>{% trans "Localisation"%}</h3>
-<p><label>{%trans "Towns:"%}</label> <span class='value'>{{ item.operation.towns.all|join:", " }}</span></p>
-<p><label>{%trans "Related operation:"%}</label>
-<span class='value'><a href="#" onclick='load_window("{% url show-operation item.operation.pk ''%}");'>{{ item.operation }}</a></span></p>
-{# TODO: Displayed as Year/index/Commune/Common_name This should be a link to the file sheet of the related operation #}
-{% else %}<p class='alert'><label>{%trans "No operation linked to this context unit!"%}</label></p>
-{% endif %}
-
-<table>
- <caption>{%trans "Documents"%}</caption>
- <tr>
- <th>{% trans "Title" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Authors" %}</th>
- {#<th>{% trans "Localisation" %}</th>#}
- </tr>
- {% for doc in item.source.all %}
- <tr>
- <td class='string'>{{ doc.title }}</td>
- <td class='string'>{{doc.source_type}}</td>
- <td class='string'>{{ doc.authors.all|join:", " }}</td>
- {#<td>{{ doc.localisation }}</td>#}
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No document associated to this context record" %}</td></tr>
- {% endfor %}
-</table>
-
-<table>
- <caption>{%trans "Finds"%}</caption>
- <tr>
- <th>{% trans "Find" %}</th>
- <th>{% trans "Material type" %}</th>
- <th>{% trans "Context record" %}</th>
- <th>{% trans "Periods" %}</th>
- <th>{% trans "Description" %}</th>
- <th>{% trans "Weight" %}</th>
- <th>{% trans "Numbers" %}</th>
- <th>{% trans "Parcel" %}</th>
- <th class='link'>&nbsp;</th>
- </tr>
- {% for find in item.base_finds.all %}
- <tr>
- <td>{{ find.full_label }}</td>
-{# Displayed as (Patriarche operation code)-(Record unit label)-(Finds label). #}
-{# or displayed as (Year)-(index)-(Record unit label)-(Finds label). #}
- <td>{{ find.material_type_label }}</td>
-{# Displayed as (Patriarche operation code)-(Record unit label)-(material code)-(Finds label indexed by material type). #}
-{# or displayed as (Year)-(index)-(Record unit label)-(material code)-(Finds label indexed by material type) #}
-
- <td class='string'>{{find.context_record}}</td>
- <td>{{ find.get_last_find.dating}}</td>{# TODO .all|join:", " ? #}
- <td>{{ find.get_last_find.description }}</td>
- <td>{{ find.get_last_find.weight }}</td>
- <td>{{ find.get_last_find.item_number }}</td>
- <td>{{ item.context_record.parcel.short_label }}</td>
- <td class='link'><a href="#">{% trans "Details" %}</a></td>
- {#<a href="#" onclick='load_window("{% url show-find find.pk%}");'>{%trans "Details"%}</a></td>#}
- </tr>
- {% empty %}
- <tr><td colspan="9" class='no_items'>{% trans "No find associated to this context record" %}</td></tr>
- {% endfor %}
-</table>
-
-{% endblock %}
diff --git a/ishtar_common/templates/sheet_contextrecord_window.html b/ishtar_common/templates/sheet_contextrecord_window.html
deleted file mode 100644
index 7ff65d1e7..000000000
--- a/ishtar_common/templates/sheet_contextrecord_window.html
+++ /dev/null
@@ -1,3 +0,0 @@
-{% extends "sheet_contextrecord.html" %}
-{% block main_head %}{%endblock%}
-{% block main_foot %}{%endblock%}
diff --git a/ishtar_common/templates/sheet_file.html b/ishtar_common/templates/sheet_file.html
deleted file mode 100644
index 88ef1b3a2..000000000
--- a/ishtar_common/templates/sheet_file.html
+++ /dev/null
@@ -1,132 +0,0 @@
-{% extends "sheet.html" %}
-{% load i18n %}
-{% block content %}
-{% if previous or next %}
-<div class='tool'>
-{%if previous%}
-<a href="#" onclick='load_window("{% url show-historized-file item.pk previous|date:"c"%}");$("#{{window_id}}").hide();return false;'>{%trans "Previous version"%} ({{previous}})</a>
-{% endif %}
-{% if previous and next %} - {% endif %}
-{%if next%}
-<a href="#" onclick='if(confirm("{%trans "Are you sure to rollback to this version?"%}")){load_url("{% url revert-file item.pk item.history_date|date:"c"%}");closeAllWindows();load_window("{% url show-file item.pk None %}");}'>Rollback</a> -
-<a href="#" onclick='load_window("{% url show-historized-file item.pk next|date:"c" %}");$("#{{window_id}}").hide();return false;'>{%trans "Next version"%} ({{next}})</a>
-{% endif %}
-</div>
-{% endif %}
-<div class='tool'>{%trans "Export as:"%} <a href='{% url show-file item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-file item.pk "pdf" %}'>{%trans "PDF file"%}</a></div>
-<h3>{% trans "General"%}</h3>
-<p><label>{%trans "Year:"%}</label> <span class='value'>{{ item.year }}</span></p>
-<p><label>{%trans "Numerical reference:"%}</label> <span class='value'>{{ item.numeric_reference }}</span></p>
-
-<p><label>{%trans "File's name:"%}</label> <span class='value'>{{ item.internal_reference }}</span></p>
-
-<p><label>{%trans "Edition date:"%}</label> <span class='value'>{{ item.history_date }}</span></p> <!-- date = now -->
-{% if item.reception_date %}<p><label>{%trans "Reception date:"%}</label> <span class='value'>{{ item.reception_date }}</span></p>{% endif %}
-<p><label>{%trans "Creation date:"%}</label> <span class='value'>{{ item.creation_date }}</span></p>
-{% comment %}
-{% if item.deadline_date and not item.acts %}
- <p><label>{%trans "Deadline:"%}</label> <span class='value'>{% item.deadline_date %}</span></p> <!-- calculated deadline for some preventive files , see saisine_type, not displayed if an act as been send -->
-{% endif %}
-{% endcomment %}
-
-<p><label>{%trans "In charge:"%}</label> <span class='value'>{{ item.in_charge.full_label }}</span></p>
-<p><label>{%trans "State:"%}</label> <span class='value'>{% if item.is_active %}{%trans "Active file"%}</span></p>
-{% else %}{%trans "Closed file"%}</span></p>
-<p><label>{%trans "Closing date:"%}</label> <span class='value'>{{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user }}</span></p>
-{% endif %}
-
-<p><label>{%trans "Type:"%}</label> <span class='value'>{{ item.file_type }}</span></p>
-
-{% if item.related_file %}<p><label>{%trans "Related file:"%}</label> <span class='value'><a href='#' onclick='load_window("{% url show-file item.related_file.pk ''%}")'>{{ item.related_file }}</a></span></p>{% endif %} <!-- Displayed as Year/index/Commune/Common_name This should be a link to the file sheet of the related file -->
-{% if item.comment %}<p><label>{%trans "Comment:"%}</label> <span class='value'>{{ item.comment }}</span></p>{%endif%}
-
-<h3>{% trans "Localisation"%}</h3>
-<p><label>{%trans "Towns:"%}</label> <span class='value'>{{ item.towns.all|join:", " }}</span></p>
-
-<p><label>{%trans "Main address:"%}</label> <span class='value'>{{ item.address }}</span></p>
-{% if item.address_complement %}<p><label>{%trans "Complement:"%}</label> <span class='value'>{{ item.address_complement }}</span></p>{%endif%}
-{% if item.postal_code %}<p><label>{%trans "Postal code:"%}</label> <span class='value'>{{ item.postal_code }}</span></p>{%endif%}
-
-<p><label>{%trans "Surface:"%}</label>{% if item.total_surface %} <span class='value'>{{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha)</span>{%endif%}</p>
-
-
-
-{% if item.is_preventive %}
-<h3>{% trans "Preventive archaelogical file"%}</h3>
-<p><label>{%trans "Planed surface:"%}</label> <span class='value'>{{ item.total_developed_surface }} m<sup>2</sup> ({{ item.total_developed_surface_ha }} ha)</span></p>
-<p><label>{%trans "Saisine type:"%}</label> <span class='value'>{{ item.saisine_type }}</span></p>
-{% if item.town_planning_service %}<p><label>{%trans "Town planning service:"%}</label> <span class='value'>{{ item.town_planning_service }}</span></p>{% endif %}
-{% if item.permit_type %}<p><label>{%trans "Permit type:"%}</label> <span class='value'>{{ item.permit_type }}</span></p>{% endif %}
-{% if item.permit_reference %}<p><label>{%trans "Permit reference:"%}</label> <span class='value'>{{ item.permit_reference }}</span></p>{% endif %}
-{% if item.general_contractor.attached_to %}<p><label>{%trans "General contractor organisation:"%}</label> <span class='value'>{{ item.general_contractor.attached_to }}</span></p>{% endif %} <!-- Contractor's organisation displayed as concat of Name/Adress/postal_code/city -->
-{% if item.general_contractor %}<p><label>{%trans "General contractor:"%}</label> <span class='value'>{{ item.general_contractor.full_label }}</span></p>{% endif %}
-{% endif %}
-
-<table>
- <caption>{%trans "Admninistrative acts"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Reference" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Date" %}</th>
- </tr>
- {% for act in item.administrative_act.all %}
- <tr>
- <td>{{act.signature_date.year}}</td>
- <td>{{act.ref_sra}}</td>
- <td class='string'>{{act.act_type}}</td>
- <td>{{act.signature_date}}</td>
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No administrative act associated to this archaelogical file" %}</td></tr>
- {% endfor %}
-</table>
-
-<table>
- <caption>{%trans "Associated operations"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Reference" %}</th>
- <th>Code Patriarche</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "In charge" %}</th>
- <th>{% trans "Start date" %}</th>
- <th>{% trans "Excavation end date" %}</th>
- <th class='link'>&nbsp;</th>
- </tr>
- {% for operation in item.operations.all %}
- <tr>
- <td>{{operation.year}}</td>
- <td>{{operation.operation_code}}</td>
- <td>{{operation.code_patriarche|default:""}}</td>
- <td class='string'>{{operation.operation_type}}</td>
- <td class='string'>{{operation.in_charge|default:""}}</td>
- <td>{{operation.start_date|default:""}}</td>
- <td>{{operation.excavation_end_date|default:""}}</td>
- <td class='link'><a href="#" onclick='load_window("{%url show-operation operation.pk ''%}")'>{% trans "Details" %}</a></td>
- </tr>
- {% empty %}
- <tr><td colspan="8" class='no_items'>{% trans "No operation associated to this archaelogical file" %}</td></tr>
- {% endfor %}
-</table>
-
-<table>
- <caption>{%trans "Admninistrative acts linked to associated operations"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Reference" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Date" %}</th>
- </tr>
- {% for act in item.operation_acts %}
- <tr>
- <td>{{act.signature_date.year}}</td>
- <td>{{act.ref_sra}}</td>
- <td class='string'>{{act.act_type}}</td>
- <td>{{act.signature_date}}</td>
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No administrative act linked to operations" %}</td></tr>
- {% endfor %}
-</table>
-{% endblock %}
diff --git a/ishtar_common/templates/sheet_file_pdf.html b/ishtar_common/templates/sheet_file_pdf.html
deleted file mode 100644
index 3c77c75f8..000000000
--- a/ishtar_common/templates/sheet_file_pdf.html
+++ /dev/null
@@ -1,18 +0,0 @@
-{% extends "sheet_file.html" %}
-{% block css_head %}
-<link rel="stylesheet" href="{{MEDIA_URL}}/media/style_basic.css" />
-{% endblock %}
-{% block main_head %}
-{{ block.super }}
-<div id="pdfheader">
-Ishtar &ndash; {{APP_NAME}} &ndash; {{item}}
-</div>
-{% endblock %}
-{%block head_sheet%}{%endblock%}
-{%block main_foot%}
-<div id="pdffooter">
-&ndash; <pdf:pagenumber/> &ndash;
-</div>
-</body>
-</html>
-{%endblock%}
diff --git a/ishtar_common/templates/sheet_file_window.html b/ishtar_common/templates/sheet_file_window.html
deleted file mode 100644
index e9debdd0d..000000000
--- a/ishtar_common/templates/sheet_file_window.html
+++ /dev/null
@@ -1,3 +0,0 @@
-{% extends "sheet_file.html" %}
-{% block main_head %}{%endblock%}
-{% block main_foot %}{%endblock%}
diff --git a/ishtar_common/templates/sheet_operation.html b/ishtar_common/templates/sheet_operation.html
deleted file mode 100644
index 7b161f641..000000000
--- a/ishtar_common/templates/sheet_operation.html
+++ /dev/null
@@ -1,183 +0,0 @@
-{% extends "sheet.html" %}
-{% load i18n %}
-{% block content %}
-<div class='tool'>{%trans "Export as:"%} <a href='{% url show-operation item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-operation item.pk "pdf" %}'>{%trans "PDF file"%}</a></div>
-<h3>{% trans "General"%}</h3>
-<p><label>{%trans "Year:"%}</label> <span class='value'>{{ item.year }}</span></p>
-{% if item.operation.operation_code %}<p><label>{%trans "Numerical reference:"%}</label> <span class='value'>{{ item.operation_code }}</span></p>{% endif %}
-
-{% if item.code_patriarche %}<p><label>{%trans "Patriarche OA code:"%}</label> <span class='value'>{{ item.code_patriarche }}</span></p>{%else%}
-<p class='alert'>{%trans "Patriarche OA code not yet recorded!"%}</p>{%endif%}
-
-{#<p><label>{%trans "Operation's name:"%}</label> <span class='value'>{{ item.internal_reference }}</span></p>#}
-
-<p><label>{%trans "Edition date:"%}</label> <span class='value'>{{ item.history.all.0.history_date }}</span></p> <!-- date = now -->
-
-{% if item.start_date %}<p><label>{%trans "Begining date:"%}</label> <span class='value'>{{ item.start_date }}</span></p>
-<p><label>{%trans "Excavation end date:"%}</label> <span class='value'>{{ item.excavation_end_date|default:"-" }}</span></p>
-{%endif%}
-{% if item.in_charge %}<p><label>{%trans "Head scientist:"%}</label> <span class='value'>{{ item.in_charge.full_label }}</span></p>{%endif%}
-<p><label>{%trans "State:"%}</label> <span class='value'>{% if item.is_active %}{%trans "Active file"%}</span></p>
-{% else %}{%trans "Closed operation"%}</span></p>
-<p><label>{%trans "Closing date:"%}</label> <span class='value'>{{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user }}</span></p>
-{% endif %}
-<p><label>{%trans "Type:"%}</label> <span class='value'>{{ item.operation_type }}</span></p>
-{% if item.surface %}<p><label>{%trans "Surface:"%}</label> <span class='value'>{{ item.surface }} m<sup>2</sup> ({{ item.surface_ha }} ha)</span></p>{% endif %}
-{% if item.cost %}<p><label>{%trans "Cost:"%}</label> <span class='value'>{{ item.cost }} &euro;{% if item.cost_by_m2 %}, ({{ item.cost_by_m2 }} &euro;/m<sup>2</sup>){%endif%}</span></p>{%endif%}
-{% if item.duration %}<p><label>{%trans "Duration:"%}</label> <span class='value'>{{ item.duration }} {%trans "Day"%}s</span></p>{%endif%}
-
-<p><label>{%trans "Remains:"%}</label> <span class='value'>{{ item.remains.all|join:", " }}</span></p>
-<p><label>{%trans "Periods:"%}</label> <span class='value'>{{ item.periods.all|join:", " }}</span></p>
-
-{% if item.associated_file %}
-<p><label>{%trans "Associated file:"%}</label> <span class='value'><a href='#' onclick='load_window("{% url show-file item.associated_file.pk ''%}")'>{{ item.associated_file }}</a></span></p><!-- Displayed as Year/index/Commune/Common_name This should be a link to the file sheet of the related file -->
-{% if item.associated_file.is_preventive %}
-{#{% if item.operator_reference_code %}<p><label>{%trans "Operator's reference code:"%}</label> <span class='value'>{{ item.operator_reference_code }}</span></p>{% endif %}#}
-{% if item.associated_file.town_planning_service %}<p><label>{%trans "Town planning service:"%}</label> <span class='value'>{{ item.associated_file.town_planning_service }}</span></p>{% endif %}
-{% if item.associated_file.permit_type %}<p><label>{%trans "Permit type:"%}</label> <span class='value'>{{ item.associated_file.permit_type }}</span></p>{% endif %}
-{% if item.associated_file.permit_reference %}<p><label>{%trans "Permit reference:"%}</label> <span class='value'>{{ item.associated_file.permit_reference }}</span></p>{% endif %}
-{% if item.associated_file.general_contractor.attached_to %}<p><label>{%trans "General contractor organisation:"%}</label> <span class='value'>{{ item.associated_file.general_contractor.attached_to }}</span></p>{% endif %} <!-- Contractor's organisation displayed as concat of Name/Adress/postal_code/city -->
-{% if item.associated_file.general_contractor %}<p><label>{%trans "General contractor:"%}</label> <span class='value'>{{ item.associated_file.general_contractor.full_label }}</span></p>{% endif %}
-{% endif %}
-{% endif %}
-
-{% if item.comment %}<p><label>{%trans "Comment:"%}</label> <span class='value'>{{ item.comment }}</span></p>{%endif%}
-
-<h3>{% trans "Localisation"%}</h3>
-<p><label>{%trans "Towns:"%}</label> <span class='value'>{{ item.towns.all|join:", " }}</span></p>
-
-<p><label>{%trans "Main address:"%}</label> <span class='value'>{{ item.associated_file.address }}</span></p>
-{% if item.associated_file.address_complement %}<p><label>{%trans "Complement:"%}</label> <span class='value'>{{ item.associated_file.address_complement }}</span></p>{%endif%}
-{% if item.associated_file.postal_code %}<p><label>{%trans "Postal code:"%}</label> <span class='value'>{{ item.associated_file.postal_code }}</span></p>{%endif%}
-
-{% comment %}
-<p><label>{%trans "Lambert X:"%}</label> <span class='value'>{{ item.lambert_x }}</span></p>
-<p><label>{%trans "Lambert Y:"%}</label> <span class='value'>{{ item.lambert_y }}</span></p>
-<p><label>{%trans "Altitude (m NGF):"%}</label> <span class='value'>{{ item.altitude }}</span></p>
-{% endcomment %}
-<table>
- <caption>{%trans "Associated parcels"%}</caption>
- <tr>
- <th>{% trans "Commune" %}</th>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Section" %}</th>
- <th>{% trans "Parcel" %}</th>
- {#<th>{% trans "Owner" %}</th>#}
- </tr>
- {% for parcel in item.parcels.all %}
- <tr>
- <td class='string'>{{parcel.town}}</td>
- <td>{{parcel.year}}</td>
- <td>{{parcel.section}}</td>
- <td>{{parcel.parcel_number}}</td>
- {#<td class='string'>{{operation.parcel.owner}}</td>#}
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No parcel associated to this operation" %}</td></tr>
- {% endfor %}
-</table>
-
-<table>
- <caption>{%trans "Admninistrative acts"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Reference" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Date" %}</th>
- </tr>
- {% for act in item.administrative_act.all %}
- <tr>
- <td>{{act.signature_date.year}}</td>
- <td>{{act.ref_sra}}</td>
- <td class='string'>{{act.act_type}}</td>
- <td class="string">{{act.signature_date}}</td>
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No acts associated to this operation" %}</td></tr>
- {% endfor %}
-</table>
-
-<h3>{% trans "Scientific documentation"%}</h3>
-<table>
- <caption>{%trans "Documents"%}</caption>
- <tr>
- <th>{% trans "Title" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Authors" %}</th>
- {#<th>{% trans "Localisation" %}</th>#}
- </tr>
- {% for doc in item.source.all %}
- <tr>
- <td class='string'>{{ doc.title }}</td>
- <td class='string'>{{doc.source_type}}</td>
- <td class='string'>{{ doc.authors.all|join:", " }}</td>
- {#<td>{{ doc.localisation }}</td>#}
- </tr>
- {% empty %}
- <tr><td colspan="4" class='no_items'>{% trans "No scientific document associated to this operation" %}</td></tr>
- {% endfor %}
-</table>
-
-<table>
- <caption>{%trans "Context records"%}</caption>
- <tr>
- <th>{% trans "ID" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Chronology" %}</th>
- <th>{% trans "Description" %}</th>
- <th>{% trans "Parcel" %}</th>
- <th class='link'>&nbsp;</th>
- </tr>
- {% for context_record in item.context_record.all %}
- <tr>
- <td class='string'>{{ context_record.label }}</td>
- <td class='string'>{{context_record.unit|default:""}}</td>
- <td class='string'>{{ context_record.datings.all|join:", " }}</td>{# periods ?#}
- <td class='string'>{{ context_record.description }}</td>
- <td class='string'>{{ context_record.parcel.section }} - {{context_record.parcel.parcel_number}}</td>
- <td class='link'><a href="#" onclick='load_window("{%url show-contextrecord context_record.pk ''%}")'>{% trans "Details" %}</a></td>
- </tr>
- {% empty %}
- <tr><td colspan="6" class='no_items'>{% trans "No context record associated to this operation" %}</td></tr>
- {% endfor %}
-</table>
-<div class='table'>
-<table>
- <caption>{%trans "Finds"%}</caption>
- <tr>
- <th>{% trans "Find" %}</th>
- <th>{% trans "Material type" %}</th>
- <th>{% trans "Context record" %}</th>
- <th>{% trans "Periods" %}</th>
- <th>{% trans "Description" %}</th>
- <th>{% trans "Weight" %}</th>
- <th>{% trans "Numbers" %}</th>
- <th>{% trans "Parcel" %}</th>
- <th class='link'>&nbsp;</th>
- </tr>
- {% for context_record in item.context_record.all %}
- {% for find in context_record.base_finds.all %}
- <tr>
- <td class="ref">{{ find.full_label }}</td>
-{# Displayed as (Patriarche operation code)-(Record unit label)-(Finds label). #}
-{# or displayed as (Year)-(index)-(Record unit label)-(Finds label). #}
- <td class="ref">{{ find.material_type_label }}</td>
- <td>{{find.context_record.label}}</td>
- <td class='string'>{{ find.get_last_find.dating}}</td>{# TODO .all|join:", " ? #}
- <td class='string'>{{ find.get_last_find.description }}</td>
- <td>{{ find.get_last_find.weight }}</td>
- <td>{{ find.get_last_find.item_number }}</td>
- <td class="ref">{{ context_record.parcel.short_label }}</td>
- <td class='link'><a href="#">{% trans "Details" %}</a></td>
- {#<a href="#" onclick='load_window("{% url show-find find.pk%}");'>{%trans "Details"%}</a></td>#}
- </tr>
- {% empty %}
- <tr><td colspan="9" class='no_items'>{% trans "No find associated to context record" %} {{context_record.short_label}}</td></tr>
- {% endfor %}
- {% empty %}
- <tr><td colspan="9" class='no_items'>{% trans "No find associated to parcel" %} {{parcel.short_label}} {% trans "(no context record)" %}</td></tr>
- {% endfor %}
-</table>
-</div>
-
-{% endblock %}
diff --git a/ishtar_common/templates/sheet_operation_pdf.html b/ishtar_common/templates/sheet_operation_pdf.html
deleted file mode 100644
index 3397d5f43..000000000
--- a/ishtar_common/templates/sheet_operation_pdf.html
+++ /dev/null
@@ -1,18 +0,0 @@
-{% extends "sheet_operation.html" %}
-{% block css_head %}
-<link rel="stylesheet" href="{{MEDIA_URL}}/media/style_basic.css" />
-{% endblock %}
-{% block main_head %}
-{{ block.super }}
-<div id="pdfheader">
-Ishtar &ndash; {{APP_NAME}} &ndash; {{item}}
-</div>
-{% endblock %}
-{%block head_sheet%}{%endblock%}
-{%block main_foot%}
-<div id="pdffooter">
-&ndash; <pdf:pagenumber/> &ndash;
-</div>
-</body>
-</html>
-{%endblock%}
diff --git a/ishtar_common/templates/sheet_operation_window.html b/ishtar_common/templates/sheet_operation_window.html
deleted file mode 100644
index 9c595a1e9..000000000
--- a/ishtar_common/templates/sheet_operation_window.html
+++ /dev/null
@@ -1,3 +0,0 @@
-{% extends "sheet_operation.html" %}
-{% block main_head %}{%endblock%}
-{% block main_foot %}{%endblock%}
diff --git a/ishtar_common/templatetags/inline_formset.py b/ishtar_common/templatetags/inline_formset.py
new file mode 100644
index 000000000..c3220f207
--- /dev/null
+++ b/ishtar_common/templatetags/inline_formset.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from django import template
+from django.utils.translation import ugettext as _
+import re
+
+register = template.Library()
+
+@register.inclusion_tag('blocks/inline_formset.html')
+def inline_formset(caption, formset, header=True, skip=False):
+ u"""
+ Render a formset as an inline table.
+ For i18n of the caption be carreful to add manualy the caption label to
+ the translated fields
+ """
+ return {'caption':caption, 'formset':formset, 'header':header, 'skip':skip}
+
diff --git a/ishtar_common/templatetags/table_form.py b/ishtar_common/templatetags/table_form.py
index 7adb54d65..0ab49d93f 100644
--- a/ishtar_common/templatetags/table_form.py
+++ b/ishtar_common/templatetags/table_form.py
@@ -5,6 +5,6 @@ from django.template import Library
register = Library()
-@register.inclusion_tag('form_snippet.html')
+@register.inclusion_tag('blocks/form_snippet.html')
def table_form(form):
return {'form': form}
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 4a1a656d9..641ca8046 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -170,10 +170,10 @@ def format_val(val):
return unicode(val)
HIERARCHIC_LEVELS = 5
-HIERARCHIC_FIELDS = ['period', 'unit', 'material_type']
+HIERARCHIC_FIELDS = ['periods', 'period', 'unit', 'material_type']
PRIVATE_FIELDS = ('id', 'history_modifier', 'order')
def get_item(model, func_name, default_name, extra_request_keys=[],
- base_request={}, bool_fields=[]):
+ base_request={}, bool_fields=[], dated_fields=[]):
"""
Generic treatment of tables
"""
@@ -213,7 +213,18 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
dct.pop(k)
else:
dct[k] = dct[k] == u"2" and True or False
-
+ for k in dated_fields:
+ if k in dct:
+ if not dct[k]:
+ dct.pop(k)
+ try:
+ items = dct[k].split('/')
+ assert len(items) == 3
+ dct[k] = datetime.date(*map(lambda x: int(x),
+ reversed(items))
+ ).strftime('%Y-%m-%d')
+ except AssertionError:
+ dct.pop(k)
# manage hierarchic conditions
or_reqs = []
for req in dct.copy():
@@ -373,7 +384,7 @@ def show_item(model, name):
n.strftime('%Y%m%d-%H%M%S'))
if doc_type == "odt" and settings.XHTML2ODT_PATH and \
settings.ODT_TEMPLATE:
- tpl = loader.get_template('sheet_%s.html' % name)
+ tpl = loader.get_template('ishtar/sheet_%s.html' % name)
content = tpl.render(context_instance)
try:
tidy_options = dict(output_xhtml=1, add_xml_decl=1, indent=1,
@@ -413,7 +424,7 @@ def show_item(model, name):
response.write(odtfile)
return response
elif doc_type == 'pdf':
- tpl = loader.get_template('sheet_%s_pdf.html' % name)
+ tpl = loader.get_template('ishtar/sheet_%s_pdf.html' % name)
content = tpl.render(context_instance)
result = StringIO.StringIO()
html = content.encode('utf-8')
@@ -427,7 +438,7 @@ def show_item(model, name):
return response
return HttpResponse(content, content_type="application/xhtml")
else:
- tpl = loader.get_template('sheet_%s_window.html' % name)
+ tpl = loader.get_template('ishtar/sheet_%s_window.html' % name)
content = tpl.render(context_instance)
return HttpResponse(content, content_type="application/xhtml")
return func
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index ecc48a1e8..06d6f20f0 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -206,7 +206,7 @@ class JQueryJqGrid(forms.RadioSelect):
self.source_full = source_full
def render(self, name, value=None, attrs=None):
- t = loader.get_template('form_snippet.html')
+ t = loader.get_template('blocks/form_snippet.html')
rendered = t.render(Context({'form':self.form}))
rendered += u"\n</table>\n"\
u"<button id='search_%s' class='submit'>%s</button>" % (
@@ -219,8 +219,8 @@ class JQueryJqGrid(forms.RadioSelect):
rendered += "\n<h4>%s</h4>\n" % unicode(_("Search and select an item"))
extra_cols = []
col_names, col_idx = [], []
- for k in self.form.fields:
- field = self.form.fields[k]
+ for k in self.form.get_input_ids():
+ #field = self.form.fields[k]
col_idx.append(u'"%s"' % k)
for field_name in getattr(self.associated_model, self.table_cols):
field = self.associated_model
@@ -292,7 +292,7 @@ class JQueryJqGrid(forms.RadioSelect):
}
}
var mygrid = jQuery("#grid_%(name)s");
- var url = "%(source)s?submited=1&amp;" + data;
+ var url = "%(source)s?submited=1&" + data;
mygrid.setGridParam({url:url});
mygrid.trigger("reloadGrid");
return false;
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 8b6e1a50d..e421c25dd 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2010-2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2010-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -461,15 +461,26 @@ class Wizard(NamedUrlWizardView):
k = u'-'.join(items)
data[k] = data.pop(key)[0]
# get a form key
- base_key = form.form.base_fields.keys()[0]
- init = self.get_form_initial(step)
+ frm = form.form
+ if callable(frm):
+ frm = frm()
+ base_key = frm.base_fields.keys()[-1]
+ init = self.get_form_initial(step, data=data)
total_field = len([key for key in data.keys()
if base_key in key.split('-')
and data[key]])
- if init and not to_delete:
+ if init and not to_delete and (
+ not hasattr(self, 'form_initialized') or
+ not self.form_initialized):
total_field = max((total_field, len(init)))
data[step + u'-INITIAL_FORMS'] = unicode(total_field)
data[step + u'-TOTAL_FORMS'] = unicode(total_field + 1)
+ # update initialization
+ if request.POST and init and hasattr(self, 'form_initialized') \
+ and self.form_initialized:
+ for k in init[0]:
+ data[step + '-' + unicode(total_field) + '-' + k] = \
+ init[0][k]
data = data or None
form = super(Wizard, self).get_form(step, data, files)
return form
@@ -561,7 +572,7 @@ class Wizard(NamedUrlWizardView):
pass
return current_obj
- def get_form_initial(self, step):
+ def get_form_initial(self, step, data=None):
current_obj = self.get_current_object()
current_step = self.steps.current
request = self.request