From aecab933b0ea152bcf590073bfb8cbf5619d5688 Mon Sep 17 00:00:00 2001 From: Montana Date: Mon, 11 Feb 2019 10:40:33 -0500 Subject: [PATCH] Add jinja filters for just dollars and just cents --- atst/filters.py | 9 +++++++++ templates/portfolios/header.html | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/atst/filters.py b/atst/filters.py index 61c42f8c..f752c1b2 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -18,6 +18,13 @@ def dollars(value): numberValue = 0 return "${:,.2f}".format(numberValue) +def justDollars(value): + raw = dollars(value) + return raw[:-3] + +def justCents(value): + raw = dollars(value) + return raw[-3:] def usPhone(number): phone = re.sub(r"\D", "", number) @@ -99,6 +106,8 @@ def normalizeOrder(title): def register_filters(app): app.jinja_env.filters["iconSvg"] = iconSvg app.jinja_env.filters["dollars"] = dollars + app.jinja_env.filters["justDollars"] = justDollars + app.jinja_env.filters["justCents"] = justCents app.jinja_env.filters["usPhone"] = usPhone app.jinja_env.filters["readableInteger"] = readableInteger app.jinja_env.filters["getOptionLabel"] = getOptionLabel diff --git a/templates/portfolios/header.html b/templates/portfolios/header.html index 1895ecac..63b1a546 100644 --- a/templates/portfolios/header.html +++ b/templates/portfolios/header.html @@ -20,9 +20,29 @@ {{ Icon('info') }} - {{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | dollars }} + {{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | justDollars }} + + + {{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | justCents }} +
+ {% if funding_end_date and funded %} + {{ Icon('ok') }} + Funded through + + + {% elif funding_end_date and not funded %} + {{ Icon('alert') }} + Funded period ends + + + {% endif %} +