[Mpuls-commits] r3211 - in wasko/trunk: . waskoweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jul 21 09:30:53 CEST 2010


Author: roland
Date: 2010-07-21 09:30:52 +0200 (Wed, 21 Jul 2010)
New Revision: 3211

Added:
   wasko/trunk/waskoweb/controllers/settings.py
Modified:
   wasko/trunk/ChangeLog
Log:
added file

Modified: wasko/trunk/ChangeLog
===================================================================
--- wasko/trunk/ChangeLog	2010-07-21 07:15:17 UTC (rev 3210)
+++ wasko/trunk/ChangeLog	2010-07-21 07:30:52 UTC (rev 3211)
@@ -1,5 +1,8 @@
 2010-07-20 Roland Geider <roland.geider at intevation.de>
+	* waskoweb/controllers/settings.py: added file
 
+2010-07-20 Roland Geider <roland.geider at intevation.de>
+
 	* waskoweb/public/formed/formedtree.xml: issue255: added free form
 	  documentation to section "Nachbetreuung"
 

Added: wasko/trunk/waskoweb/controllers/settings.py
===================================================================
--- wasko/trunk/waskoweb/controllers/settings.py	2010-07-21 07:15:17 UTC (rev 3210)
+++ wasko/trunk/waskoweb/controllers/settings.py	2010-07-21 07:30:52 UTC (rev 3211)
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+import logging
+import formencode
+
+from pylons import request, tmpl_context as c
+from mpulsweb.lib.translation import _
+
+from mpulsweb.lib.helpers import url_for
+from mpulsweb.lib.base import BaseController, render
+from mpulsweb.lib.validators import EditSettingsForm
+from mpulsweb.lib.security import checkRole
+
+from waskoweb.model.agencysettings import Agency
+
+from mpulsweb.controllers.settings import SettingsController
+
+log = logging.getLogger(__name__)
+
+
+EDIT_AGENCY_SUCCESS_HEADER = _('adm_edit_agency_header')
+EDIT_AGENCY_SUCCESS_TEXT = _('adm_edit_agency_text')
+
+
+
+class SettingsController(SettingsController):
+    """
+    Overwrite the Settings controller to use the wasko agency-settings model
+    in c.agency, all the logic is copy/pasted
+    """
+
+    def show(self):
+        c.form_errors = {}
+        c.form_result = {}
+        c.agency = Agency()
+        return render('/settings/show.mako')
+
+    @checkRole('admin_ka')
+    def edit(self):
+        c.form_errors = {}
+        c.form_result = {}
+        c.agency = Agency()
+        return render('/settings/edit.mako')
+    
+    @checkRole('admin_ka')
+    def editAction(self):
+        validator = EditSettingsForm()
+        c.agency = Agency()
+        try:
+            c.form_result = validator.to_python(request.params)
+        except formencode.Invalid, error:
+            c.form_result = error.value
+            c.form_errors = error.error_dict or {}
+            return render('/settings/edit.mako')
+
+        c.agency.store(c.form_result)
+        c.dialog_title = EDIT_AGENCY_SUCCESS_HEADER
+        c.dialog_text = EDIT_AGENCY_SUCCESS_TEXT
+        c.url_ok = url_for(controller='/settings')
+        return render ('/settings/dialogs/success_edit.mako')
\ No newline at end of file



More information about the Mpuls-commits mailing list