[Mpuls-commits] r3593 - in wasko/trunk: . waskoweb/lib waskoweb/templates/casemanagement
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Sep 10 20:16:30 CEST 2010
Author: bh
Date: 2010-09-10 20:16:26 +0200 (Fri, 10 Sep 2010)
New Revision: 3593
Added:
wasko/trunk/waskoweb/templates/casemanagement/search_extra.mako
Modified:
wasko/trunk/ChangeLog
wasko/trunk/wasko.json
wasko/trunk/waskoweb/lib/search.py
Log:
* wasko.json: Add default values for the type_ending search
option. By default all possible values are matched.
* waskoweb/lib/search.py (CaseSearch.VALID_OPTIONS)
(CaseSearch.MULTI_OPTIONS): Add new "type_ending"
(CaseSearch.validate_form_params)
(CaseSearch.convert_form_parameters)
(CaseSearch.get_ending_clause, CaseSearch.get_where_subclauses):
New. Implement search for type of CM ending.
* waskoweb/templates/casemanagement/search_extra.mako: New.
Contains the template part of the type_ending search option.
Modified: wasko/trunk/ChangeLog
===================================================================
--- wasko/trunk/ChangeLog 2010-09-10 15:38:46 UTC (rev 3592)
+++ wasko/trunk/ChangeLog 2010-09-10 18:16:26 UTC (rev 3593)
@@ -1,3 +1,18 @@
+2010-09-10 Bernhard Herzog <bh at intevation.de>
+
+ * waskoweb/lib/search.py (CaseSearch.VALID_OPTIONS)
+ (CaseSearch.MULTI_OPTIONS): Add new "type_ending"
+ (CaseSearch.validate_form_params)
+ (CaseSearch.convert_form_parameters)
+ (CaseSearch.get_ending_clause, CaseSearch.get_where_subclauses):
+ New. Implement search for type of CM ending.
+
+ * waskoweb/templates/casemanagement/search_extra.mako: New.
+ Contains the template part of the type_ending search option.
+
+ * wasko.json: Add default values for the type_ending search
+ option. By default all possible values are matched.
+
2010-09-10 Roland Geider <roland.geider at intevation.de>
* waskoweb/public/formed/formedtree.xml: issue1019: missing warning
Modified: wasko/trunk/wasko.json
===================================================================
--- wasko/trunk/wasko.json 2010-09-10 15:38:46 UTC (rev 3592)
+++ wasko/trunk/wasko.json 2010-09-10 18:16:26 UTC (rev 3593)
@@ -62,13 +62,15 @@
"admin_defaults": [
{"search_str": "",
"state": [3, 4],
- "phase": [-1, 0, 1, 2, 3]}
+ "phase": [-1, 0, 1, 2, 3],
+ "type_ending": [-3, -1, 1, 2, 3]}
],
"cm_defaults": [
{"own": "1",
"search_str": "",
"state": [1],
- "phase": [-1, 0, 1, 2, 3]}
+ "phase": [-1, 0, 1, 2, 3],
+ "type_ending": [-3, -1, 1, 2, 3]}
]
},
"logbook": {
Modified: wasko/trunk/waskoweb/lib/search.py
===================================================================
--- wasko/trunk/waskoweb/lib/search.py 2010-09-10 15:38:46 UTC (rev 3592)
+++ wasko/trunk/waskoweb/lib/search.py 2010-09-10 18:16:26 UTC (rev 3593)
@@ -29,6 +29,9 @@
import logging
+from formencode import ForEach
+from formencode.validators import Int
+
from mpulsweb.lib.search import CaseSearch as CaseBaseSearch
@@ -38,11 +41,45 @@
class CaseSearch(CaseBaseSearch):
VALID_OPTIONS = (CaseBaseSearch.VALID_OPTIONS
- + ("gender",))
+ + ("gender", "type_ending"))
+ MULTI_OPTIONS = (CaseBaseSearch.MULTI_OPTIONS
+ + ("type_ending",))
# In wasko, the values for male and female are swapped.
wasko_gender_mapping = {"1": "0", "0": "1"}
+ def validate_form_params(self, params):
+ # FIXME: We import SearchCaseForm here because importing it
+ # during import doesn't work. The validators module performs
+ # translations and accesses app_globals during import, so it has
+ # to be imported when a HTTP-request is being handled. The
+ # search module is imported early on when the application starts
+ # so validators cannot be imported then.
+ from mpulsweb.lib.validators import SearchCaseForm
+ validator = SearchCaseForm(type_ending=ForEach(Int(),
+ convert_to_list=True))
+ return validator.to_python(params)
+
+ def convert_form_parameters(self, options, user, extended):
+ search = CaseBaseSearch.convert_form_parameters(self, options, user,
+ extended=extended)
+ if extended:
+ if "type_ending" in options:
+ search["type_ending"] = options["type_ending"]
+
+ return search
+
+ def get_ending_clause(self, options):
+ """Return the where subclause that selects based on CM ending.
+ If the type_ending option was not specified, any ending will be
+ OK, so this method returns 'TRUE'. Otherwise only endings
+ contained in the list value of the type_ending option will be
+ selected. If that list is empty, no ending will be OK, so no
+ case will be found.
+ """
+ return self.generic_int_choice_clause(options, "type_ending",
+ "m.cm_end_art")
+
def get_gender_clause(self, options):
gender = options.get("gender")
if gender is not None:
@@ -50,5 +87,10 @@
% self.wasko_gender_mapping.get(gender, gender))
return "TRUE"
+ def get_where_subclauses(self, options):
+ return CaseBaseSearch.get_where_subclauses(self, options) + [
+ self.get_ending_clause(options),
+ ]
+
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
Added: wasko/trunk/waskoweb/templates/casemanagement/search_extra.mako
===================================================================
--- wasko/trunk/waskoweb/templates/casemanagement/search_extra.mako 2010-09-10 15:38:46 UTC (rev 3592)
+++ wasko/trunk/waskoweb/templates/casemanagement/search_extra.mako 2010-09-10 18:16:26 UTC (rev 3593)
@@ -0,0 +1,17 @@
+## -*- coding: utf-8 -*-
+
+<tr style="${not c.extended_search and 'display:none' or ''}">
+ <td class="label">Art der Beendigung</td>
+ <td>
+ <input type="checkbox" value="-1" id="type_ending_-1" name="type_ending"/>
+ <label for="type_ending_-1">Keine Angabe</label><br/>
+ <input type="checkbox" value="-3" id="type_ending_-3" name="type_ending"/>
+ <label for="type_ending_-3">Unbekannt</label><br/>
+ <input type="checkbox" value="1" id="type_ending_1" name="type_ending"/>
+ <label for="type_ending_1">Erfolgreiche Reintegration in die Schule</label><br/>
+ <input type="checkbox" value="2" id="type_ending_2" name="type_ending"/>
+ <label for="type_ending_2">Sonstiges Beendigung</label><br/>
+ <input type="checkbox" value="3" id="type_ending_3" name="type_ending"/>
+ <label for="type_ending_3">Abbruch</label><br/>
+ </td>
+</tr>
More information about the Mpuls-commits
mailing list