[Mpuls-commits] r2069 - wasko/branches/2.0/jmdweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 23 11:08:53 CET 2010
Author: torsten
Date: 2010-03-23 11:08:53 +0100 (Tue, 23 Mar 2010)
New Revision: 2069
Removed:
wasko/branches/2.0/jmdweb/model/appointment.py
Log:
Deleted. MaxSavetimeReminder is now defined in mpulsweb
Deleted: wasko/branches/2.0/jmdweb/model/appointment.py
===================================================================
--- wasko/branches/2.0/jmdweb/model/appointment.py 2010-03-23 10:07:59 UTC (rev 2068)
+++ wasko/branches/2.0/jmdweb/model/appointment.py 2010-03-23 10:08:53 UTC (rev 2069)
@@ -1,174 +0,0 @@
-# -*- 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.model.appointment import *
-from mpulsweb.model.agencysettings import Agency
-
-from jmdweb.model.case import CaseOverview
-
-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 (-1, 0, 1)
-"""
-
-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 (-1, 0, 1) AND m.bearbeiter_id = %(editor)s
-"""
-
-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(day from now()-s.zugriff) > %(maxdays)s
- AND phase in (2, 3, 4)
-"""
-
-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(day from now()-s.zugriff) > %(maxdays)s
- AND phase in (2, 3, 4)
-"""
-
-
-class MaxSaveTimeReminderOverview(AppointmentOverview):
-
- def __init__(self):
- self.appointment_list = []
- agency = Agency()
- maxage = agency.getMaxSavetime()
- cases = CaseOverview()
- 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 appointmentment, aids or the
- # modification date is older than maxage
- oldAndActive = self.__getOldAndActiveCases(maxage, user)
- oldAndFinished = self.__getOldAndFinishedCases(maxage, user)
-
- # 1. Load cases of the user so we can so checks regarding the maximum
- # savetime on them
- default_search_options = ['own:%s' % user.id, 'standin:%s' % user.id,
- 'state:1', 'state:2', 'state:3']
- cases.search(";".join(default_search_options))
-
- # 2. filter cases which seems to be orphaned and create reminders
- oldAndActiveSet = set(oldAndActive)
- old_cases = [case for case in cases.getDatasets()
- if case.id in oldAndActiveSet]
- for case in old_cases:
- info = oldAndActive[case.id]
- last = info['last_date']
- appointment = self.__makeAppointment(case, last, maxage,
- finished=False)
- self.appointment_list.append(appointment)
-
-
- # 3. filter cases which are finished and not edited and create reminders
- oldAndFinishedSet = set(oldAndFinished)
- old_cases = [case for case in cases.getDatasets()
- if case.id in oldAndFinishedSet]
- for case in old_cases:
- info = oldAndFinished[case.id]
- access = info['access']
- appointment = self.__makeAppointment(case, access, maxage,
- finished=True)
- self.appointment_list.append(appointment)
-
- def __getOldAndFinishedCases(self, days, user):
- conn, cur = None, None
- list = {}
- try:
- conn = db.getConnection()
- cur = conn.cursor()
- if user.isAdmin():
- cur.execute(GET_OLDFINISHED_CASES_4_ADMIN, {'maxdays': days})
- else:
- cur.execute(GET_OLDFINISHED_CASES, {'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():
- cur.execute(GET_OLDACTIVE_CASES_4_ADMIN, {'maxdays': days,
- 'editor': user.id})
- else:
- cur.execute(GET_OLDACTIVE_CASES, {'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 __makeAppointment(self, case, last_date, maxage, finished):
- factory = CaseAppointmentFactory()
- type = 1
- title = u"%s, %s" % (case.last_name, case.first_name)
- age = datetime.now() - last_date
- mydate = datetime.now() - timedelta(age.days-int(maxage))
- if finished:
- desc = (u"Achtung! Die maximale Speicherdauer von (%s Tagen)"
- u" ist seit %s Tagen für diese Fallakte überschritten!"
- % (maxage, age.days-int(maxage)))
- else:
- desc = (u"Inaktive Fallakte? Bitte prüfen Sie,"
- u" ob der Fall noch bearbeitet wird.")
- appointment = factory.createByData(None, title, mydate, None, desc,
- case.id, type)
- return appointment
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8:
More information about the Mpuls-commits
mailing list