[Mpuls-commits] r3558 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 9 09:43:42 CEST 2010


Author: torsten
Date: 2010-09-09 09:43:41 +0200 (Thu, 09 Sep 2010)
New Revision: 3558

Modified:
   base/trunk/mpulsweb/lib/helpers.py
Log:
* mpulsweb/lib/helpers.py (convertForDigest): New function to convert
	given values suitable for the digest output. Will localize dates an
	return srting representation for unknown values.


Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2010-09-08 16:50:19 UTC (rev 3557)
+++ base/trunk/mpulsweb/lib/helpers.py	2010-09-09 07:43:41 UTC (rev 3558)
@@ -143,6 +143,20 @@
     print out
     return out
 
+def convertForDigest(value):
+    """Will convert given values to it's string representation for correct
+    display in digest. Will localize dates and shown and return string
+    'unknown' if it is the unknown value"""
+    if isinstance(value, datetime.date):
+        if value == datetime.date(1,1,1):
+            return _('unknown')  
+        else:
+            return format_date(value)
+    if isinstance(value, int):
+        if value == -9999999:
+            return _('unknown')  
+    return value
+
 # Helper functions used in the UI to show some information like status messages
 # or icons
 



More information about the Mpuls-commits mailing list