Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>
Filters module and rig `as_currency` jinja filter
core/app.py | 4 ++++ core/filters.py | 4 ++++
diff --git a/core/app.py b/core/app.py index 08773425a98f3b89e22d7396abceae36b20aa054..cdd91370e66b7d50d943e784b00c6bd44ee02ba4 100644 --- a/core/app.py +++ b/core/app.py @@ -1,5 +1,6 @@ from flask import Flask, render_template from flask_login import LoginManager +import locale from core.config import read_from_config, env from core.database import db, init_database @@ -17,6 +18,9 @@ login_manager = LoginManager() login_manager.login_view = 'auth.login' login_manager.init_app(app) + +from core.filters import * +app.jinja_env.filters['as_currency'] = as_currency from .types.user import User diff --git a/core/filters.py b/core/filters.py new file mode 100644 index 0000000000000000000000000000000000000000..5751dce1def3a0e7babd212dc2e6566dc55b848c --- /dev/null +++ b/core/filters.py @@ -0,0 +1,4 @@ +import locale + +def as_currency(value): + return locale.currency(value)