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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Dec 1 13:17:08 CET 2011


Author: bricks
Date: 2011-12-01 13:17:04 +0100 (Thu, 01 Dec 2011)
New Revision: 5680

Modified:
   base/trunk/mpulsweb/lib/export.py
Log:
Format float and decimal values with two following numbers

For bewilligung_betrag the exported entry is a currency and should have two
following numbers after the colon.

Part of issue2679


Modified: base/trunk/mpulsweb/lib/export.py
===================================================================
--- base/trunk/mpulsweb/lib/export.py	2011-12-01 12:16:30 UTC (rev 5679)
+++ base/trunk/mpulsweb/lib/export.py	2011-12-01 12:17:04 UTC (rev 5680)
@@ -6,6 +6,7 @@
 import stat
 from collections import defaultdict
 from datetime import datetime, date
+from decimal import Decimal
 
 import pyExcelerator
 
@@ -53,7 +54,7 @@
 # Export base classes
 #
 
-class Export:
+class Export(object):
 
     pass
 
@@ -294,8 +295,17 @@
 # Formletter Export
 #
 class FormletterXLSTable(XLSTable):
-    pass
 
+    def encode(self, value):
+        if isinstance(value, (float, Decimal)):
+            style = pyExcelerator.XFStyle()
+            value = float(value)
+            style.num_format_str = "0.00"
+        else:
+            value, style = super(FormletterXLSTable, self).encode(value)
+        return (value, style)
+
+
 class FormletterExport(Export):
 
     def __init__(self, data, order=None):



More information about the Mpuls-commits mailing list