[Mpuls-commits] r5973 - in base/trunk/mpulsweb: controllers lib

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue May 29 14:08:22 CEST 2012


Author: ludwig
Date: 2012-05-29 14:08:21 +0200 (Tue, 29 May 2012)
New Revision: 5973

Modified:
   base/trunk/mpulsweb/controllers/settings.py
   base/trunk/mpulsweb/lib/validators.py
Log:
Issue 979: Move the max_reminder validator into the editAction.
To generate the EditSettingForm validator two values from app_globals 
are used.


Modified: base/trunk/mpulsweb/controllers/settings.py
===================================================================
--- base/trunk/mpulsweb/controllers/settings.py	2012-05-29 11:47:58 UTC (rev 5972)
+++ base/trunk/mpulsweb/controllers/settings.py	2012-05-29 12:08:21 UTC (rev 5973)
@@ -2,12 +2,12 @@
 import logging
 import formencode
 
-from pylons import request, tmpl_context as c
+from pylons import request, tmpl_context as c, app_globals as g
 from mpulsweb.lib.translation import _
 
 from mpulsweb.lib.helpers import url
 from mpulsweb.lib.base import BaseController, render
-from mpulsweb.lib.validators import EditSettingsForm
+from mpulsweb.lib.validators import EditSettingsForm, MaxMinInt
 from mpulsweb.lib.security import checkRole
 from mpulsweb.model.agencysettings import Agency
 
@@ -24,8 +24,8 @@
     def _get_agency(self):
         return Agency()
 
-    def _get_settings_validator(self):
-        return EditSettingsForm()
+    def _get_settings_validator(self, param):
+        return EditSettingsForm(**param)
 
     def show(self):
         c.form_errors = {}
@@ -46,7 +46,13 @@
 
     @checkRole('admin')
     def editAction(self):
-        validator = self._get_settings_validator()
+        param = {"max_speicherdauer":MaxMinInt(min=g.mpuls_config.get('case',
+                                                         'remindermindays'),
+                                  max=g.mpuls_config.get('case',
+                                                         'remindermaxdays'),
+                                  not_empty=True)
+                }
+        validator = self._get_settings_validator(param)
         c.agency = self._get_agency()
         try:
             c.form_result = validator.to_python(request.params)

Modified: base/trunk/mpulsweb/lib/validators.py
===================================================================
--- base/trunk/mpulsweb/lib/validators.py	2012-05-29 11:47:58 UTC (rev 5972)
+++ base/trunk/mpulsweb/lib/validators.py	2012-05-29 12:08:21 UTC (rev 5973)
@@ -10,7 +10,6 @@
      StringBoolean, DateConverter, TimeConverter, FormValidator, MaxLength, \
      FileUploadKeeper, OneOf, Wrapper, Regex
 
-from pylons import app_globals as g
 from mpulsweb.lib.translation import _
 
 from mpulsweb.lib.db import db
@@ -620,13 +619,7 @@
 class EditSettingsForm(BaseFormValidator):
 
     anon_transfer = String(if_missing='off')
-    max_speicherdauer = MaxMinInt(min=g.mpuls_config.get('case',
-                                                         'remindermindays'),
-                                  max=g.mpuls_config.get('case',
-                                                         'remindermaxdays'),
-                                  not_empty=True)
 
-
 class NewPasswordForm(BaseFormValidator):
 
     passwd = SecurePassword()



More information about the Mpuls-commits mailing list