[Mpuls-commits] r5363 - in jmd/trunk/jmdweb: controllers model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Sep 16 10:29:50 CEST 2011


Author: roland
Date: 2011-09-16 10:29:48 +0200 (Fri, 16 Sep 2011)
New Revision: 5363

Added:
   jmd/trunk/jmdweb/controllers/administration.py
Modified:
   jmd/trunk/jmdweb/model/struktur.py
Log:
issue1616: delete the user login from the structure's user table when the user
is deleted.

This prevents a newly created user from accessing the structure part if the
login matches the one from a deleted one.


Added: jmd/trunk/jmdweb/controllers/administration.py
===================================================================
--- jmd/trunk/jmdweb/controllers/administration.py	2011-09-16 08:27:53 UTC (rev 5362)
+++ jmd/trunk/jmdweb/controllers/administration.py	2011-09-16 08:29:48 UTC (rev 5363)
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+
+#
+# Copyright 2007 - 2011 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:
+# Roland Geider <roland.geider at intevation.de>
+#
+
+
+import logging
+import formencode
+
+from pylons import request, tmpl_context as c
+from mpulsweb.lib.translation import _
+
+from mpulsweb.lib.db import db
+from mpulsweb.lib.base import BaseController, render, redirect_to, session
+from mpulsweb.lib.helpers import url_for
+from mpulsweb.lib.security import checkRole, getDbName
+from mpulsweb.lib.validators import ValidatorStateObject, NewUserGroupForm, \
+    EditUserGroupForm , NewUserForm, EditUserForm, DeleteUserHelperForm
+from mpulsweb.model.user import UserListObject, UserObject, UserGroupList, \
+    UserGroup, UserGroupFactory
+from mpulsweb.model.case import MpulsCaseOverview, MpulsCaseBundle
+from mpulsweb.model.phase import PhaseFactory 
+from mpulsweb.controllers.case_overview import default_phases
+
+from mpulsweb.controllers.administration import AdministrationController \
+    as MpulsAdministrationController
+from jmdweb.model.struktur import remove_struktur_user_by_login
+
+
+log = logging.getLogger(__name__)
+
+class AdministrationController(MpulsAdministrationController):
+    def _before_delete_user(self, id, confirmed='0'):
+        """
+        Application specific actions to perform before actually deleting the user.
+        
+        Here the user's rights to access the structure part are removed.
+        """
+        uo = UserObject(id)
+        remove_struktur_user_by_login(uo.login)
\ No newline at end of file

Modified: jmd/trunk/jmdweb/model/struktur.py
===================================================================
--- jmd/trunk/jmdweb/model/struktur.py	2011-09-16 08:27:53 UTC (rev 5362)
+++ jmd/trunk/jmdweb/model/struktur.py	2011-09-16 08:29:48 UTC (rev 5363)
@@ -76,6 +76,46 @@
     return user_ids
 
 
+def remove_struktur_user_by_login(user_login):
+    """
+    Deletes user from the ka_benutzer_tbl on the structure part.
+    """
+    struktur_db = get_db()
+    con = cur = None
+    try:
+        try:
+            con = struktur_db.getConnection()
+            cur = con.cursor()
+            cur.execute("SELECT id FROM ka_benutzer_tbl WHERE login LIKE 'ka_%%_%s'" \
+                                                                % user_login)
+            row = cur.fetchone()
+            if row:
+                remove_struktur_user_by_id(row[0])
+            con.commit()
+        except:
+            con.rollback()
+            raise
+    finally:
+        struktur_db.recycleConnection(con, cur)
+
+def remove_struktur_user_by_id(user_id):
+    """
+    Deletes user from the ka_benutzer_tbl on the structure part.
+    """
+    struktur_db = get_db()
+    con = cur = None
+    try:
+        try:
+            con = struktur_db.getConnection()
+            cur = con.cursor()
+            cur.execute("SELECT jmd_delete_struktur_nutzer(%s)" % user_id)
+            con.commit()
+        except:
+            con.rollback()
+            raise
+    finally:
+        struktur_db.recycleConnection(con, cur)
+
 def set_struktur_users(user_ids):
     """Define the group of users who may access the struktur part.
 



More information about the Mpuls-commits mailing list