[Mpuls-commits] r1338 - in wasko/branches/2.0: . mpulsweb/controllers mpulsweb/templates mpulsweb/templates/administration mpulsweb/templates/dialogs mpulsweb/templates/usersettings mpulsweb/templates/usersettings/dialogs

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


Author: torsten
Date: 2010-02-09 09:22:41 +0100 (Tue, 09 Feb 2010)
New Revision: 1338

Added:
   wasko/branches/2.0/mpulsweb/controllers/usersettings.py
   wasko/branches/2.0/mpulsweb/templates/administration/
   wasko/branches/2.0/mpulsweb/templates/administration/show_user_body.mako
   wasko/branches/2.0/mpulsweb/templates/dialogs/
   wasko/branches/2.0/mpulsweb/templates/dialogs/success.mako
   wasko/branches/2.0/mpulsweb/templates/usersettings/
   wasko/branches/2.0/mpulsweb/templates/usersettings/change_password.mako
   wasko/branches/2.0/mpulsweb/templates/usersettings/dialogs/
   wasko/branches/2.0/mpulsweb/templates/usersettings/dialogs/notificate_setpassword.mako
   wasko/branches/2.0/mpulsweb/templates/usersettings/dialogs/success_edit_standin.mako
   wasko/branches/2.0/mpulsweb/templates/usersettings/edit_standin.mako
   wasko/branches/2.0/mpulsweb/templates/usersettings/show_settings.mako
Modified:
   wasko/branches/2.0/ChangeLog
Log:
Moved usersettings to base.
* mpulsweb/controllers/usersettings.py: Copied from waskaweb
* mpulsweb/templates/usersettings,
  mpulsweb/templates/usersettings/dialogs,
  mpulsweb/templates/usersettings/dialogs/success_edit_standin.mako,
  mpulsweb/templates/usersettings/dialogs/notificate_setpassword.mako,
  mpulsweb/templates/usersettings/show_settings.mako,
  mpulsweb/templates/usersettings/edit_standin.mako,
  mpulsweb/templates/usersettings/change_password.mako,
  mpulsweb/templates/dialogs,
  mpulsweb/templates/dialogs/success.mako,
  mpulsweb/templates/administration,
  mpulsweb/templates/administration/show_user_body.mako: Copied
  templates from waskaweb. And adapted links



Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-08 16:27:03 UTC (rev 1337)
+++ wasko/branches/2.0/ChangeLog	2010-02-09 08:22:41 UTC (rev 1338)
@@ -1,3 +1,21 @@
+2010-02-09  Torsten Irländer <torsten.irlaender at intevation.de>
+
+	Moved usersettings to base.
+
+	* mpulsweb/controllers/usersettings.py: Copied from waskaweb
+	* mpulsweb/templates/usersettings,
+	  mpulsweb/templates/usersettings/dialogs,
+	  mpulsweb/templates/usersettings/dialogs/success_edit_standin.mako,
+	  mpulsweb/templates/usersettings/dialogs/notificate_setpassword.mako,
+	  mpulsweb/templates/usersettings/show_settings.mako,
+	  mpulsweb/templates/usersettings/edit_standin.mako,
+	  mpulsweb/templates/usersettings/change_password.mako,
+	  mpulsweb/templates/dialogs,
+	  mpulsweb/templates/dialogs/success.mako,
+	  mpulsweb/templates/administration,
+	  mpulsweb/templates/administration/show_user_body.mako: Copied
+	  templates from waskaweb.
+
 2010-02-08  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	Copied resposible.mako and help.mako to new locations.
@@ -18,6 +36,20 @@
 	blackboard. Set app title from config in navipath and menus. Make
 	Casemanagement configurabel (endable/disable)
 
+
+	* mpulsweb/lib/validators.py: New. Copied BaseFormValidator,
+	SecurePassword, NewPasswordForm from waskaweb.lib.validators.
+
+	* waskaweb/lib/validators.py (BaseFormValidator): Deleted. Now
+	imported from mpulsweb. 
+	* waskaweb/lib/validators.py (NewPasswordForm): Deleted. Now imported
+	from mpulsweb
+	* waskaweb/lib/validators.py (SecurePassword): Deleted not used here
+	anymore. 
+
+	* mpulsweb/templates/usersettings/edit_standin.mako: Call
+	usersettings/showSettings to return to the usersettings page 
+
 2010-02-08  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	Added default templates for help
@@ -104,6 +136,8 @@
 	* mpulsweb/templates/main.mako: Inherit from base.mako
 	* mpulsweb/controllers/mpuls.py (MpulsController.index): Return
 	  main.mako
