[Mpuls-commits] r4884 - in jmd/trunk: . jmdstrukturweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Apr 7 15:41:06 CEST 2011
Author: roland
Date: 2011-04-07 15:41:04 +0200 (Thu, 07 Apr 2011)
New Revision: 4884
Added:
jmd/trunk/jmdstrukturweb/model/struktur.py
Modified:
jmd/trunk/ChangeLog
jmd/trunk/jmdstrukturweb/model/case.py
Log:
issue1990: initialise new statistics with the number of users
Modified: jmd/trunk/ChangeLog
===================================================================
--- jmd/trunk/ChangeLog 2011-04-07 12:19:42 UTC (rev 4883)
+++ jmd/trunk/ChangeLog 2011-04-07 13:41:04 UTC (rev 4884)
@@ -1,5 +1,11 @@
2011-04-07 Roland Geider <roland.geider at intevation.de>
+ * jmdstrukturweb/model/case.py,
+ jmdstrukturweb/model/struktur.py: issue1990: initialise new
+ statistics with the number of users
+
+2011-04-07 Roland Geider <roland.geider at intevation.de>
+
* jmdstrukturweb/templates/error/error.mako: issue1982: overwrite the
error template, as JMD doesn't use a support email
Modified: jmd/trunk/jmdstrukturweb/model/case.py
===================================================================
--- jmd/trunk/jmdstrukturweb/model/case.py 2011-04-07 12:19:42 UTC (rev 4883)
+++ jmd/trunk/jmdstrukturweb/model/case.py 2011-04-07 13:41:04 UTC (rev 4884)
@@ -37,8 +37,18 @@
from mpulsweb.model.case import MpulsCase, MpulsCaseFactory, \
MpulsCaseOverview, MpulsCaseBundle, MpulsCaseState
+from jmdstrukturweb.model.struktur import get_db
+
log = logging.getLogger(__name__)
+# SQL STATEMENTS
+INIT_CASE_SQL = """
+UPDATE master_tbl_view
+SET
+ anzahl_ha_personen = %(anzahl)s
+WHERE id = %(id)s"""
+
+
class CaseBundle(MpulsCaseBundle):
pass
@@ -53,7 +63,32 @@
class CaseFactory(MpulsCaseFactory):
def _initNewCase(self, id):
- pass
+ """
+ Initialise the case with the number of users in the case part
+ Here we only count users with the role "cm"
+ """
+ case_db = get_db()
+ connection = cursor = None
+ try:
+ # Read the amount of users in the case part that are CM
+ connection = case_db.getConnection()
+ cursor = connection.cursor()
+ cursor.execute("SELECT COUNT(id) FROM ka_benutzer_tbl_view WHERE rolle LIKE '%cm'")
+ anzahl = cursor.fetchone()
+
+ # Initialise the new statistic
+ user = session['USER_AUTHORIZED']
+ fields = {
+ 'anzahl': anzahl[0],
+ 'id': int(id)
+ }
+ conn = db.getConnection()
+ cur = conn.cursor()
+ cur.execute(INIT_CASE_SQL, fields)
+ conn.commit()
+ finally:
+ case_db.recycleConnection(connection, cursor)
+
class Case(MpulsCase):
Added: jmd/trunk/jmdstrukturweb/model/struktur.py
===================================================================
--- jmd/trunk/jmdstrukturweb/model/struktur.py 2011-04-07 12:19:42 UTC (rev 4883)
+++ jmd/trunk/jmdstrukturweb/model/struktur.py 2011-04-07 13:41:04 UTC (rev 4884)
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008, 2010 Intevation GmbH, Germany, <info at intevation.de>
+#
+# This file is part of mpuls JMD (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:
+# Bernhard Herzog <bh at intevation.de>
+# Roland Geider <roland.geider at intevation.de>
+
+from pylons import config
+
+from mpulsweb.lib.db import DB
+from mpulsweb.lib.security import get_db_parameters
+from mpulsweb.model.user import UserListObject, parse_dblogin
+from mpulsweb.lib.base import session
+
+
+def get_db():
+ current_user = session['USER_AUTHORIZED']
+ return DB(**get_db_parameters(current_user.login,
+ current_user.password,
+ config.get('jmd.casedb.host'),
+ config.get('jmd.casedb.port'),
+ config.get('jmd.casedb.database'),
+ config.get('jmd.casedb.user')))
\ No newline at end of file
More information about the Mpuls-commits
mailing list