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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 9 17:48:33 CET 2010


Author: torsten
Date: 2010-02-09 17:48:32 +0100 (Tue, 09 Feb 2010)
New Revision: 1423

Modified:
   wasko/branches/2.0/mpulsweb/controllers/administration.py
Log:
* mpulsweb/controllers/administration.py
(AdministrationController.newUserAction): Copied from waskaweb.
Removed try/except block as we do not want to display traceback


Modified: wasko/branches/2.0/mpulsweb/controllers/administration.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/administration.py	2010-02-09 16:22:46 UTC (rev 1422)
+++ wasko/branches/2.0/mpulsweb/controllers/administration.py	2010-02-09 16:48:32 UTC (rev 1423)
@@ -7,11 +7,11 @@
 from pylons.controllers.util import abort, redirect_to
 
 from mpulsweb.lib.base import BaseController, render
-from mpulsweb.lib.security import checkRole
+from mpulsweb.lib.security import checkRole, getDbName
 from mpulsweb.lib.validators import ValidatorStateObject, NewUserGroupForm, \
     EditUserGroupForm 
 from mpulsweb.model.user import UserListObject, UserObject, UserGroupList, \
-    UserGroup, UserGroupFactory
+    UserGroup, UserGroupFactory, NewUserForm
 
 NEW_USERGROUP_SUCCESS_HEADER = _('adm_new_usergroup_success_header')
 NEW_USERGROUP_SUCCESS_TEXT = _('adm_new_usergroup_success_text')
@@ -44,6 +44,31 @@
         return render('/administration/new_user.mako')
 
     @checkRole('admin_ka')
+    def newUserAction(self):
+        validator = NewUserForm()
+        c.user_password = None
+        try:
+            agency = getDbName()
+            state = ValidatorStateObject
+            state.agency = agency
+            c.form_result = validator.to_python(request.params, state)
+            c.uo = UserObject()
+            # Set initial data which is needed to create a new user
+            login = c.form_result.get('login', '')
+            role = c.form_result.get('role', '')
+            c.uo.setData(c.form_result)
+            # create user
+            c.user_password = c.uo.createLogin(login, role, agency)
+            return render('/administration/new_user_result.mako')
+        except formencode.Invalid, error:
+            c.form_result = error.value
+            c.form_errors = error.error_dict or {}
+            form = render('/administration/new_user.mako')
+            return formencode.htmlfill.render(unicode(form, 'utf-8'),
+                                   c.form_result, c.form_errors,
+                                   auto_insert_errors=False)
+
+    @checkRole('admin_ka')
     def showUser(self, id=None):
         id = self._checkInt(id)
         c.uo = UserObject(id)
@@ -86,7 +111,8 @@
                                    c.form_result,
                                    c.form_errors,
                                    auto_insert_errors=False)
-        except:
+        except Exception, e:
+            log.exception(e)
             c.dialog_title = NEW_USERGROUP_FAILURE_HEADER
             c.dialog_text = NEW_USERGOUP_FAILURE_TEXT
             c.url_ok = "/administration/overviewUserGroups"



More information about the Mpuls-commits mailing list