[Mpuls-commits] r3502 - in base/trunk: . mpulsweb/controllers mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Aug 31 21:03:13 CEST 2010
Author: bh
Date: 2010-08-31 21:03:11 +0200 (Tue, 31 Aug 2010)
New Revision: 3502
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/controllers/case_bundle.py
base/trunk/mpulsweb/controllers/case_overview.py
base/trunk/mpulsweb/lib/search.py
Log:
* mpulsweb/controllers/case_bundle.py
(CaseBundleController._build_casebundle): Call parseSearchOptions
with the appropriate extended flag.
* mpulsweb/controllers/case_overview.py (parseSearchOptions)
(CaseOverviewController.parseSearchOptions): Add parameter
extended.
(CaseOverviewController.overview): Call parseSearchOptions with
the appropriate extended flag.
* mpulsweb/lib/search.py (CaseSearch.convert_form_parameters): New
option extended to indicate whether the search is an extended
search.
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2010-08-31 19:01:47 UTC (rev 3501)
+++ base/trunk/ChangeLog 2010-08-31 19:03:11 UTC (rev 3502)
@@ -1,5 +1,25 @@
2010-08-31 Bernhard Herzog <bh at intevation.de>
+ Only consider the extended search options when showing the
+ extended search interface to the user. At the same time, try not
+ lose the extended search options selected by the user.
+
+ * mpulsweb/lib/search.py (CaseSearch.convert_form_parameters): New
+ option extended to indicate whether the search is an extended
+ search.
+
+ * mpulsweb/controllers/case_bundle.py
+ (CaseBundleController._build_casebundle): Call parseSearchOptions
+ with the appropriate extended flag.
+
+ * mpulsweb/controllers/case_overview.py (parseSearchOptions)
+ (CaseOverviewController.parseSearchOptions): Add parameter
+ extended.
+ (CaseOverviewController.overview): Call parseSearchOptions with
+ the appropriate extended flag.
+
+2010-08-31 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/lib/search.py (CaseSearch.get_dates_clause): The
options dictionary might not contain the "phase" key.
Modified: base/trunk/mpulsweb/controllers/case_bundle.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_bundle.py 2010-08-31 19:01:47 UTC (rev 3501)
+++ base/trunk/mpulsweb/controllers/case_bundle.py 2010-08-31 19:03:11 UTC (rev 3502)
@@ -229,7 +229,8 @@
# option again as they are not included in the submitted
# data.
search_options = search_options_from_session()
- search = parseSearchOptions(search_options)
+ search = parseSearchOptions(search_options,
+ extended=session.get("EXTENDED_SEARCH"))
case_bundle = MpulsCaseBundle([case.id for case in
MpulsCaseOverview().search(search)])
else:
Modified: base/trunk/mpulsweb/controllers/case_overview.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_overview.py 2010-08-31 19:01:47 UTC (rev 3501)
+++ base/trunk/mpulsweb/controllers/case_overview.py 2010-08-31 19:03:11 UTC (rev 3502)
@@ -43,11 +43,11 @@
phases.append(-1)
return phases
-def parseSearchOptions(options):
+def parseSearchOptions(options, extended):
return g.case_search.convert_form_parameters(options,
- session['USER_AUTHORIZED'])
+ session['USER_AUTHORIZED'],
+ extended=extended)
-
def search_options_from_session():
options = session.get('CASE_OVERVIEW_SEARCHOPTIONS')
if options:
@@ -91,7 +91,8 @@
search_options = search_options_from_session()
session['CASE_OVERVIEW_SEARCHOPTIONS'] = search_options
session.save()
- search = self.parseSearchOptions(search_options)
+ search = self.parseSearchOptions(search_options,
+ extended=session.get("EXTENDED_SEARCH"))
# Sorting the cases
search.update(self.parseSortOptions(request.params))
@@ -169,7 +170,7 @@
return dict(sort_field=sort_field,
sort_order=sort_order)
- def parseSearchOptions(self, options=None):
- return parseSearchOptions(options)
+ def parseSearchOptions(self, options, extended):
+ return parseSearchOptions(options, extended)
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py 2010-08-31 19:01:47 UTC (rev 3501)
+++ base/trunk/mpulsweb/lib/search.py 2010-08-31 19:03:11 UTC (rev 3502)
@@ -188,9 +188,12 @@
from mpulsweb.lib.validators import SearchCaseForm
return SearchCaseForm().to_python(params)
- def convert_form_parameters(self, options, user):
+ def convert_form_parameters(self, options, user, extended):
"""Convert form parameters to search options.
The parameter user is the user object for the current user.
+ If extended is true, the search is an extended search, otherwise
+ it's the more limited default search. In the limited default
+ search, some options are not included in the return value.
"""
search_options = dict()
@@ -216,30 +219,32 @@
if options.get("editor") and options.get("editor") != -1:
search_options["editor"] = options.get("editor")
- # Phase
- if "phase" in options:
- # Get phasepart ids for the selected phasepairs. Only if
- # pairs are defined.
- pairs = g.mpuls_config.get("phases", "pairs")
- if pairs:
- phases = []
- for pp in options["phase"]:
- phases.extend((int(p) for p in pairs[0].get(str(pp), [-1])))
- search_options["phase"] = phases
+ if extended:
+ # Phase
+ if "phase" in options:
+ # Get phasepart ids for the selected phasepairs. Only if
+ # pairs are defined.
+ pairs = g.mpuls_config.get("phases", "pairs")
+ if pairs:
+ phases = []
+ for pp in options["phase"]:
+ phases.extend((int(p) for p in pairs[0].get(str(pp),
+ [-1])))
+ search_options["phase"] = phases
- # Dates
- if (options.get("sdate") is not None
- and options.get("edate") is not None):
- search_options["sdate"] = options.get("sdate")
- search_options["edate"] = options.get("edate")
+ # Dates
+ if (options.get("sdate") is not None
+ and options.get("edate") is not None):
+ search_options["sdate"] = options.get("sdate")
+ search_options["edate"] = options.get("edate")
- # gender
- if options.get("gender", -2) != -2:
- search_options["gender"] = options["gender"]
+ # gender
+ if options.get("gender", -2) != -2:
+ search_options["gender"] = options["gender"]
- # branch office
- if options.get("branch"):
- search_options["branch"] = options["branch"]
+ # branch office
+ if options.get("branch"):
+ search_options["branch"] = options["branch"]
return search_options
More information about the Mpuls-commits
mailing list