summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2013-10-28 21:32:30 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2013-10-28 21:32:30 +0100
commitedf06a984dda8678c296a58875ffae7aaf5c192a (patch)
treeaf6cbbeb81036c1e20a188359cffd5d9b63debaf
parent188338115899e9f7dafe61f6a672ec79bbd07433 (diff)
downloadIshtar-edf06a984dda8678c296a58875ffae7aaf5c192a.tar.bz2
Ishtar-edf06a984dda8678c296a58875ffae7aaf5c192a.zip
Display a reminder of items concerned by the current edition (refs #1218)
-rw-r--r--archaeological_context_records/wizards.py12
-rw-r--r--archaeological_finds/wizards.py15
-rw-r--r--archaeological_operations/wizards.py27
-rw-r--r--example_project/settings.py2
-rw-r--r--ishtar_common/static/media/style.css71
-rw-r--r--ishtar_common/templates/base.html5
-rw-r--r--ishtar_common/templates/ishtar/wizard/default_wizard.html1
-rw-r--r--ishtar_common/templates/ishtar/wizard/parcels_wizard.html1
8 files changed, 71 insertions, 63 deletions
diff --git a/archaeological_context_records/wizards.py b/archaeological_context_records/wizards.py
index afed15c4e..60dab44d6 100644
--- a/archaeological_context_records/wizards.py
+++ b/archaeological_context_records/wizards.py
@@ -34,6 +34,7 @@ class RecordWizard(Wizard):
step = self.steps.current
if not step:
return
+ # manage manualy on creation
if step.endswith('_creation'): # an operation has been selected
main_form_key = 'selec-' + self.url_name
try:
@@ -46,21 +47,16 @@ class RecordWizard(Wizard):
if current_cr:
return current_cr.operation
- # get_template_context
def get_context_data(self, form, **kwargs):
"""
Get the operation "reminder" on top of wizard forms
"""
context = super(RecordWizard, self).get_context_data(form)
+
operation = self.get_current_operation()
- if not operation:
+ if not operation or self.steps.current.startswith('selec-'):
return context
- items = []
- if hasattr(operation, 'code_patriarche') and operation.code_patriarche:
- items.append(unicode(operation.code_patriarche))
- items.append("-".join((unicode(operation.year),
- unicode(operation.operation_code))))
- context['reminder'] = _("Current operation: ") + " - ".join(items)
+ context['reminders'] = ((_("Operation"), unicode(operation)),)
return context
def get_form(self, step=None, data=None, files=None):
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py
index de16d2069..e5024f10e 100644
--- a/archaeological_finds/wizards.py
+++ b/archaeological_finds/wizards.py
@@ -50,25 +50,16 @@ class FindWizard(Wizard):
if base_finds:
return base_finds[0].context_record
- #def get_template_context(self, request, storage, form=None):
def get_context_data(self, form, **kwargs):
"""
Get the operation and context record "reminder" on top of wizard forms
"""
context = super(FindWizard, self).get_context_data(form, **kwargs)
current_cr = self.get_current_contextrecord()
- if not current_cr:
+ if not current_cr or self.steps.current.startswith('select-'):
return context
- operation = current_cr.operation
- items = []
- if hasattr(operation, 'code_patriarche') and operation.code_patriarche:
- items.append(unicode(operation.code_patriarche))
- items.append("-".join((unicode(operation.year),
- unicode(operation.operation_code))))
- reminder = unicode(_("Current operation: ")) + u" - ".join(items)
- reminder += u"<br/>" + unicode(_("Current context record: "))\
- + unicode(current_cr.label)
- context['reminder'] = mark_safe(reminder)
+ context['reminders'] = ((_("Operation"), unicode(current_cr.operation)),
+ (_(u"Context record"), unicode(current_cr)))
return context
def get_extra_model(self, dct, form_list):
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index f20999f18..07c8844b9 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -45,6 +45,19 @@ class OperationWizard(Wizard):
templates = ['ishtar/wizard/parcels_wizard.html'] + templates
return templates
+ def get_current_file(self):
+ step = self.steps.current
+ if not step:
+ return
+ main_form_key = 'general-' + self.url_name
+ try:
+ idx = int(self.session_get_value(main_form_key,
+ 'associated_file'))
+ current_file = models.File.objects.get(pk=idx)
+ return current_file
+ except(TypeError, ValueError, ObjectDoesNotExist):
+ pass
+
def get_context_data(self, form, **kwargs):
"""
Return extra context for templates
@@ -54,13 +67,15 @@ class OperationWizard(Wizard):
step = self.steps.current
if step.startswith('towns-'):
context['TOWNS'] = self.get_towns()
- elif step.startswith('parcels-'):
+ elif step.startswith('parcels-') and self.get_current_file():
# if a file is acciated to the operation add the button "Add all"
- general_form_key = 'general-' + self.url_name
- file_id = self.session_get_value(general_form_key,
- "associated_file")
- if file_id:
- context['add_all'] = True
+ context['add_all'] = True
+ # reminder of the current file
+ archaeological_file = self.get_current_file()
+ if not archaeological_file or self.steps.current.startswith('general-'):
+ return context
+ context['reminders'] = ((_("Archaelogical file"),
+ unicode(archaeological_file)),)
return context
def get_towns(self):
diff --git a/example_project/settings.py b/example_project/settings.py
index e7a2d5643..1e9051429 100644
--- a/example_project/settings.py
+++ b/example_project/settings.py
@@ -172,7 +172,7 @@ ENCODING = 'windows-1252'
APP_NAME = "SRA - Pays de la Loire"
SURFACE_UNIT = 'square-metre'
SURFACE_UNIT_LABEL = u'm²'
-JOINT = u"|"
+JOINT = u" | "
ISHTAR_OPE_COL_FORMAT = None
# DB key: (txt_idx, label)
ISHTAR_OPE_TYPES = {}
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css
index 83e538331..e59f84e85 100644
--- a/ishtar_common/static/media/style.css
+++ b/ishtar_common/static/media/style.css
@@ -175,13 +175,31 @@ div#language_form_div label{
div#context_menu{
height:110px;
- margin-left:200px;
- margin-right:20px;
- margin-bottom:20px;
+ float:right;
+ margin-right:10px;
+}
+
+div#context_menu fieldset{
+ background-color:#EEE;
+ border:2px solid #CCC;
+ -moz-border-radius:8px;
+ -webkit-border-radius:8px;
+ border-radius:8px;
+}
+
+div#context_menu ul{
+ margin:0;
+ padding:2px;
+}
+
+div#context_menu li{
+ margin: 0;
+ list-style:none;
}
div#main_menu{
width:200px;
+ top:160px;
position:absolute;
}
@@ -203,37 +221,12 @@ div#main_menu .selected a{
color:#D14;
}
-
div#main_menu > ul{
color:#922;
}
-div#context_menu fieldset{
- right:20px;
- position:absolute;
- width:420px;
- background-color:#EEE;
- border:2px solid #CCC;
- -moz-border-radius:8px;
- -webkit-border-radius:8px;
- border-radius:8px;
-}
-/*div#context_menu fieldset label{
- display:inline;
-}*/
-
-div#context_menu ul{
- margin:0;
- padding:2px;
-}
-
-div#context_menu li{
- margin: 0;
- list-style:none;
-}
-
-
div#content{
+ clear:both;
margin:0 200px;
text-align:center;
}
@@ -268,17 +261,27 @@ ul#form_path button {
font-family:Arial, Helvetica, sans-serif;
}
-.reminder{
+#reminder{
padding:0.4em;
+ margin-right:10px;
border:1px solid #CCC;
-moz-border-radius:8px;
-webkit-border-radius:8px;
border-radius:8px;
- text-align:center;
- width:400px;
- margin-left:auto;
- margin-right:auto;
background-color:white;
+ float:right;
+}
+
+#reminder p{
+ margin:0;
+ padding:0;
+}
+
+#reminder strong.lbl,
+#reminder span.value {
+ display:inline-block;
+ max-width:250px;
+ vertical-align:top;
}
div.form {
diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html
index e7fdf3e6f..e235df60a 100644
--- a/ishtar_common/templates/base.html
+++ b/ishtar_common/templates/base.html
@@ -78,6 +78,11 @@
</form>
{% endif %}{% endblock %}
</div>
+{% if reminders %}<fieldset id='reminder'><legend>{% trans "Current items" %}</legend>
+{% for lbl, value in reminders%}
+<p><strong class='lbl'>{{lbl}}{% trans ":"%}</strong> <span class='value'>{{value}}</span></p>
+{% endfor %}
+</fieldset>{%endif%}
<div id="main_menu">
<ul>
{% for section in MENU.childs %}
diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html
index b2c7189cf..c1c0cb5cf 100644
--- a/ishtar_common/templates/ishtar/wizard/default_wizard.html
+++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html
@@ -21,7 +21,6 @@
{% block wizard_form %}
<form action="." method="post" name='wizard'{% if wizard.form.file_upload %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}
<div class='form'>
-{% if reminder %}<div class='reminder'>{{ reminder }}</div>{%endif%}
{{ wizard.form.media }}
{{ wizard.management_form }}
{% if wizard.form.forms %}
diff --git a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html
index 5d135a563..b550cf6c4 100644
--- a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html
+++ b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html
@@ -6,7 +6,6 @@
{% block wizard_form %}
<form action="." method="post">{% csrf_token %}
<div class='form'>
-{% if reminder %}<div class='reminder'>{{ reminder }}</div>{%endif%}
{{ wizard.form.media }}
{{ wizard.management_form }}
{{ wizard.form.management_form }}