[Mpuls-commits] r2362 - wasko/branches/2.0/jmdweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Apr 15 10:27:56 CEST 2010


Author: torsten
Date: 2010-04-15 10:27:56 +0200 (Thu, 15 Apr 2010)
New Revision: 2362

Added:
   wasko/branches/2.0/jmdweb/model/appointment.py
Log:
* jmdweb/model/appointment.py: New. JMD Specific implementation of
	getting old cases (only after the kids are 27 years)


Added: wasko/branches/2.0/jmdweb/model/appointment.py
===================================================================
--- wasko/branches/2.0/jmdweb/model/appointment.py	2010-04-15 08:12:09 UTC (rev 2361)
+++ wasko/branches/2.0/jmdweb/model/appointment.py	2010-04-15 08:27:56 UTC (rev 2362)
@@ -0,0 +1,121 @@
+# -*- 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>
+#
+
+from mpulsweb.lib.base import session, g
+from mpulsweb.lib.db import db
+from mpulsweb.model.appointment import MaxSaveTimeReminderOverview as \
+    MpulsMaxSaveTimeReminderOverview
+
+GET_OLDACTIVE_CASES_4_ADMIN = """
+SELECT m.id, s.zugriff, getLastCaseAppointment(m.id) AS last_date
+FROM
+  (SELECT * FROM ka_status_tbl_view
+   WHERE zugriff < now() - interval '1 day' * %%(maxdays)s AND status <> 5) s
+   JOIN master_tbl_view m ON m.id = s.master_id
+WHERE phase in (%s)
+AND extract(year from age(geburtsdatum)) >= 27
+"""
+
+GET_OLDACTIVE_CASES = """
+SELECT m.id, s.zugriff, getLastCaseAppointment(m.id) AS last_date
+FROM
+  (SELECT * FROM ka_status_tbl_view
+   WHERE zugriff < now() - interval '1 day' * %%(maxdays)s 
+   AND status <> 5) s
+   JOIN master_tbl_view m ON m.id = s.master_id
+WHERE phase in (%s) AND m.bearbeiter_id = %%(editor)s
+AND extract(year from age(geburtsdatum)) >= 27
+"""
+
+GET_OLDFINISHED_CASES_4_ADMIN = """\
+SELECT m.id, s.zugriff, getLastCaseAppointment(m.id) as last_date
+FROM master_tbl_view m JOIN ka_status_tbl_view s ON s.master_id = m.id
+WHERE s.status <> 5
+      AND extract(year from age(geburtsdatum)) >= 27
+      AND extract(day from now()-s.zugriff) > %%(maxdays)s
+      AND phase in (%s)
+"""
+
+GET_OLDFINISHED_CASES = """\
+SELECT m.id, s.zugriff, getLastCaseAppointment(m.id) as last_date
+FROM master_tbl_view m JOIN ka_status_tbl_view s ON s.master_id = m.id
+WHERE s.status <> 5
+      AND m.bearbeiter_id = %%(editor)s
+      AND extract(year from age(geburtsdatum)) >= 27
+      AND extract(day from now()-s.zugriff) > %%(maxdays)s
+      AND phase in (%s)
+"""
+
+class MaxSaveTimeReminderOverview(MpulsMaxSaveTimeReminderOverview):
+
+    def getOldAndFinishedCases(self, days, user):
+        conn, cur = None, None
+        list = {}
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            if user.isAdmin():
+                sql = (GET_OLDFINISHED_CASES_4_ADMIN
+                       % ",".join(g.mpuls_config.get('phases', 'finished')))
+                cur.execute(sql,
+                            {'maxdays': days})
+            else:
+                sql = (GET_OLDFINISHED_CASES
+                       % ",".join(g.mpuls_config.get('phases', 'finished')))
+                cur.execute(sql, {'maxdays': days, 'editor': user.id})
+            result = cur.fetchall()
+            for r in result:
+                list[r[0]] = {'access':r[1], 'last_date': r[2]}
+            return list
+        finally:
+            db.recycleConnection(conn, cur)
+        return False
+
+    def getOldAndActiveCases(self, days, user):
+        conn, cur = None, None
+        list = {}
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            if user.isAdmin():
+                sql = (GET_OLDACTIVE_CASES_4_ADMIN
+                       % ",".join(g.mpuls_config.get('phases', 'active')))
+                cur.execute(sql, {'maxdays': days, 'editor': user.id})
+            else:
+                sql = (GET_OLDACTIVE_CASES
+                       % ",".join(g.mpuls_config.get('phases', 'active')))
+                cur.execute(sql, {'maxdays': days, 'editor': user.id})
+            result = cur.fetchall()
+            for r in result:
+                list[r[0]] = {'access':r[1], 'last_date': r[2]}
+            return list
+        finally:
+            db.recycleConnection(conn, cur)
+        return False



More information about the Mpuls-commits mailing list