[Mpuls-commits] r4629 - base/trunk/mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Feb 16 15:32:19 CET 2011
Author: torsten
Date: 2011-02-16 15:32:17 +0100 (Wed, 16 Feb 2011)
New Revision: 4629
Modified:
base/trunk/mpulsweb/lib/search.py
Log:
* mpulsweb/lib/search.py: Added handling of new optione federal_state.
In normal case search this will have no effect. In evaluation search
the search clause ws enhanced to match on the federal state if it is
provided.
Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py 2011-02-16 13:42:20 UTC (rev 4628)
+++ base/trunk/mpulsweb/lib/search.py 2011-02-16 14:32:17 UTC (rev 4629)
@@ -232,6 +232,10 @@
if phases:
search_options["phase"] = phases
+ # Federal state
+ if (options.get("federal_state") is not None):
+ search_options["federal_state"] = options.get("federal_state")
+
# Dates
if (options.get("sdate") is not None
and options.get("edate") is not None):
@@ -412,6 +416,12 @@
return "(%s)" % " OR ".join(phase_clauses)
return "FALSE"
+ def get_federalstate_clause(self, options):
+ """Return the search condition to select cases based on federal state.
+ Derived classes may override this method if necessary.
+ """
+ return "TRUE"
+
def get_status_clause(self, options):
"""Return the search condition to select cases based on status.
Derived classes may override this method if necessary.
@@ -441,6 +451,7 @@
self.get_editor_clause(options),
self.get_branch_clause(options),
self.get_phases_dates_clause(options),
+ self.get_federalstate_clause(options),
self.get_gender_clause(options),
]
@@ -506,8 +517,8 @@
VALID_OPTIONS = (Search.VALID_OPTIONS
+ ("state", "phase", "own", "standin", "editor", "branch",
- "sdate", "edate", "sort_field", "sort_order"))
- MULTI_OPTIONS = Search.MULTI_OPTIONS + ('state', 'phase')
+ "sdate", "edate", "sort_field", "sort_order", "federal_state"))
+ MULTI_OPTIONS = Search.MULTI_OPTIONS + ('state', 'phase', 'federal_state')
def __init__(self, retrieve_fields, match_fields):
@@ -531,6 +542,11 @@
return needle_expr % dict(needle=" ".join(search))
return "TRUE"
+ def get_federalstate_clause(self, options):
+ """Return the search condition to select cases based on federal state."""
+ if options.get('federal_state'):
+ return "f.bundesland_id IN ( %s )" % ",".join([str(x) for x in options.get('federal_state')])
+ return "TRUE"
def get_fields(self, options):
return self.SEARCH_FIELDS
More information about the Mpuls-commits
mailing list