+	* waskaweb/controllers/usersettings.py: Import validators and base
+	  from mpulsweb. 
 
 	* mpulsweb/templates/base.mako: New. Common to all template files.
 	  Mainly the header definition.

Copied: wasko/branches/2.0/mpulsweb/controllers/usersettings.py (from rev 1336, wasko/branches/2.0/waskaweb/controllers/usersettings.py)
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/usersettings.py	2010-02-08 16:22:07 UTC (rev 1336)
+++ wasko/branches/2.0/mpulsweb/controllers/usersettings.py	2010-02-09 08:22:41 UTC (rev 1338)
@@ -0,0 +1,179 @@
+# -*- 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.dialog_title = SET_PASSWORD_NOTIFICATION_HEADER
+                    c.dialog_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.dialog_title = EDIT_STANDIN_SUCCESS_HEADER
+        c.dialog_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')
+
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:


Property changes on: wasko/branches/2.0/mpulsweb/controllers/usersettings.py
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: wasko/branches/2.0/mpulsweb/templates/administration/show_user_body.mako (from rev 1319, wasko/branches/2.0/waskaweb/templates/administration/show_user_body.mako)


Property changes on: wasko/branches/2.0/mpulsweb/templates/administration/show_user_body.mako
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: wasko/branches/2.0/mpulsweb/templates/dialogs/success.mako (from rev 1319, wasko/branches/2.0/waskaweb/templates/dialogs/success.mako)
===================================================================
--- wasko/branches/2.0/waskaweb/templates/dialogs/success.mako	2010-02-08 12:06:10 UTC (rev 1319)
+++ wasko/branches/2.0/mpulsweb/templates/dialogs/success.mako	2010-02-09 08:22:41 UTC (rev 1338)
@@ -0,0 +1,7 @@
+## -*- coding: utf-8 -*-
+<%!  import mpulsweb.lib.helper.filters as F %>
+<div class="dialog" />
+<h1><img src="/images/confirmation.png" alt="Erledigt"/>${c.dialog_title | F.NA, h}</h1>
+<p>${c.dialog_text | F.NA, h}</p>
+<a class="button" href="${c.url_ok}">${_('dialog_header_confirm_option_ok')}</a>
+</div>


Property changes on: wasko/branches/2.0/mpulsweb/templates/dialogs/success.mako
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: wasko/branches/2.0/mpulsweb/templates/usersettings/change_password.mako (from rev 1319, wasko/branches/2.0/waskaweb/templates/usersettings/change_password.mako)
===================================================================
--- wasko/branches/2.0/waskaweb/templates/usersettings/change_password.mako	2010-02-08 12:06:10 UTC (rev 1319)
+++ wasko/branches/2.0/mpulsweb/templates/usersettings/change_password.mako	2010-02-09 08:22:41 UTC (rev 1338)
@@ -0,0 +1,55 @@
+## -*- coding: utf-8 -*-
+<%inherit file="../main.mako" />
+<%def name="buildNavipath()">
+  <li><a href="#" onclick="return checkModification();">${_('sm_menu_link_settings')}</a></li>
+  <li><a href="#" onclick="return checkModification();">${_('adm_header_changepassword')}
+</a></li>
+</%def>
+<%
+  formular_labels = {'passwd'    : 'adm_form_newuser_passwd',
+                      'passwd2'   : 'adm_form_newuser_passwd_confirm'
+                      }
+%>
+<div id="content_header_small">
+  <div id="content_ueberschrift">
+ ${_('adm_header_changepassword')}
+  </div>
+  <div id="modusfield">
+    <div class="actions">
+	<ul>
+		<li><a href="${h.url_for(controller='usersettings', action='showSettings', id=h.getUserId())}"> ${_('sm_menu_link_settings_back')}</a></li>
+	</ul>
+    </div>
+  </div>
+</div>
+${self.buildFormErrors(formular_labels)}
+<div id="waska_form" class="import_box">
+<p class="import_p">Das neue Passwort muss aus mindestens acht Zeichen bestehen und zwei Nicht-Buchstaben enthalten. </p>
+<div class="import_box_dialog">
+<form action="${h.url_for(controller="usersettings", action="changePasswordAction")}" method="POST">
+<div>
+  % if c.form_errors.get('passwd'):
+    <label class="import_label" for="passwd" class="error_font"><strong class="import_number">1. </strong>${_('adm_form_newuser_passwd')}:</label>
+    <input type="password" class="field error_box" id="passwd" name="passwd">
+  % else:
+    <label class="import_label" for="passwd"><strong class="import_number">1. </strong>${_('adm_form_newuser_passwd')}:</label>
+    <input type="password" class="field" id="passwd" name="passwd">
+  % endif
+</div>
+<div>
+  % if c.form_errors.get('passwd2'):
+    <label class="import_label" for="passwd2" class="error_font"><strong class="import_number">2. </strong>${_('adm_form_newuser_passwd_confirm')}:</label>
+    <input type="password" class="field error_box" id="passwd2" name="passwd2">
+  % else:
+    <label class="import_label" for="passwd2"><strong class="import_number">2. </strong>${_('adm_form_newuser_passwd_confirm')}:</label>
+    <input type="password" class="field" id="passwd2" name="passwd2">
+  % endif
+</div>
+<div>
+  <input type="hidden" name="uid" value="${h.getUserId()}">
+  <label class="import_label" for="passwd2"><strong class="import_number">3. </strong>Neues Passwort speichern:</label>
+  <input id="account_pw_sub" class="btn_space" type="submit" value="${_('adm_form_changepassword_submit')}">
+</div>
+</form>
+</div>
+</div>


