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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 10 14:26:23 CET 2010


Author: torsten
Date: 2010-02-10 14:26:21 +0100 (Wed, 10 Feb 2010)
New Revision: 1458

Modified:
   wasko/branches/2.0/mpulsweb/controllers/administration.py
Log:
* mpulsweb/controllers/administration.py (user_has_cases): Implemented
function to check if the user is the editor of at least one cases



Modified: wasko/branches/2.0/mpulsweb/controllers/administration.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/administration.py	2010-02-10 13:17:39 UTC (rev 1457)
+++ wasko/branches/2.0/mpulsweb/controllers/administration.py	2010-02-10 13:26:21 UTC (rev 1458)
@@ -6,6 +6,7 @@
 from pylons.i18n import _
 from pylons.controllers.util import abort, redirect_to
 
+from mpulsweb.lib.db import db
 from mpulsweb.lib.base import BaseController, render
 from mpulsweb.lib.security import checkRole, getDbName
 from mpulsweb.lib.validators import ValidatorStateObject, NewUserGroupForm, \
@@ -42,7 +43,20 @@
 log = logging.getLogger(__name__)
 
 def user_has_cases(user):
-    return True
+    conn, cur = None, None
+    fields = {'userid': user.id}
+    sql = "select count(id) from master_tbl_view where bearbeiter_id = %(userid)s"
+    try:
+        conn = db.getConnection()
+        cur = conn.cursor()
+        cur.execute(sql, fields)
+        result = cur.fetchone()
+        return int(result[0]) > 0
+    except Exception, e:
+        log.exception(e)
+        return True
+    finally:
+        db.recycleConnection(conn, cur)
 
 class AdministrationController(BaseController):
 



More information about the Mpuls-commits mailing list