[Mpuls-commits] r5968 - wasko/trunk/waskoweb/controllers

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue May 29 12:08:42 CEST 2012


Author: ludwig
Date: 2012-05-29 12:08:42 +0200 (Tue, 29 May 2012)
New Revision: 5968

Modified:
   wasko/trunk/waskoweb/controllers/settings.py
Log:
Use the new get_agency method to simplify the settings controllers.


Modified: wasko/trunk/waskoweb/controllers/settings.py
===================================================================
--- wasko/trunk/waskoweb/controllers/settings.py	2012-05-29 10:07:28 UTC (rev 5967)
+++ wasko/trunk/waskoweb/controllers/settings.py	2012-05-29 10:08:42 UTC (rev 5968)
@@ -1,15 +1,6 @@
 # -*- 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
-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
@@ -23,41 +14,5 @@
     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')
-    def edit(self):
-        c.form_errors = {}
-        c.agency = Agency()
-        c.form_result = c.agency.conf
-        form = render('/settings/edit.mako')
-        return formencode.htmlfill.render(form,
-                                          defaults=c.form_result,
-                                          auto_insert_errors=False,
-                                          errors=c.form_errors)
-       
-    
-    @checkRole('admin')
-    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 {}
-            form = render('/settings/edit.mako')
-            return formencode.htmlfill.render(form,
-                                              defaults=c.form_result,
-                                              auto_insert_errors=False,
-                                              errors=c.form_errors)
-
-        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 get_agency(self):
+        return Agency()



More information about the Mpuls-commits mailing list