[Mpuls-commits] r134 - in waska/trunk: . waskaweb/lib waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 4 08:05:45 CEST 2008


Author: teichmann
Date: 2008-09-04 08:05:45 +0200 (Thu, 04 Sep 2008)
New Revision: 134

Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/lib/helpers.py
   waska/trunk/waskaweb/templates/casemanagement/phase.mako
Log:
Phases: print dates and time sums correctly.


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-09-04 05:37:34 UTC (rev 133)
+++ waska/trunk/ChangeLog.txt	2008-09-04 06:05:45 UTC (rev 134)
@@ -1,5 +1,12 @@
 2008-09-04  Sascha L. Teichmann <sascha.teichmann at intevation.de>
 
+	* waskaweb/lib/helpers.py: Added function to print times in weeks
+
+	* waskaweb/templates/casemanagement/phase.mako: Only print 
+	  dd:mm:YYYY for dates and time sums in weeks. 
+
+2008-09-04  Sascha L. Teichmann <sascha.teichmann at intevation.de>
+
 	* waskaweb/model/phase_transition.py: add function to map
 	  back phase symbol to phase number.
 

Modified: waska/trunk/waskaweb/lib/helpers.py
===================================================================
--- waska/trunk/waskaweb/lib/helpers.py	2008-09-04 05:37:34 UTC (rev 133)
+++ waska/trunk/waskaweb/lib/helpers.py	2008-09-04 06:05:45 UTC (rev 134)
@@ -91,9 +91,9 @@
     retval = locale.format("%.2f",(number),1)
     return retval
 
-def dd_mm_YYYY(d):
+def dd_mm_YYYY(d, empty = ''):
     ''' datetime.strftime() dislikes years before 1900. '''
-    if d is None: return ''
+    if d is None: return empty
     return "%02d.%02d.%d" % (d.day, d.month, d.year)
 
 def HH_MM(d):
@@ -121,6 +121,12 @@
     secs = ti.seconds / 60.0
     return round(days + secs)
 
+def timedelta_in_weeks(ti, empty = None):
+    if ti is None: return empty
+    days = float(ti.days) / 7.0
+    secs = ti.seconds / (60.0 * 24.0 * 7.0)
+    return formatNumber(days + secs)
+
 def human_timedelta(td, empty=None):
     if td is None: return empty
     out = []

Modified: waska/trunk/waskaweb/templates/casemanagement/phase.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-04 05:37:34 UTC (rev 133)
+++ waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-04 06:05:45 UTC (rev 134)
@@ -35,7 +35,7 @@
       <td class="required_field">
         ${p1.getLinks()}
       </td>
-      <td>${h.dd_mm_yyyy_HH_MM(p1.getTime(), '-/-')}</td>
+      <td>${h.dd_mm_YYYY(p1.getTime(), '-/-')}</td>
       <td style="text-align:right">
         % if p1.isComplete() and not p1.isRunning() and p1.isNeighbor(c.current_phase):
             <input type="submit" value="Start ${phase_pair.getDescription()|h}" name="${p1.getLabel()|h}">
@@ -54,7 +54,7 @@
       <td class="table_row_h required_field">
         ${p2.getLinks()}
       </td>
-      <td class="table_row_h">${h.dd_mm_yyyy_HH_MM(p2.getTime(), '-/-')}</td>
+      <td class="table_row_h">${h.dd_mm_YYYY(p2.getTime(), '-/-')}</td>
       <td style="text-align:right" class="table_row_h">
         % if p2.isComplete() and p2.isRunning():
             <input type="submit" value="Ende ${p2.getDescription()|h}" name="${p2.getLabel()|h}">
@@ -87,14 +87,14 @@
         t = phase_pair.getDuration();
         if t: total = total and (total + t) or t
       %>
-      ${h.human_timedelta(t, '-/-')}
+      ${h.timedelta_in_weeks(t, '-/-')}
       </td>
     </tr>
     % endfor
     <tr>
       <td style="border-top:1px solid"><strong>Gesamt</strong></td>
       <td style="border-top:1px solid; text-align:right">
-        <strong>${h.human_timedelta(total, '-/-')}</strong>
+        <strong>${h.timedelta_in_weeks(total, '-/-')}</strong>
       </td>
     </tr>
   </table>



More information about the Mpuls-commits mailing list