Property changes on: wasko/branches/2.0/mpulsweb/templates/usersettings/change_password.mako
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: wasko/branches/2.0/mpulsweb/templates/usersettings/dialogs/notificate_setpassword.mako (from rev 1319, wasko/branches/2.0/waskaweb/templates/usersettings/dialogs/notificate_setpassword.mako)


Property changes on: wasko/branches/2.0/mpulsweb/templates/usersettings/dialogs/notificate_setpassword.mako
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: wasko/branches/2.0/mpulsweb/templates/usersettings/dialogs/success_edit_standin.mako (from rev 1319, wasko/branches/2.0/waskaweb/templates/usersettings/dialogs/success_edit_standin.mako)


Property changes on: wasko/branches/2.0/mpulsweb/templates/usersettings/dialogs/success_edit_standin.mako
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: wasko/branches/2.0/mpulsweb/templates/usersettings/edit_standin.mako (from rev 1319, wasko/branches/2.0/waskaweb/templates/usersettings/edit_standin.mako)
===================================================================
--- wasko/branches/2.0/waskaweb/templates/usersettings/edit_standin.mako	2010-02-08 12:06:10 UTC (rev 1319)
+++ wasko/branches/2.0/mpulsweb/templates/usersettings/edit_standin.mako	2010-02-09 08:22:41 UTC (rev 1338)
@@ -0,0 +1,42 @@
+## -*- coding: utf-8 -*-
+<%inherit file="../main.mako" />
+<%!  import mpulsweb.lib.helper.filters as F %>
+<div id="content_header_small">
+  <div id="content_ueberschrift">
+ ${_('usrset_header_changestandin')}
+  </div>
+  <div id="modusfield">
+    <div class="actions">
+	<ul>
+		<li><a href="${h.url_for(controller='/usersettings', action='showSettings', id=h.getUserId())}"> ${_('sm_menu_link_settings_back')}</a></li>
+	</ul>
+    </div>
+  </div>
+</div>
+${self.buildFormErrors()}
+<div id="waska_form">
+<p>${_('usrset_explain_changestandin')}</p>
+<br>
+<form action="${h.url_for(action="editStandinAction")}" method="POST">
+  <div class="waska_form_element w100">
+    <label
+    for="standin">${_('usrset_form_changestandin_standin')}</label><br>
+    <select name="standin" id="standin">
+      % for g in c.grouplist:
+        % if g.id == c.uo.standin:
+          <option value="${g.id}" selected>${g.name | F.NA, h}</option>
+        % else:
+          <option value="${g.id}">${g.name | F.NA, h}</option>
+        % endif
+      % endfor
+        % if c.uo.standin is None:
+          <option value="" selected>Keine Vertretung</option>
+        % else:
+          <option value="">Keine Vertretung</option>
+        % endif
+    </select>
+  </div>
+  <input type="hidden" name="uid" value="${h.getUserId()}">
+  <input class="btn_space" type="submit" value="${_('usrset_form_changestandin_submit')}">
+</form>
+</div>


Property changes on: wasko/branches/2.0/mpulsweb/templates/usersettings/edit_standin.mako
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: wasko/branches/2.0/mpulsweb/templates/usersettings/show_settings.mako (from rev 1319, wasko/branches/2.0/waskaweb/templates/usersettings/show_settings.mako)


Property changes on: wasko/branches/2.0/mpulsweb/templates/usersettings/show_settings.mako
___________________________________________________________________
Name: svn:mergeinfo
   + 



More information about the Mpuls-commits mailing list