[Mpuls-commits] r3653 - in base/trunk: . mpulsweb/controllers mpulsweb/lib mpulsweb/templates/evaluation
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 15 15:01:41 CEST 2010
Author: bh
Date: 2010-09-15 15:01:36 +0200 (Wed, 15 Sep 2010)
New Revision: 3653
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/controllers/evaluate.py
base/trunk/mpulsweb/lib/validators.py
base/trunk/mpulsweb/templates/evaluation/evaluate.mako
Log:
* mpulsweb/controllers/evaluate.py (get_search_options): New
parameter selected_ids for the list of ids of the cases selected
for evaluation.
(EvaluateController.reset_filter): New. Reset the list of
selected cases.
(EvaluateController.evaluate, EvaluateController.evaluateAction):
Pass the list of selected case ids to get_search_options
(EvaluateController._get_evalparams): Add the test for the
selected cases to the WHERE clause of the sql statement used for
evaluation.
* mpulsweb/lib/validators.py
(EvaluationFormValidator.selected_ids): New validator for the
selected_ids form parameter.
* mpulsweb/templates/evaluation/evaluate.mako: Add note about the
selected cases with a link to reset that list. Add a hidden
parameter selected_ids for the list of selected cases
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2010-09-15 12:07:00 UTC (rev 3652)
+++ base/trunk/ChangeLog 2010-09-15 13:01:36 UTC (rev 3653)
@@ -1,5 +1,26 @@
2010-09-15 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/templates/evaluation/evaluate.mako: Add note about the
+ selected cases with a link to reset that list. Add a hidden
+ parameter selected_ids for the list of selected cases
+
+ * mpulsweb/lib/validators.py
+ (EvaluationFormValidator.selected_ids): New validator for the
+ selected_ids form parameter.
+
+ * mpulsweb/controllers/evaluate.py (get_search_options): New
+ parameter selected_ids for the list of ids of the cases selected
+ for evaluation.
+ (EvaluateController.reset_filter): New. Reset the list of
+ selected cases.
+ (EvaluateController.evaluate, EvaluateController.evaluateAction):
+ Pass the list of selected case ids to get_search_options
+ (EvaluateController._get_evalparams): Add the test for the
+ selected cases to the WHERE clause of the sql statement used for
+ evaluation.
+
+2010-09-15 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/templates/casemanagement/overview.mako: Add action
"evaluate" if the evaluation module is activated.
Modified: base/trunk/mpulsweb/controllers/evaluate.py
===================================================================
--- base/trunk/mpulsweb/controllers/evaluate.py 2010-09-15 12:07:00 UTC (rev 3652)
+++ base/trunk/mpulsweb/controllers/evaluate.py 2010-09-15 13:01:36 UTC (rev 3653)
@@ -63,7 +63,7 @@
return suc
-def get_search_options(soptions=None, id=None):
+def get_search_options(soptions=None, id=None, selected_ids=()):
options = {}
options['id'] = id
if soptions:
@@ -88,6 +88,7 @@
options['start_date'] = g.mpuls_config.get('search',
'default-start-date')
options['end_date'] = g.mpuls_config.get('search', 'default-end-date')
+ options["selected_ids"] = " ".join(map(unicode, selected_ids))
options['typelist'] = c.evalconfig.get_evaluations()
#phases = []
@@ -107,6 +108,12 @@
def index(self):
return self.evaluate()
+ def reset_filter(self, id):
+ if session.has_key("evaluation_ids"):
+ del session['evaluation_ids']
+ session.save()
+ return self.evaluate(id)
+
def evaluate(self, id=None):
conn, cur = None, None
try:
@@ -121,7 +128,8 @@
db.recycleConnection(conn, cur)
c.evaloptions = get_search_options(session.get('evaluation.options'),
- id)
+ id,
+ session.get("evaluation_ids", ()))
# If user selects adele-evaluation render page with disabled
# configuration elements. Change default params
@@ -175,8 +183,14 @@
dates.append("TRUE")
dates.append(' )')
+ selected_ids = "TRUE"
+ if form_result.get("selected_ids"):
+ selected_ids = ("(m.id in (%s))"
+ % (",".join(map(str, form_result["selected_ids"]))))
+
params['sql'] = ("SELECT %%(fields)s from master_tbl_eval_total_view m"
- " WHERE %s " % ("".join(dates)))
+ " WHERE %s " % (" AND ".join(("".join(dates),
+ selected_ids))))
#Datefields
if all_phases:
@@ -210,7 +224,9 @@
form_result = error.value
form_errors = error.error_dict or {}
c.evaloptions = get_search_options(session.get('evaluation.options'),
- id)
+ id,
+ session.get("evaluation_ids",
+ ()))
form = render('/evaluation/evaluate.mako')
return formencode.htmlfill.render(form, defaults=form_result,
errors=form_errors,
Modified: base/trunk/mpulsweb/lib/validators.py
===================================================================
--- base/trunk/mpulsweb/lib/validators.py 2010-09-15 12:07:00 UTC (rev 3652)
+++ base/trunk/mpulsweb/lib/validators.py 2010-09-15 13:01:36 UTC (rev 3653)
@@ -653,6 +653,9 @@
type_ending = ForEach(String(), convert_to_list=True)
phase = ForEach(String(), convert_to_list=True)
show_percent = Bool(if_missing=False)
+ selected_ids = Wrapper(to_python=lambda s: [int(item)
+ for item in s.split()],
+ if_missing=None)
class SearchCaseForm(BaseFormValidator):
Modified: base/trunk/mpulsweb/templates/evaluation/evaluate.mako
===================================================================
--- base/trunk/mpulsweb/templates/evaluation/evaluate.mako 2010-09-15 12:07:00 UTC (rev 3652)
+++ base/trunk/mpulsweb/templates/evaluation/evaluate.mako 2010-09-15 13:01:36 UTC (rev 3653)
@@ -61,12 +61,18 @@
<form:error name="end_date" format="">
</td>
</tr>
- % if session.has_key('evaluation.options'):
+ <%
+ evaluation_ids = session.get("evaluation_ids")
+ %>
+ % if evaluation_ids:
<tr>
<td class="label">${_('Filter')}</td>
<td>
- Yes (<a href="${h.url_for(controller='/evaluate', action='resetFilter', id=c.evalconfig.get_setid())}">Reset</a>)<br>
- ${session['evaluation.options'].get('sql')}
+ ${_("Yes")} (<a href="${h.url_for(controller='/evaluate', action='reset_filter', id=c.evalconfig.get_setid())}">${_("Reset")}</a>)<br>
+ ${(ungettext("%d case has been selected for evaluation",
+ "%d cases have been selected for evaluation",
+ len(evaluation_ids)) % len(evaluation_ids))}
+ <input type="hidden" name="selected_ids">
</td>
</tr>
% endif
More information about the Mpuls-commits
mailing list