diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2016-06-17 10:06:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-17 10:06:19 +0200 |
| commit | 5084cafe6bcd266bd1e676fc6921a7dba3c48a57 (patch) | |
| tree | 7c2d5f915a5f37d086e31b61cb71fd20dbf4b385 /budget/utils.py | |
| parent | 789196721584ca4800e4236eee36955e78761346 (diff) | |
| parent | c49a355eb082cff208806f785d52567ddd043c03 (diff) | |
| download | ihatemoney-mirror-5084cafe6bcd266bd1e676fc6921a7dba3c48a57.zip ihatemoney-mirror-5084cafe6bcd266bd1e676fc6921a7dba3c48a57.tar.gz ihatemoney-mirror-5084cafe6bcd266bd1e676fc6921a7dba3c48a57.tar.bz2 | |
Merge pull request #131 from JocelynDelalande/members-weights
Added Members weights handling
Diffstat (limited to 'budget/utils.py')
| -rw-r--r-- | budget/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/budget/utils.py b/budget/utils.py index 7717aaa..c849af0 100644 --- a/budget/utils.py +++ b/budget/utils.py @@ -1,6 +1,7 @@ import re import inspect +from jinja2 import filters from flask import redirect from werkzeug.routing import HTTPException, RoutingException @@ -63,3 +64,16 @@ class PrefixedWSGI(object): if scheme: environ['wsgi.url_scheme'] = scheme return self.wsgi_app(environ, start_response) + + +def minimal_round(*args, **kw): + """ Jinja2 filter: rounds, but display only non-zero decimals + + from http://stackoverflow.com/questions/28458524/ + """ + # Use the original round filter, to deal with the extra arguments + res = filters.do_round(*args, **kw) + # Test if the result is equivalent to an integer and + # return depending on it + ires = int(res) + return (res if res != ires else ires) |
