[Mpuls-commits] r1366 - wasko/branches/2.0/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 9 12:53:10 CET 2010
Author: torsten
Date: 2010-02-09 12:53:09 +0100 (Tue, 09 Feb 2010)
New Revision: 1366
Modified:
wasko/branches/2.0/mpulsweb/controllers/administration.py
Log:
* mpulsweb/controllers/administration.py
(AdministrationController.editUserGroupAction): Copied from
waskaweb. Adapted imports. Fixed dialog vars and removed try except
block.
Modified: wasko/branches/2.0/mpulsweb/controllers/administration.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/administration.py 2010-02-09 11:48:10 UTC (rev 1365)
+++ wasko/branches/2.0/mpulsweb/controllers/administration.py 2010-02-09 11:53:09 UTC (rev 1366)
@@ -7,9 +7,13 @@
from mpulsweb.lib.base import BaseController, render
from mpulsweb.lib.security import checkRole
+from mpulsweb.lib.validators import ValidatorStateObject, EditUserGroupForm
from mpulsweb.model.user import UserListObject, UserObject, UserGroupList, \
UserGroup, UserGroupFactory
+EDIT_USERGROUP_SUCCESS_HEADER = _('adm_edit_usergroup_header')
+EDIT_USERGROUP_SUCCESS_TEXT = _('adm_edit_usergroup_text')
+
log = logging.getLogger(__name__)
class AdministrationController(BaseController):
@@ -69,4 +73,36 @@
c.form_errors,
auto_insert_errors=False)
+ @checkRole('admin_ka')
+ def editUserGroupAction(self):
+ validator = EditUserGroupForm()
+ factory = UserGroupFactory()
+ userlist = UserListObject()
+ admins = userlist.getAdminList()
+ c.userlist = userlist.getUserList(filter=[u.id for u in admins])
+
+ try:
+ state = ValidatorStateObject
+ data = formencode.variabledecode.variable_decode(request.params)
+ state.groupid = data.get('id')
+ form_result = validator.to_python(data, state)
+ group = factory.load(form_result.get('id'))
+ group.setData(form_result)
+ group.setUser(form_result.get('standin'))
+ group.store()
+ c.group = group
+ c.dialog_title = EDIT_USERGROUP_SUCCESS_HEADER
+ c.dialog_text = EDIT_USERGROUP_SUCCESS_TEXT
+ c.url_ok = "/administration/overviewUserGroups"
+ return render('/administration/dialogs/success_edit_usergroup.mako')
+ except formencode.Invalid, error:
+ c.form_result = error.value
+ c.group = factory.load(c.form_result.get('id'))
+ c.form_errors = error.error_dict or {}
+ form = render('/administration/edit_usergroup.mako')
+ return htmlfill.render(unicode(form, 'utf-8'),
+ c.form_result,
+ c.form_errors,
+ auto_insert_errors=False)
+
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list