[Mpuls-commits] r6086 - base/trunk/mpulsweb/controllers

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 2 11:35:58 CEST 2012


Author: roland
Date: 2012-10-02 11:35:58 +0200 (Tue, 02 Oct 2012)
New Revision: 6086

Modified:
   base/trunk/mpulsweb/controllers/settings.py
Log:
Add a pre save hook

This hook can be used by other applications to do something special with the
agency data. E.g. sending an email when the job percentage is changed (2066-5)


Modified: base/trunk/mpulsweb/controllers/settings.py
===================================================================
--- base/trunk/mpulsweb/controllers/settings.py	2012-10-02 09:34:11 UTC (rev 6085)
+++ base/trunk/mpulsweb/controllers/settings.py	2012-10-02 09:35:58 UTC (rev 6086)
@@ -52,6 +52,13 @@
                                                          'remindermaxdays'),
                                   not_empty=True)
                 }
+        
+        # Additional validator if the job_percentage is enabled, otherwise it
+        # will complain about missing values on applications that don't have
+        # the field
+        if g.mpuls_config.is_enabled('job_percentage', 'enabled'):
+            param["job_percentage"] = MaxMinInt() 
+        
         validator = self._get_settings_validator(param)
         c.agency = self._get_agency()
         try:
@@ -65,11 +72,20 @@
                                               defaults=c.form_result,
                                               auto_insert_errors=False,
                                               errors=c.form_errors)
-
+        
+        self.pre_save_hook(c.form_result)
+            
         c.agency.store(c.form_result)
         c.dialog_title = _('Configurations saved!')
         c.dialog_text = _('Please click on ok to continue.')
         c.url_ok = url(controller='settings', action='index')
         return render ('/settings/dialogs/success_edit.mako')
 
+    def pre_save_hook(self, form_data):
+        """
+        Customizable function, is called before saving the agency settings
+        """
+        
+        pass
+    
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list