[Mpuls-commits] r2367 - wasko/branches/2.0/mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Apr 15 12:19:45 CEST 2010
Author: torsten
Date: 2010-04-15 12:19:44 +0200 (Thu, 15 Apr 2010)
New Revision: 2367
Modified:
wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCaseState.check_remindcondition): New.
Returns True is remindcondition is true.
* mpulsweb/model/case.py (MpulsCaseState.daysToMaxSavetime): On return
real days to maxsavetime if remind condtion is true. else return fake
15 days to prevent showing counting days until reminder generation in
template.
Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py 2010-04-15 08:36:44 UTC (rev 2366)
+++ wasko/branches/2.0/mpulsweb/model/case.py 2010-04-15 10:19:44 UTC (rev 2367)
@@ -88,7 +88,8 @@
UPDATE master_tbl_view
SET phase = %(phase)s
WHERE id IN (SELECT master_id FROM ka_status_tbl_view WHERE id = %(id)s)"""
-ANONYMIZE_CASE = """SELECT anonymize_case_wrapper(%(id)s)"""
+ANONYMIZE_CASE = """SELECT anonymizephase_case_wrapper(%(id)s)"""
+CHECK_REMIND_CONDITION = """select id from master_tbl_view where id = %%(id)s and (%s)"""
#DIALOGS
MARKANONYMIZE_FAILED_MIN_PHASE = u"""\
@@ -1133,12 +1134,38 @@
def getMaxSavetime(self):
return Agency().getMaxSavetime()
+ def check_remindcondition(self):
+ conn, cur = None, None
+ remindercondition = g.mpuls_config.get('case', 'remindercondition')
+ try:
+ try:
+ conn = db.getConnection()
+ cur = conn.cursor()
+ sql = CHECK_REMIND_CONDITION % remindercondition
+ fields = {'id': self.master_id}
+ cur.execute(sql, fields)
+ conn.commit()
+ if cur.fetchone():
+ return True
+ return False
+ finally:
+ db.recycleConnection(conn, cur)
+ except:
+ log.exception('Can not check remind condition')
+ return False
+
def daysToMaxSavetime(self):
maxage = self.getMaxSavetime()
if self.isCmFinished():
age = datetime.now() - self.getAccessTime()
else:
age = datetime.now() - self.getLastDate()
- if int(maxage) != 0:
- return int(maxage) - age.days
- return None
+
+ if self.check_remindcondition():
+ if int(maxage) != 0:
+ return int(maxage) - age.days
+ else:
+ return 15 # showning counting days until generation of a reminder
+ # starts 14 days before maxsavetime is reached in
+ # template. We do not want such counter until the
+ # remindcondiotion is not true
More information about the Mpuls-commits
mailing list