[Mpuls-commits] r3511 - in waska/trunk: . waskaweb/lib waskaweb/templates/casemanagement
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 1 18:31:38 CEST 2010
Author: bh
Date: 2010-09-01 18:31:38 +0200 (Wed, 01 Sep 2010)
New Revision: 3511
Added:
waska/trunk/waskaweb/templates/casemanagement/search_extra.mako
Modified:
waska/trunk/ChangeLog
waska/trunk/waska.json
waska/trunk/waskaweb/lib/search.py
Log:
* waska.json: Add default values for the type_ending search
option. By default all possible values are matched.
* waskaweb/lib/search.py (CaseSearch.validate_form_params)
(CaseSearch.convert_form_parameters)
(CaseSearch.get_ending_clause, CaseSearch.get_where_subclauses):
New. Implement search for type of CM ending.
(CaseSearch.VALID_OPTIONS, CaseSearch.MULTI_OPTIONS): Add
"type_ending"
* waskaweb/templates/casemanagement/search_extra.mako: New.
Contains the template part of the type_ending search option.
Modified: waska/trunk/ChangeLog
===================================================================
--- waska/trunk/ChangeLog 2010-09-01 14:22:10 UTC (rev 3510)
+++ waska/trunk/ChangeLog 2010-09-01 16:31:38 UTC (rev 3511)
@@ -1,3 +1,18 @@
+2010-09-01 Bernhard Herzog <bh at intevation.de>
+
+ * waskaweb/lib/search.py (CaseSearch.validate_form_params)
+ (CaseSearch.convert_form_parameters)
+ (CaseSearch.get_ending_clause, CaseSearch.get_where_subclauses):
+ New. Implement search for type of CM ending.
+ (CaseSearch.VALID_OPTIONS, CaseSearch.MULTI_OPTIONS): Add
+ "type_ending"
+
+ * waskaweb/templates/casemanagement/search_extra.mako: New.
+ Contains the template part of the type_ending search option.
+
+ * waska.json: Add default values for the type_ending search
+ option. By default all possible values are matched.
+
2010-09-01 Frank Koormann <frank.koormann at intevation.de>
* waska.json: issue10004: Adapted item order to WASKA 1.7.1.
Modified: waska/trunk/waska.json
===================================================================
--- waska/trunk/waska.json 2010-09-01 14:22:10 UTC (rev 3510)
+++ waska/trunk/waska.json 2010-09-01 16:31:38 UTC (rev 3511)
@@ -64,13 +64,17 @@
"admin_defaults": [
{"search_str": "",
"state": [3, 4],
- "phase": [-1, 0, 1, 2, 3]}
+ "phase": [-1, 0, 1, 2, 3],
+ "type_ending": [-3, -1, 0, 1, 2]
+ }
],
"cm_defaults": [
{"own": "1",
"search_str": "",
"state": [1],
- "phase": [-1, 0, 1, 2, 3]}
+ "phase": [-1, 0, 1, 2, 3],
+ "type_ending": [-3, -1, 0, 1, 2]
+ }
]
},
"logbook": {
Modified: waska/trunk/waskaweb/lib/search.py
===================================================================
--- waska/trunk/waskaweb/lib/search.py 2010-09-01 14:22:10 UTC (rev 3510)
+++ waska/trunk/waskaweb/lib/search.py 2010-09-01 16:31:38 UTC (rev 3511)
@@ -29,6 +29,9 @@
import logging
+from formencode import ForEach
+from formencode.validators import Int
+
from mpulsweb.lib.search import CaseSearch as CaseBaseSearch
@@ -38,12 +41,51 @@
class CaseSearch(CaseBaseSearch):
VALID_OPTIONS = (CaseBaseSearch.VALID_OPTIONS
- + ("gender",))
+ + ("gender", "type_ending"))
+ MULTI_OPTIONS = (CaseBaseSearch.MULTI_OPTIONS
+ + ("type_ending",))
+ 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.art_beendigung")
+
def get_gender_clause(self, options):
gender = options.get("gender")
if gender is not None:
return "m.geschlecht = %s" % 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: waska/trunk/waskaweb/templates/casemanagement/search_extra.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/search_extra.mako 2010-09-01 14:22:10 UTC (rev 3510)
+++ waska/trunk/waskaweb/templates/casemanagement/search_extra.mako 2010-09-01 16:31:38 UTC (rev 3511)
@@ -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="2" id="type_ending_2" name="type_ending"/>
+ <label for="type_ending_2">vorzeitige Beendigung</label><br/>
+ <input type="checkbox" value="0" id="type_ending_0" name="type_ending"/>
+ <label for="type_ending_0">reguläre Beendigung</label><br/>
+ <input type="checkbox" value="1" id="type_ending_1" name="type_ending"/>
+ <label for="type_ending_1">Abbruch</label><br/>
+ </td>
+</tr>
More information about the Mpuls-commits
mailing list