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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue May 24 13:14:25 CEST 2011


Author: bh
Date: 2011-05-24 13:14:24 +0200 (Tue, 24 May 2011)
New Revision: 4994

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/evaluate.py
Log:
* mpulsweb/controllers/evaluate.py (get_default_adele_options):
New. Like get_default_options, but for "adele" evaluations.
(EvaluateController.evaluate): Rework how the various option
sources are combined into one set of options. In particular, the
case of "adele" evaluations has to be changed, so that the
predefined defaults (and not just the phase) are always used,
regardless of what the user has used earlier for other
evaluations.
Fixes part of mpuls/issue1744


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-05-24 10:56:27 UTC (rev 4993)
+++ base/trunk/ChangeLog	2011-05-24 11:14:24 UTC (rev 4994)
@@ -1,5 +1,17 @@
 2011-05-24  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/controllers/evaluate.py (get_default_adele_options):
+	New. Like get_default_options, but for "adele" evaluations.
+	(EvaluateController.evaluate): Rework how the various option
+	sources are combined into one set of options. In particular, the
+	case of "adele" evaluations has to be changed, so that the
+	predefined defaults (and not just the phase) are always used,
+	regardless of what the user has used earlier for other
+	evaluations.
+	Fixes part of mpuls/issue1744
+
+2011-05-24  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/controllers/evaluate.py (get_common_options): Pass
 	evalconfig as a parameter instead of relying on it being in the c
 	object. This makes the dependency clearer.

Modified: base/trunk/mpulsweb/controllers/evaluate.py
===================================================================
--- base/trunk/mpulsweb/controllers/evaluate.py	2011-05-24 10:56:27 UTC (rev 4993)
+++ base/trunk/mpulsweb/controllers/evaluate.py	2011-05-24 11:14:24 UTC (rev 4994)
@@ -56,7 +56,17 @@
                                                    'default-start-date'),
                 end_date=g.mpuls_config.get_date('search', 'default-end-date'))
 
+def get_default_adele_options():
+    """Return a dictionary with the default evaluation options for 'adele'.
+    It has the same contents as the one returned by
+    get_default_options() except for the phase which is taken from the
+    'evaluations', 'adele-phases' configuration option.
+    """
+    options = get_default_options()
+    options["phase"] = g.mpuls_config.get('evaluations', 'adele-phases')
+    return options
 
+
 def get_common_options(evalconfig, id, selected_ids):
     """Return a dictionary with common evaluation options.
 
@@ -105,22 +115,26 @@
     def evaluate(self, id=None):
         c.evalconfig = EvaluationConfig(get_configfile(id), None, None, None,
                                         None, None, None, None, None)
-        evaloptions = get_default_options()
-        evaloptions.update(get_common_options(c.evalconfig, id,
-                                              session.get("evaluation_ids",())))
-        evaloptions.update(get_session_options())
+        common_options = get_common_options(c.evalconfig, id,
+                                            session.get("evaluation_ids", ()))
 
-        # If user selects adele-evaluation render page with disabled
-        # configuration elements.  Change default params
-        if id == '0':
-            evaloptions['phase'] = g.mpuls_config.get('evaluations',
-                                                      'adele-phases')
+        if id == "0":
+            # If user selects adele-evaluation render page with disabled
+            # configuration elements and use different default options
+            # and no session options.
             c.adele_evaluation = True
+            option_sources = [common_options, get_default_adele_options()]
         else:
             c.adele_evaluation = False
+            option_sources  = [get_default_options(), common_options,
+                               get_session_options()]
 
+        evaloptions = dict()
+        for options in option_sources:
+            evaloptions.update(options)
+        defaults = EvaluationFormValidator().from_python(evaloptions)
+
         c.phases = PhaseFactory().build()
-        defaults = EvaluationFormValidator().from_python(evaloptions)
         form = render('/evaluation/evaluate.mako')
         return formencode.htmlfill.render(form, defaults=defaults,
                                           errors={}, auto_insert_errors=False)



More information about the Mpuls-commits mailing list