[Mpuls-commits] r3951 - in base/trunk: . mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 8 22:04:32 CEST 2010


Author: bh
Date: 2010-10-08 22:04:31 +0200 (Fri, 08 Oct 2010)
New Revision: 3951

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/evaluate.py
Log:
* mpulsweb/controllers/evaluate.py (get_search_options): Refactor
to make handling of the default values clearer.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-10-08 20:00:05 UTC (rev 3950)
+++ base/trunk/ChangeLog	2010-10-08 20:04:31 UTC (rev 3951)
@@ -1,5 +1,10 @@
 2010-10-08  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/controllers/evaluate.py (get_search_options): Refactor
+	to make handling of the default values clearer.
+
+2010-10-08  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/validators.py (MyDateConverter.unconvert_day): New.
 	Called by the from_python method to convert back from a python
 	date object to the string representation.

Modified: base/trunk/mpulsweb/controllers/evaluate.py
===================================================================
--- base/trunk/mpulsweb/controllers/evaluate.py	2010-10-08 20:00:05 UTC (rev 3950)
+++ base/trunk/mpulsweb/controllers/evaluate.py	2010-10-08 20:04:31 UTC (rev 3951)
@@ -65,22 +65,20 @@
 def get_search_options(soptions=None, id=None, selected_ids=()):
     options = {}
     options['id'] = id
-    if soptions:
-        options['start_date'] = soptions.get('start_date') or \
-            g.mpuls_config.get('search', 'default-start-date')
-        options['end_date'] = soptions.get('end_date') or \
-            g.mpuls_config.get('search', 'default-end-date')
-        phase = [int(p) for p in soptions.get('phase')]
-        options['phase'] = max(phase) #TODO: Why max?
-    else:
-        # set default evaluation options.
-        options['phase'] = g.mpuls_config.get('evaluations', 'default-phases')
-        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()
 
+    # set default evaluation options.
+    options['phase'] = g.mpuls_config.get('evaluations', 'default-phases')
+    options['start_date'] = g.mpuls_config.get('search', 'default-start-date')
+    options['end_date'] = g.mpuls_config.get('search', 'default-end-date')
+
+    # copy options from soptions if included there
+    if soptions:
+        for name in ["start_date", "end_date", "phase"]:
+            if name in soptions:
+                options[name] = soptions[name]
+
     # convert dates to locale
     options['start_date'] = format_date(options['start_date'])
     options['end_date'] = format_date(options['end_date'])



More information about the Mpuls-commits mailing list