From 4f8cbc2b68045538b1522655adfdc230abc63838 Mon Sep 17 00:00:00 2001
From: dandds
Date: Tue, 24 Sep 2019 09:55:31 -0400
Subject: [PATCH] Delete unused Jinja macros and rearrange templates.
Templates and fragments that relate to specific resources (portfolios,
applications, task orders) should reside in directories named for the
relevant resource. This also matches the way the application routes are
distributed among modules named for each resource type.
---
atst/routes/applications/index.py | 2 +-
atst/routes/applications/new.py | 8 +++----
atst/routes/applications/settings.py | 2 +-
atst/routes/task_orders/index.py | 6 ++---
.../{portfolios => }/applications/base.html | 0
.../fragments}/add_new_environment.html | 0
.../fragments}/member_perms_form_fields.html | 0
.../fragments}/new_member_modal_content.html | 2 +-
.../{portfolios => }/applications/index.html | 0
.../applications/new/step_1.html | 4 ++--
.../applications/new/step_2.html | 2 +-
.../applications/settings.html | 10 ++++----
templates/components/totals_box.html | 18 ---------------
templates/components/user_info.html | 23 -------------------
templates/portfolios/admin.html | 6 ++---
.../fragments}/add_new_portfolio_member.html | 0
.../fragments}/change_ppoc.html | 0
.../fragments/delete_portfolio.html | 0
.../fragments}/members_edit.html | 0
.../fragments}/members_view.html | 0
.../fragments}/portfolio_members.html | 6 ++---
.../fragments/primary_point_of_contact.html | 2 +-
.../fragments/task_order_review.html | 18 ++++++++++++---
.../{portfolios => }/task_orders/index.html | 0
.../{portfolios => }/task_orders/review.html | 2 +-
templates/task_orders/step_4.html | 2 +-
26 files changed, 41 insertions(+), 72 deletions(-)
rename templates/{portfolios => }/applications/base.html (100%)
rename templates/{fragments/applications => applications/fragments}/add_new_environment.html (100%)
rename templates/{fragments/applications => applications/fragments}/member_perms_form_fields.html (100%)
rename templates/{fragments/applications => applications/fragments}/new_member_modal_content.html (97%)
rename templates/{portfolios => }/applications/index.html (100%)
rename templates/{portfolios => }/applications/new/step_1.html (97%)
rename templates/{portfolios => }/applications/new/step_2.html (98%)
rename templates/{portfolios => }/applications/settings.html (97%)
delete mode 100644 templates/components/totals_box.html
delete mode 100644 templates/components/user_info.html
rename templates/{fragments/admin => portfolios/fragments}/add_new_portfolio_member.html (100%)
rename templates/{fragments/admin => portfolios/fragments}/change_ppoc.html (100%)
rename templates/{ => portfolios}/fragments/delete_portfolio.html (100%)
rename templates/{fragments/admin => portfolios/fragments}/members_edit.html (100%)
rename templates/{fragments/admin => portfolios/fragments}/members_view.html (100%)
rename templates/{fragments/admin => portfolios/fragments}/portfolio_members.html (95%)
rename templates/{ => portfolios}/fragments/primary_point_of_contact.html (91%)
rename templates/{ => task_orders}/fragments/task_order_review.html (76%)
rename templates/{portfolios => }/task_orders/index.html (100%)
rename templates/{portfolios => }/task_orders/review.html (88%)
diff --git a/atst/routes/applications/index.py b/atst/routes/applications/index.py
index d4b2f276..e89b1efa 100644
--- a/atst/routes/applications/index.py
+++ b/atst/routes/applications/index.py
@@ -23,4 +23,4 @@ def has_portfolio_applications(_user, portfolio=None, **_kwargs):
message="view portfolio applications",
)
def portfolio_applications(portfolio_id):
- return render_template("portfolios/applications/index.html")
+ return render_template("applications/index.html")
diff --git a/atst/routes/applications/new.py b/atst/routes/applications/new.py
index 40477666..2f3ce510 100644
--- a/atst/routes/applications/new.py
+++ b/atst/routes/applications/new.py
@@ -37,7 +37,7 @@ def render_new_application_form(
@user_can(Permissions.CREATE_APPLICATION, message="view create new application form")
def view_new_application_step_1(portfolio_id, application_id=None):
return render_new_application_form(
- "portfolios/applications/new/step_1.html",
+ "applications/new/step_1.html",
NameAndDescriptionForm,
portfolio_id=portfolio_id,
application_id=application_id,
@@ -78,7 +78,7 @@ def create_or_update_new_application_step_1(portfolio_id, application_id=None):
else:
return (
render_new_application_form(
- "portfolios/applications/new/step_1.html",
+ "applications/new/step_1.html",
NameAndDescriptionForm,
portfolio_id,
application_id,
@@ -94,7 +94,7 @@ def create_or_update_new_application_step_1(portfolio_id, application_id=None):
@user_can(Permissions.CREATE_APPLICATION, message="view create new application form")
def view_new_application_step_2(portfolio_id, application_id):
return render_new_application_form(
- "portfolios/applications/new/step_2.html",
+ "applications/new/step_2.html",
EnvironmentsForm,
portfolio_id=portfolio_id,
application_id=application_id,
@@ -122,7 +122,7 @@ def update_new_application_step_2(portfolio_id, application_id):
else:
return (
render_new_application_form(
- "portfolios/applications/new/step_2.html",
+ "applications/new/step_2.html",
EnvironmentsForm,
portfolio_id,
application_id,
diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py
index 144800fd..8bc002bc 100644
--- a/atst/routes/applications/settings.py
+++ b/atst/routes/applications/settings.py
@@ -130,7 +130,7 @@ def render_settings_page(application, **kwargs):
)
return render_template(
- "portfolios/applications/settings.html",
+ "applications/settings.html",
application=application,
environments_obj=environments_obj,
new_env_form=new_env_form,
diff --git a/atst/routes/task_orders/index.py b/atst/routes/task_orders/index.py
index beb1d653..7ce6fc3e 100644
--- a/atst/routes/task_orders/index.py
+++ b/atst/routes/task_orders/index.py
@@ -18,7 +18,7 @@ def review_task_order(task_order_id):
else:
signature_form = SignatureForm()
return render_template(
- "portfolios/task_orders/review.html",
+ "task_orders/review.html",
task_order=task_order,
signature_form=signature_form,
)
@@ -37,7 +37,5 @@ def portfolio_funding(portfolio_id):
TaskOrderStatus.UNSIGNED: "purple",
}
return render_template(
- "portfolios/task_orders/index.html",
- task_orders=task_orders,
- label_colors=label_colors,
+ "task_orders/index.html", task_orders=task_orders, label_colors=label_colors
)
diff --git a/templates/portfolios/applications/base.html b/templates/applications/base.html
similarity index 100%
rename from templates/portfolios/applications/base.html
rename to templates/applications/base.html
diff --git a/templates/fragments/applications/add_new_environment.html b/templates/applications/fragments/add_new_environment.html
similarity index 100%
rename from templates/fragments/applications/add_new_environment.html
rename to templates/applications/fragments/add_new_environment.html
diff --git a/templates/fragments/applications/member_perms_form_fields.html b/templates/applications/fragments/member_perms_form_fields.html
similarity index 100%
rename from templates/fragments/applications/member_perms_form_fields.html
rename to templates/applications/fragments/member_perms_form_fields.html
diff --git a/templates/fragments/applications/new_member_modal_content.html b/templates/applications/fragments/new_member_modal_content.html
similarity index 97%
rename from templates/fragments/applications/new_member_modal_content.html
rename to templates/applications/fragments/new_member_modal_content.html
index 14fa7019..bc3bd4d2 100644
--- a/templates/fragments/applications/new_member_modal_content.html
+++ b/templates/applications/fragments/new_member_modal_content.html
@@ -2,7 +2,7 @@
{% from "components/text_input.html" import TextInput %}
{% from "components/checkbox_input.html" import CheckboxInput %}
{% from "components/phone_input.html" import PhoneInput %}
-{% from "fragments/applications/member_perms_form_fields.html" import MemberPermsFields %}
+{% from "applications/fragments/member_perms_form_fields.html" import MemberPermsFields %}
{% macro MemberFormTemplate(title, next_button, previous=True) %}
{% if user_can(permissions.CREATE_APPLICATION_MEMBER) %}
- {% import "fragments/applications/new_member_modal_content.html" as member_steps %}
+ {% import "applications/fragments/new_member_modal_content.html" as member_steps %}
{{ MultiStepModalForm(
name=new_member_modal_name,
form=new_member_form,
@@ -205,7 +205,7 @@
{{ 'common.resource_names.environments' | translate }}
{% if user_can(permissions.CREATE_ENVIRONMENT) %}
- {% include "fragments/applications/add_new_environment.html" %}
+ {% include "applications/fragments/add_new_environment.html" %}
{% endif %}
diff --git a/templates/components/totals_box.html b/templates/components/totals_box.html
deleted file mode 100644
index 1369c52d..00000000
--- a/templates/components/totals_box.html
+++ /dev/null
@@ -1,18 +0,0 @@
-{% macro TotalsBox(task_order=None, obligated_funds=0, contract_amount=0) -%}
-
-
- {% if task_order %}
- {% set obligated_funds = task_order.total_obligated_funds %}
- {% set contract_amount = task_order.total_contract_amount %}
- {% endif %}
-
-
{{ 'components.totals_box.obligated_funds' | translate }}
-
{{ obligated_funds | dollars }}
-
{{ 'components.totals_box.obligated_text' | translate }}
-
{{ 'components.totals_box.total_amount' | translate }}
-
{{ contract_amount | dollars }}
-
{{ 'components.totals_box.total_text' | translate }}
-
-
-
-{%- endmacro %}
diff --git a/templates/components/user_info.html b/templates/components/user_info.html
deleted file mode 100644
index aa2507ee..00000000
--- a/templates/components/user_info.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% from "components/text_input.html" import TextInput %}
-
-{% macro UserInfo(first_name, last_name, email, phone) -%}
-
-
-
-{% endmacro %}
diff --git a/templates/portfolios/admin.html b/templates/portfolios/admin.html
index fe2727af..027231b4 100644
--- a/templates/portfolios/admin.html
+++ b/templates/portfolios/admin.html
@@ -53,15 +53,15 @@
{% if user_can(permissions.VIEW_PORTFOLIO_POC) %}
- {% include "fragments/primary_point_of_contact.html" %}
+ {% include "portfolios/fragments/primary_point_of_contact.html" %}
{% endif %}
{% if user_can(permissions.ARCHIVE_PORTFOLIO) %}
- {% include "fragments/delete_portfolio.html" %}
+ {% include "portfolios/fragments/delete_portfolio.html" %}
{% endif %}
{% if user_can(permissions.VIEW_PORTFOLIO_USERS) %}
- {% include "fragments/admin/portfolio_members.html" %}
+ {% include "portfolios/fragments/portfolio_members.html" %}
{% endif %}
{% if user_can(permissions.VIEW_PORTFOLIO_ACTIVITY_LOG) %}
diff --git a/templates/fragments/admin/add_new_portfolio_member.html b/templates/portfolios/fragments/add_new_portfolio_member.html
similarity index 100%
rename from templates/fragments/admin/add_new_portfolio_member.html
rename to templates/portfolios/fragments/add_new_portfolio_member.html
diff --git a/templates/fragments/admin/change_ppoc.html b/templates/portfolios/fragments/change_ppoc.html
similarity index 100%
rename from templates/fragments/admin/change_ppoc.html
rename to templates/portfolios/fragments/change_ppoc.html
diff --git a/templates/fragments/delete_portfolio.html b/templates/portfolios/fragments/delete_portfolio.html
similarity index 100%
rename from templates/fragments/delete_portfolio.html
rename to templates/portfolios/fragments/delete_portfolio.html
diff --git a/templates/fragments/admin/members_edit.html b/templates/portfolios/fragments/members_edit.html
similarity index 100%
rename from templates/fragments/admin/members_edit.html
rename to templates/portfolios/fragments/members_edit.html
diff --git a/templates/fragments/admin/members_view.html b/templates/portfolios/fragments/members_view.html
similarity index 100%
rename from templates/fragments/admin/members_view.html
rename to templates/portfolios/fragments/members_view.html
diff --git a/templates/fragments/admin/portfolio_members.html b/templates/portfolios/fragments/portfolio_members.html
similarity index 95%
rename from templates/fragments/admin/portfolio_members.html
rename to templates/portfolios/fragments/portfolio_members.html
index 4ab00357..ef0fb0d7 100644
--- a/templates/fragments/admin/portfolio_members.html
+++ b/templates/portfolios/fragments/portfolio_members.html
@@ -47,9 +47,9 @@
{% if user_can(permissions.EDIT_PORTFOLIO_USERS) %}
- {% include "fragments/admin/members_edit.html" %}
+ {% include "portfolios/fragments/members_edit.html" %}
{% elif user_can(permissions.VIEW_PORTFOLIO_USERS) %}
- {% include "fragments/admin/members_view.html" %}
+ {% include "portfolios/fragments/members_view.html" %}
{% endif %}
@@ -73,7 +73,7 @@
{% if user_can(permissions.CREATE_PORTFOLIO_USERS) %}
- {% include "fragments/admin/add_new_portfolio_member.html" %}
+ {% include "portfolios/fragments/add_new_portfolio_member.html" %}
{% endif %}
{% if user_can(permissions.EDIT_PORTFOLIO_USERS) %}
diff --git a/templates/fragments/primary_point_of_contact.html b/templates/portfolios/fragments/primary_point_of_contact.html
similarity index 91%
rename from templates/fragments/primary_point_of_contact.html
rename to templates/portfolios/fragments/primary_point_of_contact.html
index fbdaabe5..3b1fcf2c 100644
--- a/templates/fragments/primary_point_of_contact.html
+++ b/templates/portfolios/fragments/primary_point_of_contact.html
@@ -19,7 +19,7 @@
{% if user_can(permissions.EDIT_PORTFOLIO_POC) %}
- {% include "fragments/admin/change_ppoc.html" %}
+ {% include "portfolios/fragments/change_ppoc.html" %}
{% endif %}
diff --git a/templates/fragments/task_order_review.html b/templates/task_orders/fragments/task_order_review.html
similarity index 76%
rename from templates/fragments/task_order_review.html
rename to templates/task_orders/fragments/task_order_review.html
index 3956da3d..a97d8e09 100644
--- a/templates/fragments/task_order_review.html
+++ b/templates/task_orders/fragments/task_order_review.html
@@ -1,6 +1,5 @@
{% from "components/icon.html" import Icon %}
{% from "components/semi_collapsible_text.html" import SemiCollapsibleText %}
-{% from "components/totals_box.html" import TotalsBox %}
@@ -10,7 +9,20 @@
{{ "task_orders.review.review_your_funding" | translate }}
- {{ TotalsBox(task_order=task_order) }}
+
+ {% if task_order %}
+ {% set obligated_funds = task_order.total_obligated_funds %}
+ {% set contract_amount = task_order.total_contract_amount %}
+ {% endif %}
+
+
{{ 'components.totals_box.obligated_funds' | translate }}
+
{{ obligated_funds | dollars }}
+
{{ 'components.totals_box.obligated_text' | translate }}
+
{{ 'components.totals_box.total_amount' | translate }}
+
{{ contract_amount | dollars }}
+
{{ 'components.totals_box.total_text' | translate }}
+
+
@@ -35,7 +47,7 @@
{{ "task_orders.review.funding_summary" | translate }}
-
+
diff --git a/templates/portfolios/task_orders/index.html b/templates/task_orders/index.html
similarity index 100%
rename from templates/portfolios/task_orders/index.html
rename to templates/task_orders/index.html
diff --git a/templates/portfolios/task_orders/review.html b/templates/task_orders/review.html
similarity index 88%
rename from templates/portfolios/task_orders/review.html
rename to templates/task_orders/review.html
index 293d29ea..39fd8128 100644
--- a/templates/portfolios/task_orders/review.html
+++ b/templates/task_orders/review.html
@@ -11,6 +11,6 @@
{% endcall %}
- {% include "fragments/task_order_review.html" %}
+ {% include "task_orders/fragments/task_order_review.html" %}
{% endblock %}
diff --git a/templates/task_orders/step_4.html b/templates/task_orders/step_4.html
index 0a80f6fe..86006054 100644
--- a/templates/task_orders/step_4.html
+++ b/templates/task_orders/step_4.html
@@ -13,5 +13,5 @@
{% endblock %}
{% block to_builder_form_field %}
- {% include "fragments/task_order_review.html" %}
+ {% include "task_orders/fragments/task_order_review.html" %}
{% endblock %}