summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/views.py36
-rw-r--r--archaeological_operations/wizards.py4
-rw-r--r--ishtar_common/templates/ishtar/wizard/default_wizard.html2
-rw-r--r--ishtar_common/templates/ishtar/wizard/search.html4
-rw-r--r--ishtar_common/templates/ishtar/wizard/towns_wizard.html20
-rw-r--r--ishtar_common/templates/ishtar/wizard/wizard_done_summary.html2
-rw-r--r--ishtar_common/templates/ishtar/wizard/wizard_done_summary_2.html2
-rw-r--r--ishtar_common/templates/ishtar/wizard/wizard_list_search_result.html2
-rw-r--r--ishtar_common/wizards.py20
9 files changed, 37 insertions, 55 deletions
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 38e2a1bc4..a9200cafa 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -32,11 +32,12 @@ import models
def autocomplete_operation(request, non_closed=True):
person_types = request.user.ishtaruser.person.person_type
- if (not request.user.has_perm('ishtar_common.view_operation', models.Operation)\
- and not request.user.has_perm('ishtar_common.view_own_operation',
- models.Operation)
- and not person_types.rights.filter(wizard__url_name='operation_search'
- ).count()):
+ if (not request.user.has_perm('ishtar_common.view_operation',
+ models.Operation)
+ and not request.user.has_perm('ishtar_common.view_own_operation',
+ models.Operation)
+ and not person_types.rights.filter(
+ wizard__url_name='operation_search').count()):
return HttpResponse(mimetype='text/plain')
if not request.GET.get('term'):
return HttpResponse(mimetype='text/plain')
@@ -59,32 +60,33 @@ def autocomplete_operation(request, non_closed=True):
return HttpResponse(data, mimetype='text/plain')
def get_available_operation_code(request, year=None):
- if not request.user.has_perm('ishtar_common.view_operation', models.Operation)\
+ if not request.user.has_perm('ishtar_common.view_operation',
+ models.Operation)\
and not request.user.has_perm('ishtar_common.view_own_operation',
- models.Operation):
+ models.Operation):
return HttpResponse(mimetype='text/plain')
data = json.dumps({'id':models.Operation.get_available_operation_code(year)})
return HttpResponse(data, mimetype='text/plain')
get_operation = get_item(models.Operation, 'get_operation', 'operation',
- bool_fields = ['end_date__isnull'],
- extra_request_keys={'common_name':'common_name__icontains',
- 'end_date':'end_date__isnull',
- 'year_index':('year', 'operation_code')})
+ bool_fields = ['end_date__isnull'],
+ extra_request_keys={'common_name':'common_name__icontains',
+ 'end_date':'end_date__isnull',
+ 'year_index':('year', 'operation_code')})
show_operation = show_item(models.Operation, 'operation')
revert_operation = revert_item(models.Operation)
get_operationsource = get_item(models.OperationSource,
- 'get_operationsource', 'operationsource',
- extra_request_keys={'operation__towns':'operation__towns__pk',
+ 'get_operationsource', 'operationsource',
+ extra_request_keys={'operation__towns':'operation__towns__pk',
'operation__operation_type':'operation__operation_type__pk',
'operation__year':'operation__year'})
get_administrativeactop = get_item(models.AdministrativeAct,
- 'get_administrativeactop', 'administrativeactop',
- extra_request_keys={'associated_file__towns':'associated_file__towns__pk',
- 'operation__towns':'operation__towns__pk',
- 'act_type__intented_to':'act_type__intented_to'})
+ 'get_administrativeactop', 'administrativeactop',
+ extra_request_keys={'associated_file__towns':'associated_file__towns__pk',
+ 'operation__towns':'operation__towns__pk',
+ 'act_type__intented_to':'act_type__intented_to'})
def dashboard_operation(request, dct, obj_id=None, *args, **kwargs):
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index 66469b5b7..3281a5723 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -36,9 +36,7 @@ class OperationWizard(Wizard):
templates = super(OperationWizard, self).get_template_names()
current_step = self.steps. current
if current_step.startswith('towns-'):
- # vérifier que le context_data est bien chargé
- #templates = ['ishtar/wizard/towns_wizard.html'] + templates
- templates = ['ishtar/wizar/towns_wizard.html'] + templates
+ templates = ['ishtar/wizard/towns_wizard.html'] + templates
return templates
def get_context_data(self, form, **kwargs):
diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html
index c379d8fbb..e2abc80b6 100644
--- a/ishtar_common/templates/ishtar/wizard/default_wizard.html
+++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html
@@ -29,7 +29,7 @@
{% for formsetform in wizard.form.forms %}
{% table_form formsetform %}
{% endfor %}
- <tr class='modify'><td colspan="2"><button name="formset_modify" value="{{form_step}}">{% trans "Add/Modify" %}</button></td></tr></li>
+ <tr class='modify'><td colspan="2"><button name="formset_modify" value="{{wizard.steps.current}}">{% trans "Add/Modify" %}</button></td></tr></li>
</table>
{% else %}
<table>
diff --git a/ishtar_common/templates/ishtar/wizard/search.html b/ishtar_common/templates/ishtar/wizard/search.html
index 7ed214a48..6bb82abdd 100644
--- a/ishtar_common/templates/ishtar/wizard/search.html
+++ b/ishtar_common/templates/ishtar/wizard/search.html
@@ -7,7 +7,7 @@
{% block content %}
<h2>{{wizard_label}}</h2>
<ul id='form_path'>
- <li class='current'>&raquo;&nbsp;<a href='#'>{{form.form_label}}</a></li>
+ <li class='current'>&raquo;&nbsp;<a href='#'>{{current_step.form_label}}</a></li>
</ul>
<div class='form'>
{% if wizard.form.forms %}
@@ -18,7 +18,7 @@
{% for formsetform in wizard.form.forms %}
{{ formsetform.as_table }}
{% endfor %}
- <tr class='modify'><td colspan="2"><button name="formset_modify" value="{{form_step}}">{% trans "Add/Modify" %}</button></td></tr></li>
+ <tr class='modify'><td colspan="2"><button name="formset_modify" value="{{wizard.steps.current}}">{% trans "Add/Modify" %}</button></td></tr></li>
</table>
{% else %}
<table>
diff --git a/ishtar_common/templates/ishtar/wizard/towns_wizard.html b/ishtar_common/templates/ishtar/wizard/towns_wizard.html
index 115ac9838..cd40e6049 100644
--- a/ishtar_common/templates/ishtar/wizard/towns_wizard.html
+++ b/ishtar_common/templates/ishtar/wizard/towns_wizard.html
@@ -1,10 +1,11 @@
-{% extends "default_wizard.html" %}
+{% extends "ishtar/wizard/default_wizard.html" %}
{% load i18n %}
{% load range %}
{% block extra_head %}
-{{form.media}}
+{{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 %}
@@ -13,20 +14,21 @@
<li class='current'>&raquo;&nbsp;<a href='#'>{{current_step.form_label}}</a></li>
</ul>
<div class='form'>
-{% if extra_context.TOWNS %}
-{% if form.forms %}
+{% if TOWNS %}
+{% if wizard.form.forms %}
<div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div>
<table class='formset'>
- {%if form.non_form_errors%}<tr class='error'><th colspan='2'>{{form.non_form_errors}}</th></tr>{%endif%}
- {{ form.management_form }}
- {% for formsetform in form.forms %}
+ {{ wizard.management_form }}
+ {%if wizard.form.non_form_errors%}<tr class='error'><th colspan='2'>{{wizard.form.non_form_errors}}</th></tr>{%endif%}
+ {{ wizard.form.management_form }}
+ {% for formsetform in wizard.form.forms %}
{{ formsetform.as_table }}
{% endfor %}
- <tr class='modify'><td colspan="2"><button name="formset_modify" value="{{form_step}}">{% trans "Add/Modify" %}</button></td></tr></li>
+ <tr class='modify'><td colspan="2"><button name="formset_modify" value="{{wizard.steps.current}}">{% trans "Add/Modify" %}</button></td></tr></li>
</table>
{% else %}
<table>
- {{ form.as_table }}
+ {{ wizard.form.as_table }}
</table>
{% endif %}
{% else %}
diff --git a/ishtar_common/templates/ishtar/wizard/wizard_done_summary.html b/ishtar_common/templates/ishtar/wizard/wizard_done_summary.html
index 53650dafe..ad069a738 100644
--- a/ishtar_common/templates/ishtar/wizard/wizard_done_summary.html
+++ b/ishtar_common/templates/ishtar/wizard/wizard_done_summary.html
@@ -1,4 +1,4 @@
-{% extends "wizard_done.html" %}
+{% extends "ishtar/wizard/wizard_done.html" %}
{% load i18n %}
{% block content %}
diff --git a/ishtar_common/templates/ishtar/wizard/wizard_done_summary_2.html b/ishtar_common/templates/ishtar/wizard/wizard_done_summary_2.html
index 66a572542..2b907ffc6 100644
--- a/ishtar_common/templates/ishtar/wizard/wizard_done_summary_2.html
+++ b/ishtar_common/templates/ishtar/wizard/wizard_done_summary_2.html
@@ -1,4 +1,4 @@
-{% extends "wizard_done.html" %}
+{% extends "ishtar/wizard/wizard_done.html" %}
{% load i18n %}
{% block content %}
diff --git a/ishtar_common/templates/ishtar/wizard/wizard_list_search_result.html b/ishtar_common/templates/ishtar/wizard/wizard_list_search_result.html
index 6cbafb930..c6be97b64 100644
--- a/ishtar_common/templates/ishtar/wizard/wizard_list_search_result.html
+++ b/ishtar_common/templates/ishtar/wizard/wizard_list_search_result.html
@@ -1,4 +1,4 @@
-{% extends "wizard_done.html" %}
+{% extends "ishtar/wizard/wizard_done.html" %}
{% load i18n %}
{% block content %}
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 373ee0e41..8b6e1a50d 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -66,7 +66,6 @@ class Wizard(NamedUrlWizardView):
def __init__(self, *args, **kwargs):
"""Check right for each step of the wizard"""
- print "2"
super(Wizard, self).__init__(*args, **kwargs)
for form_key in self.form_list.keys()[:-1]:
condition = True
@@ -85,17 +84,14 @@ class Wizard(NamedUrlWizardView):
def get_prefix(self, *args, **kwargs):
"""As the class name can interfere when reused prefix with the url_name
"""
- print "3"
return self.url_name + super(Wizard, self).get_prefix(*args,
**kwargs)
def get_wizard_name(self):
"""As the class name can interfere when reused, use the url_name"""
- print "4"
return self.url_name
def get_template_names(self):
- print "5"
templates = ['ishtar/wizard/default_wizard.html']
current_step = self.steps.current
if current_step == self.steps.last:
@@ -104,7 +100,6 @@ class Wizard(NamedUrlWizardView):
def get_context_data(self, form, **kwargs):
"""Add previous, next and current steps to manage the wizard path"""
- print "6"
context = super(Wizard, self).get_context_data(form)
self.request.session['CURRENT_ACTION'] = self.get_wizard_name()
step = self.steps.first
@@ -170,7 +165,6 @@ class Wizard(NamedUrlWizardView):
def get_formated_datas(self, forms):
"""Get the data to present in the last page"""
- print "7"
datas = []
for form in forms:
form_datas = []
@@ -235,13 +229,11 @@ class Wizard(NamedUrlWizardView):
return datas
def get_extra_model(self, dct, form_list):
- print "8"
dct['history_modifier'] = self.request.user
return dct
def done(self, form_list, return_object=False, **kwargs):
"""Save to the model"""
- print "9"
dct, m2m, whole_associated_models = {}, [], []
for form in form_list:
if not form.is_valid():
@@ -311,17 +303,14 @@ class Wizard(NamedUrlWizardView):
def get_saved_model(self):
"""Permit a distinguo when saved model is not the base selected model"""
- print "10"
return self.model
def get_current_saved_object(self):
"""Permit a distinguo when saved model is not the base selected model"""
- print "11"
return self.get_current_object()
def save_model(self, dct, m2m, whole_associated_models, form_list,
return_object):
- print "12"
dct = self.get_extra_model(dct, form_list)
obj = self.get_current_saved_object()
# manage dependant items
@@ -423,7 +412,6 @@ class Wizard(NamedUrlWizardView):
def get_deleted(self, keys):
"""Get the deleted and non-deleted items in formsets"""
- print "13"
not_to_delete, to_delete = set(), set()
for key in keys:
items = key.split('-')
@@ -444,7 +432,6 @@ class Wizard(NamedUrlWizardView):
def get_form(self, step=None, data=None, files=None):
"""Manage formset"""
- print "14"
request = self.request
storage = self.storage
if data:
@@ -493,7 +480,6 @@ class Wizard(NamedUrlWizardView):
- modify or delete button in formset: next step = current step
- validate and end: nextstep = last step
"""
- print "15"
request = self.request
if request.POST.has_key('formset_modify') \
and request.POST['formset_modify'] \
@@ -512,7 +498,6 @@ class Wizard(NamedUrlWizardView):
def post(self, *args, **kwargs):
"""Convert numerical step number to step name"""
- print "16"
request = self.request
post_data = request.POST.copy()
if request.POST.has_key('form_prev_step'):
@@ -529,7 +514,6 @@ class Wizard(NamedUrlWizardView):
"""Check if the session has value of a specific form and (if provided)
of a key
"""
- print "17"
request = self.request
storage = self.storage
test = storage.prefix in request.session \
@@ -544,7 +528,6 @@ class Wizard(NamedUrlWizardView):
def session_get_value(self, form_key, key, multi=False):
"""Get the value of a specific form"""
- print "18"
if not self.session_has_key(form_key, key, multi):
return
request = self.request
@@ -568,7 +551,6 @@ class Wizard(NamedUrlWizardView):
def get_current_object(self):
"""Get the current object for an instancied wizard"""
- print "19"
current_obj = None
main_form_key = 'selec-' + self.url_name
try:
@@ -580,7 +562,6 @@ class Wizard(NamedUrlWizardView):
return current_obj
def get_form_initial(self, step):
- print "20"
current_obj = self.get_current_object()
current_step = self.steps.current
request = self.request
@@ -611,7 +592,6 @@ class Wizard(NamedUrlWizardView):
def get_instanced_init(self, obj, step=None):
"""Get initial data from an init"""
- print "21"
current_step = step or self.steps.current
c_form = self.form_list[current_step]
# make the current object the default item for the session