[Mpuls-commits] r2990 - in jmd/trunk: . jmdstrukturweb/controllers jmdstrukturweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jun 10 16:35:58 CEST 2010


Author: roland
Date: 2010-06-10 16:35:57 +0200 (Thu, 10 Jun 2010)
New Revision: 2990

Added:
   jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py
   jmd/trunk/jmdstrukturweb/model/appointment.py
Modified:
   jmd/trunk/ChangeLog
   jmd/trunk/jmdstruktur.json
Log:
New controller and model for jmd specific reminders

Modified: jmd/trunk/ChangeLog
===================================================================
--- jmd/trunk/ChangeLog	2010-06-10 14:20:14 UTC (rev 2989)
+++ jmd/trunk/ChangeLog	2010-06-10 14:35:57 UTC (rev 2990)
@@ -1,3 +1,8 @@
+2010-05-18  Torsten Irländer <torsten.irlaender at intevation.de>
+
+	* jmdstruktur/model/appointment.py,
+	  jmdstruktur/controllers/jmdstruktur.py: New controller and model for
+	  jmdstruktur specific reminders
 2010-06-10  Bernhard Herzog  <bh at intevation.de>
 
 	* jmdstrukturweb/templates/casemanagement/new.mako,

Modified: jmd/trunk/jmdstruktur.json
===================================================================
--- jmd/trunk/jmdstruktur.json	2010-06-10 14:20:14 UTC (rev 2989)
+++ jmd/trunk/jmdstruktur.json	2010-06-10 14:35:57 UTC (rev 2990)
@@ -9,7 +9,7 @@
 	"case-module": {
 		"import": "0",
 		"appointments": "0",
-		"reminders": "0",
+		"reminders": "1",
 		"documents": "0",
 		"exportXML": "0",
 		"exportXLS": "0",
@@ -126,7 +126,9 @@
 		"alias":"datum_ende_zeitraum"},
          	{"name":"bearbeiter_id", "search_retrieve":true,
          	 "preload":true, "alias":"editor", "alias_force_string":false}
-     		]
+     		],
+                "remindercondition": "FALSE",
+		"reminderconditiondesc": "Die Fallakte kann ungeschr&auml;nkt aufbewahrt werden"
  	},
 
 	"renderer": {

Added: jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py
===================================================================
--- jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py	2010-06-10 14:20:14 UTC (rev 2989)
+++ jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py	2010-06-10 14:35:57 UTC (rev 2990)
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+import logging
+from mpulsweb.controllers.mpuls import MpulsController
+from jmdstrukturweb.model.appointment import StatisticReminderOverview
+
+log = logging.getLogger(__name__)
+
+class JmdstrukturController(MpulsController):
+    
+    def get_reminders(self):
+            """Return an AppointmentOverview instance with one reminder. It reminds the user to create a new statistic.
+        """
+        remindlist = StatisticReminderOverview()
+        return remindlist
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Added: jmd/trunk/jmdstrukturweb/model/appointment.py
===================================================================
--- jmd/trunk/jmdstrukturweb/model/appointment.py	2010-06-10 14:20:14 UTC (rev 2989)
+++ jmd/trunk/jmdstrukturweb/model/appointment.py	2010-06-10 14:35:57 UTC (rev 2990)
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+import logging
+from datetime import datetime, timedelta
+
+import mpulsweb.lib.helpers as h
+from mpulsweb.lib.base import session, g
+from mpulsweb.lib.db import db
+from mpulsweb.model.case import MpulsCaseOverview
+from mpulsweb.model.agencysettings import Agency
+
+from mpulsweb.model.appointment import AppointmentOverview, CaseAppointmentFactory
+
+class StatisticReminderOverview(AppointmentOverview):
+
+    def __init__(self):
+        self.appointment_list = []
+        agency = Agency()
+        maxage = agency.getMaxSavetime()
+        cases = MpulsCaseOverview()
+        user = session['USER_AUTHORIZED']
+
+        # 0. Load ids and some additional info on cases which either are active
+        # but seems to be orphaned or are finished and not edited for
+        # longer than maxage.
+        # orphaned means that all last appointments, aids or the
+        # modification date is older than maxage
+        oldAndActive = self.get_recent_statistic(maxage, user)
+        if not oldAndActive:
+            appointment = self.makeAppointment()
+            self.appointment_list.append(appointment)
+
+
+    def get_recent_statistic(self, days, user):
+        conn, cur = None, None
+        list = {}
+        remindercondition = g.mpuls_config.get('case', 'remindercondition') 
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            sql = ("SELECT id from master_tbl_view where extract(day from (now() - datum_begin_zeitraum)) < %(maxdays)s")
+            cur.execute(sql, {'maxdays': days})
+            result = cur.fetchall()
+            for r in result:
+                list[r[0]] = {}
+            return list
+        finally:
+            db.recycleConnection(conn, cur)
+        return False
+
+    def makeAppointment(self):
+        factory = CaseAppointmentFactory()
+        type = 1
+        title = u"JMDSTRUKTURTEST"
+        desc = u"Statistik fehlt"
+        mydate = datetime.now()
+        appointment = factory.createByData(None, title, mydate, None, desc,
+                                           0, type)
+        return appointment
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list