[Mpuls-commits] r1376 - wasko/branches/2.0/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 9 14:45:34 CET 2010


Author: torsten
Date: 2010-02-09 14:45:33 +0100 (Tue, 09 Feb 2010)
New Revision: 1376

Modified:
   wasko/branches/2.0/mpulsweb/controllers/administration.py
Log:
* mpulsweb/controllers/administration.py 
  (AdministrationController.newUserGroupAction): Copied from waskaweb.
  Removed try/except block. Changed c-vars for dialogs.


Modified: wasko/branches/2.0/mpulsweb/controllers/administration.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/administration.py	2010-02-09 13:39:39 UTC (rev 1375)
+++ wasko/branches/2.0/mpulsweb/controllers/administration.py	2010-02-09 13:45:33 UTC (rev 1376)
@@ -8,10 +8,16 @@
 
 from mpulsweb.lib.base import BaseController, render
 from mpulsweb.lib.security import checkRole
-from mpulsweb.lib.validators import ValidatorStateObject, EditUserGroupForm 
+from mpulsweb.lib.validators import ValidatorStateObject, NewUserGroupForm, \
+    EditUserGroupForm 
 from mpulsweb.model.user import UserListObject, UserObject, UserGroupList, \
     UserGroup, UserGroupFactory
 
+NEW_USERGROUP_SUCCESS_HEADER = _('adm_new_usergroup_success_header')
+NEW_USERGROUP_SUCCESS_TEXT = _('adm_new_usergroup_success_text')
+NEW_USERGROUP_FAILURE_HEADER = _('adm_new_usergroup_failure_header')
+NEW_USERGROUP_FAILURE_TEXT = _('adm_new_usergroup_failure_text')
+
 EDIT_USERGROUP_SUCCESS_HEADER = _('adm_edit_usergroup_header')
 EDIT_USERGROUP_SUCCESS_TEXT = _('adm_edit_usergroup_text')
 
@@ -51,6 +57,31 @@
         return render('/administration/new_usergroup.mako')
 
     @checkRole('admin_ka')
+    def newUserGroupAction(self):
+        factory = UserGroupFactory()
+        validator = NewUserGroupForm()
+        try:
+            c.form_result = validator.to_python(request.params)
+            c.ugo = factory.create(c.form_result.get('name'))
+            c.dialog_title = NEW_USERGROUP_SUCCESS_HEADER
+            c.dialog_text = NEW_USERGROUP_SUCCESS_TEXT
+            c.url_ok = "/administration/overviewUserGroups"
+            return render('/administration/dialogs/success_new_usergroup.mako')
+        except formencode.Invalid, error:
+            c.form_result = error.value
+            c.form_errors = error.error_dict or {}
+            form = render('/administration/new_usergroup.mako')
+            return htmlfill.render(unicode(form, 'utf-8'),
+                                   c.form_result,
+                                   c.form_errors,
+                                   auto_insert_errors=False)
+        except:
+            c.dialog_title = NEW_USERGROUP_FAILURE_HEADER
+            c.dialog_text = NEW_USERGOUP_FAILURE_TEXT
+            c.url_ok = "/administration/overviewUserGroups"
+            return render('/administration/dialogs/failed_new_usergroup.mako')
+
+    @checkRole('admin_ka')
     def showUserGroup(self, id=None):
         factory = UserGroupFactory()
         id = self._checkInt(id)



More information about the Mpuls-commits mailing list