From d7346d5a320bd71b52a191b7694d941bb460e3a9 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Tue, 4 Jun 2019 16:52:54 -0400 Subject: [PATCH] Try using new styles in the task orders page --- atst/filters.py | 5 + atst/routes/task_orders/index.py | 26 +--- templates/portfolios/task_orders/index.html | 130 +++++--------------- 3 files changed, 39 insertions(+), 122 deletions(-) diff --git a/atst/filters.py b/atst/filters.py index 02d51c5c..e6104ea5 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -82,6 +82,10 @@ def normalizeOrder(title): return " ".join(reordered_text) +def task_order_status_label(status): + return {"Pending": "warning", "Active": "success", "Expired": "error"}.get(status, "info") + + def register_filters(app): app.jinja_env.filters["iconSvg"] = iconSvg app.jinja_env.filters["dollars"] = dollars @@ -95,6 +99,7 @@ def register_filters(app): app.jinja_env.filters["renderAuditEvent"] = renderAuditEvent app.jinja_env.filters["normalizeOrder"] = normalizeOrder app.jinja_env.filters["translateDuration"] = translate_duration + app.jinja_env.filters["taskOrderStatusLabel"] = task_order_status_label @contextfilter def translateWithoutCache(context, *kwargs): diff --git a/atst/routes/task_orders/index.py b/atst/routes/task_orders/index.py index db42109d..6b440ea6 100644 --- a/atst/routes/task_orders/index.py +++ b/atst/routes/task_orders/index.py @@ -30,22 +30,6 @@ def review_task_order(task_order_id): return render_template("portfolios/task_orders/review.html", task_order=task_order) -def serialize_task_order(task_order): - return { - key: getattr(task_order, key) - for key in [ - "id", - "budget", - "time_created", - "start_date", - "end_date", - "display_status", - "days_to_expiration", - "balance", - ] - } - - @task_orders_bp.route("/portfolios//task_orders") @user_can(Permissions.VIEW_PORTFOLIO_FUNDING, message="view portfolio funding") def portfolio_funding(portfolio_id): @@ -53,14 +37,9 @@ def portfolio_funding(portfolio_id): task_orders_by_status = defaultdict(list) for task_order in portfolio.task_orders: - serialized_task_order = serialize_task_order(task_order) - serialized_task_order["url"] = url_for( - "task_orders.view_task_order", task_order_id=task_order.id - ) - task_orders_by_status[task_order.status].append(serialized_task_order) + task_orders_by_status[task_order.status].append(task_order) active_task_orders = task_orders_by_status.get(TaskOrderStatus.ACTIVE, []) - total_balance = sum([task_order["balance"] for task_order in active_task_orders]) return render_template( "portfolios/task_orders/index.html", @@ -69,6 +48,5 @@ def portfolio_funding(portfolio_id): + task_orders_by_status.get(TaskOrderStatus.PENDING, []) ), active_task_orders=active_task_orders, - expired_task_orders=task_orders_by_status.get(TaskOrderStatus.EXPIRED, []), - total_balance=total_balance, + expired_task_orders=task_orders_by_status.get(TaskOrderStatus.EXPIRED, []) ) diff --git a/templates/portfolios/task_orders/index.html b/templates/portfolios/task_orders/index.html index 469367f6..f3e6470f 100644 --- a/templates/portfolios/task_orders/index.html +++ b/templates/portfolios/task_orders/index.html @@ -13,93 +13,37 @@ {% endmacro %} -{% macro TaskOrderList(task_orders, label='success', expired=False, funded=False) %} -
-
- Pending - Started May 21, 2019 -
-
-

Task Order #12345

-
-
- This is a TO description. This is a TO description. This is a TO description. This is a TO description. This is a TO description. This is a TO description. -
-
+{% macro TaskOrderDate(task_order) %} + + {% if task_order.is_active %} + Began {{ task_order.start_date }}   |   Ends {{ task_order.end_date }} + {% elif task_order.is_expired %} + Started {{ task_order.start_date }}   |   Ended {{ task_order.end_date }} + {% else %} + Started {{ task_order.start_date }} + {% endif %} + +{% endmacro %} - -
- - - - - - - - - - - - - - - - {{ caller and caller() }} - -
- !{ col.displayName } - -
- !{ taskOrder.display_status } - - - - - - - - - - {{ Icon('ok') }} Period ending in !{ taskOrder.days_to_expiration } days, but new period funded - - - {{ Icon('alert') }} Period ends in !{ taskOrder.days_to_expiration } days, submit a new task order - - - - - - - - - View - {{ Icon("caret_right", classes="icon--tiny") }} - -
-
-
+{% macro TaskOrderList(task_orders) %} +
+ {% for task_order in task_orders %} +
+
+ {{ task_order.display_status }} + {{ TaskOrderDate(task_order) }} + + +
+
+

Task Order {{ task_order.number }}

+
+
+ This is a TO description. This is a TO description. This is a TO description. This is a TO description. This is a TO description. This is a TO description. +
+
+ {% endfor %} +
{% endmacro %}
@@ -144,21 +88,11 @@ {% endif %} {% if active_task_orders %} -
Active
- {% call TaskOrderList(active_task_orders, label='success', funded=funded) %} - - - Total Active Balance - {{ total_balance | dollars }} - -   - - {% endcall %} + {{ TaskOrderList(active_task_orders) }} {% endif %} {% if expired_task_orders %} -
Expired
- {{ TaskOrderList(expired_task_orders, label='expired', expired=True) }} + {{ TaskOrderList(expired_task_orders) }} {% endif %}