[Mpuls-commits] r1343 - wasko/branches/2.0/waskaweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 9 09:52:30 CET 2010
Author: torsten
Date: 2010-02-09 09:52:29 +0100 (Tue, 09 Feb 2010)
New Revision: 1343
Removed:
wasko/branches/2.0/waskaweb/controllers/usersettings.py
Log:
Deleted old controller. Was moved to base.
Deleted: wasko/branches/2.0/waskaweb/controllers/usersettings.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/usersettings.py 2010-02-09 08:50:43 UTC (rev 1342)
+++ wasko/branches/2.0/waskaweb/controllers/usersettings.py 2010-02-09 08:52:29 UTC (rev 1343)
@@ -1,180 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
-#
-# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
-# Web-Anwendungs-Server fuer Kompetenzagenturen).
-#
-# mpuls WASKA is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Affero General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
-# License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
-#
-# mpuls WASKA has been developed on behalf of the
-# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
-# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
-# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
-# European Social Fund resources.
-#
-# Authors:
-# Torsten Irländer <torsten.irlaender at intevation.de>
-# Sascha L. Teichmann <teichmann at intevation.de>
-#
-
-import logging
-import formencode
-
-from mpulsweb.lib.base import BaseController, c, h, render, request, session, _
-
-from mpulsweb.lib.validators import BaseFormValidator, NewPasswordForm
-from mpulsweb.lib.security import checkRole
-
-from mpulsweb.model.user import UserListObject, UserObject, UserGroupList, \
- UserGroup
-
-
-log = logging.getLogger(__name__)
-
-
-SET_PASSWORD_NOTIFICATION_HEADER = u"""Benutzerpasswort geändert!"""
-SET_PASSWORD_NOTIFICATION_TEXT = u"""\
-Ihr Passwort wurde erfolgreich geändert. Bitte klicken Sie auf "OK",
-um fortzufahren."""
-
-EDIT_STANDIN_SUCCESS_HEADER = _('adm_edit_standin_success_header')
-EDIT_STANDIN_SUCCESS_TEXT = _('adm_edit_standin_success_text')
-
-
-class UsersettingsController(BaseController):
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr', 'pb_ka'))
- def index(self):
- # Return a rendered template
- # return render('/some/template.mako')
- # or, Return a response
- return 'Hello, User'
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr', 'pb_ka'))
- def showSettings(self, id):
- id = self._checkInt(id)
- c.uo = UserObject(id)
- c.vuo = UserGroup(c.uo.standin)
- return render('/usersettings/show_settings.mako')
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr', 'pb_ka'))
- def changePassword(self):
- c.form_errors = {}
- c.form_result = {}
- return render('/usersettings/change_password.mako')
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr', 'pb_ka'))
- def changePasswordAction(self):
- validator = NewPasswordForm()
- try:
- try:
- uid = request.params['uid']
- c.uo = UserObject(uid)
- form_result = validator.to_python(request.params)
- new_pass = c.uo.setPassword(form_result.get('passwd'))
- if new_pass:
- # Save new password in the session
- user = session['USER_AUTHORIZED']
- user.password = new_pass
- session['USER_AUTHORIZED'] = user
- session.save()
- c.success_for = SET_PASSWORD_NOTIFICATION_HEADER
- c.success_text = SET_PASSWORD_NOTIFICATION_TEXT
- c.url_ok = h.url_for(controller="usersettings",
- action="showSettings", id=user.id)
- else:
- return "Password could not be changed"
- except formencode.Invalid, error:
- c.form_result = error.value
- c.form_errors = error.error_dict or {}
- return render('/usersettings/change_password.mako')
- except:
- return render('/tests/trace.mako')
- return render('/usersettings/dialogs/notificate_setpassword.mako')
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr', 'pb_ka'))
- def changePasswordOnLogin(self):
- c.form_errors = {}
- c.form_result = {}
- return render('/usersettings/change_password_login.mako')
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr', 'pb_ka'))
- def changePasswordOnLoginAction(self):
- # Do not forget to unset the flag for the need for pass change if this
- # action succseeds
- validator = NewPasswordForm()
- try:
- try:
- form_result = validator.to_python(request.params)
- uo = UserObject(form_result.get('uid'))
- new_pass = uo.setPassword(form_result.get('passwd'))
- if new_pass:
- # Save new password in the session
- session_user = session['USER_AUTHORIZED']
- session_user.password = new_pass
- session_user.needs_passrefresh = False
- session['USER_AUTHORIZED'] = session_user
- session.save()
- c.success_for = SET_PASSWORD_NOTIFICATION_HEADER
- c.success_text = SET_PASSWORD_NOTIFICATION_TEXT
- c.url_ok = h.url_for(controller="usersettings",
- action="showSettings",
- id=session_user.id)
- else:
- return "Password could not be changed"
- except formencode.Invalid, error:
- c.form_result = error.value
- c.form_errors = error.error_dict or {}
- return render('/usersettings/change_password_login.mako')
- except:
- return render('/tests/trace.mako')
- return render('/usersettings/dialogs/notificate_setpassword.mako')
-
- @checkRole('cm_ka')
- def editStandin(self, id):
- id = self._checkInt(id)
- c.form_errors = {}
- c.form_result = {}
- ulo = UserListObject()
- ug = UserGroupList()
- c.uo = UserObject(id)
- user = session['USER_AUTHORIZED']
- # Get available users for standin. filter out admins and the current
- # user
- filter = [u.gid for u in ulo.getAdminList()]
- filter.append(user.gid)
- c.grouplist = ug.getGroupList(filter)
- return render('usersettings/edit_standin.mako')
-
- @checkRole('cm_ka')
- def editStandinAction(self):
- validator = BaseFormValidator()
- try:
- c.form_result = validator.to_python(request.params)
- c.uo = UserObject(c.form_result.get('uid'))
- c.uo.setStandin(c.form_result.get('standin') or None)
- #TODO: Update the value for the logged in session user
- except formencode.Invalid, error:
- c.form_result = error.value
- c.form_errors = error.error_dict or {}
- return render('usersettings/edit_standin.mako')
- c.success_for = EDIT_STANDIN_SUCCESS_HEADER
- c.success_text = EDIT_STANDIN_SUCCESS_TEXT
- uid = c.form_result.get('uid')
- c.url_ok = "/usersettings/showSettings/%s" % (uid)
- return render ('/usersettings/dialogs/success_edit_standin.mako')
- # return self.showSettings(c.form_result.get('uid'))
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list