diff --git a/atst/filters.py b/atst/filters.py index f752c1b2..34f02787 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -18,14 +18,17 @@ 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) return "+1 ({}) {} - {}".format(phone[0:3], phone[3:6], phone[6:]) diff --git a/atst/routes/portfolios/__init__.py b/atst/routes/portfolios/__init__.py index ad935378..4e65bce1 100644 --- a/atst/routes/portfolios/__init__.py +++ b/atst/routes/portfolios/__init__.py @@ -1,4 +1,5 @@ from flask import Blueprint, request as http_request, g, render_template +from operator import attrgetter portfolios_bp = Blueprint("portfolios", __name__) @@ -31,4 +32,20 @@ def portfolio(): ) return False - return {"portfolio": portfolio, "permissions": Permissions, "user_can": user_can} + active_task_orders = [ + task_order for task_order in portfolio.task_orders if task_order.is_active + ] + funding_end_date = ( + sorted(active_task_orders, key=attrgetter("end_date"))[-1].end_date + if active_task_orders + else None + ) + funded = len(active_task_orders) > 1 + + return { + "portfolio": portfolio, + "permissions": Permissions, + "user_can": user_can, + "funding_end_date": funding_end_date, + "funded": funded, + } diff --git a/styles/components/_portfolio_layout.scss b/styles/components/_portfolio_layout.scss index f5671413..3def404f 100644 --- a/styles/components/_portfolio_layout.scss +++ b/styles/components/_portfolio_layout.scss @@ -89,6 +89,32 @@ } } } + + .cents { + font-size: 2rem; + margin-top: .75rem; + font-weight: bold; + } + + .portfolio-funding__header--funded-through { + flex-grow: 1; + text-align: left; + font-weight: bold; + } + + .funded { + color: $color-blue; + .icon { + @include icon-color($color-blue); + } + } + + .unfunded { + color: $color-red; + .icon { + @include icon-color($color-red); + } + } } @mixin subheading { diff --git a/templates/portfolios/header.html b/templates/portfolios/header.html index 63b1a546..fe8ced23 100644 --- a/templates/portfolios/header.html +++ b/templates/portfolios/header.html @@ -22,7 +22,7 @@ {{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | justDollars }} - + {{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | justCents }}