[Mpuls-commits] r3800 - base/trunk/mpulsweb/lib/helper

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 28 10:06:16 CEST 2010


Author: torsten
Date: 2010-09-28 10:06:14 +0200 (Tue, 28 Sep 2010)
New Revision: 3800

Modified:
   base/trunk/mpulsweb/lib/helper/case.py
Log:
mpulsweb/lib/helper/case.py (phase_time_in_weeks): Issue1121: Added new
function to format duration of phase in casedigest in a more human readable
* form


Modified: base/trunk/mpulsweb/lib/helper/case.py
===================================================================
--- base/trunk/mpulsweb/lib/helper/case.py	2010-09-27 18:51:13 UTC (rev 3799)
+++ base/trunk/mpulsweb/lib/helper/case.py	2010-09-28 08:06:14 UTC (rev 3800)
@@ -5,8 +5,9 @@
 from formed.meta.data import DateLeaf
 
 from mpulsweb.lib.base import g
+from mpulsweb.lib.translation import _
 from mpulsweb.lib.db import PostgresDBInterface, db
-from mpulsweb.lib.helpers import format_date 
+from mpulsweb.lib.helpers import format_date, timedelta_in_weeks
 
 log = logging.getLogger(__name__)
 
@@ -39,5 +40,15 @@
     new_it = factory.copy_instance_tree(it, fields)
     return new_it
 
+def phase_time_in_weeks(ti):
+    '''Used in case digest to display the time of the phases in weeks'''
+    if ti is None:
+        return None 
+    t = float(ti.days) / 7.0 + ti.seconds / (60.0 * 24.0 * 7.0)
+    if t < 1:
+        return _('< 1 week')
+    else:
+        return format_number(t, 1)
 
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list