Changeset - 6271eb26f0ed
[Not reviewed]
dev
0 1 0
Dennis Fink - 10 years ago 2015-10-28 01:03:05
dennis.fink@c3l.lu
Use babel to format and parse numbers in donations
1 file changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
ennstatus/donate/views.py
Show inline comments
 
@@ -14,10 +14,11 @@
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from decimal import Decimal
 
from flask import (Blueprint, render_template, request,
 
                   redirect, url_for, current_app)
 

	
 
from babel.numbers import parse_decimal, format_decimal
 

	
 
from ennstatus.donate.forms import DateForm
 
from ennstatus.donate.functions import load_csv, get_choices
 

	
 
@@ -108,7 +109,12 @@ def received():
 
            form.month.data = '{:02d}'.format(int(month))
 
            csv_file = load_csv(filename)
 

	
 
        total = str(sum(Decimal(row[2].replace(',', '.')) for row in csv_file))
 
        total = format_decimal(
 
            sum(
 
                parse_decimal(row[2], locale='de') for row in csv_file
 
            ),
 
            locale='de'
 
        )
 
        csv_file = load_csv(filename)
 

	
 
        current_app.logger.info('Return result')
0 comments (0 inline, 0 general)