From 8aa302357b37a83aa5dbe72c62b1a0647a735031 Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Tue, 19 Nov 2019 11:01:07 -0500 Subject: [PATCH] Move label display logic into the Label macro --- atst/routes/applications/new.py | 1 - atst/routes/applications/settings.py | 14 -------------- .../applications/fragments/environments.html | 2 +- templates/applications/fragments/members.html | 14 ++++++++------ templates/components/label.html | 19 +++++++++++++++---- tests/models/test_application_role.py | 13 +++++-------- tests/routes/applications/test_settings.py | 3 --- 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/atst/routes/applications/new.py b/atst/routes/applications/new.py index 00aac3f5..a1a1a54c 100644 --- a/atst/routes/applications/new.py +++ b/atst/routes/applications/new.py @@ -153,7 +153,6 @@ def view_new_application_step_3(application_id): application=application, members=members, new_member_form=new_member_form, - label_info=LABEL_INFO, ) diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py index 215bdfd1..c166223c 100644 --- a/atst/routes/applications/settings.py +++ b/atst/routes/applications/settings.py @@ -21,19 +21,6 @@ from atst.utils.localization import translate from atst.jobs import send_mail -LABEL_INFO = { - "pending": {"icon": "envelope", "text": "invite pending", "type": "success",}, - "expired": {"icon": "envelope", "text": "invite expired", "type": "error",}, - "env_changes_pending": { - "icon": "exchange", - "text": "changes pending", - "type": "default", - }, - "active": None, - "disabled": None, -} - - def get_environments_obj_for_app(application): return sorted( [ @@ -177,7 +164,6 @@ def render_settings_page(application, **kwargs): audit_events=audit_events, new_member_form=new_member_form, members=members, - label_info=LABEL_INFO, **kwargs, ) diff --git a/templates/applications/fragments/environments.html b/templates/applications/fragments/environments.html index 23fa6f82..9e9a3ef8 100644 --- a/templates/applications/fragments/environments.html +++ b/templates/applications/fragments/environments.html @@ -54,7 +54,7 @@ {%- endif %}
{% if env['pending'] -%} - {{ Label('exchange', 'Changes Pending', classes='label--below')}} + {{ Label(type="changes_pending", classes='label--below')}} {% else %} {{ "portfolios.applications.csp_link" | translate }} {{ Icon('link', classes="icon--tiny") }} diff --git a/templates/applications/fragments/members.html b/templates/applications/fragments/members.html index b3ec0c35..a8e8d80b 100644 --- a/templates/applications/fragments/members.html +++ b/templates/applications/fragments/members.html @@ -33,6 +33,8 @@ {% else %} {% for member in members %} + {% set invite_pending = member.role_status == 'invite_pending' %} + {% set invite_expired = member.role_status == 'invite_expired' %} {%- if user_can(permissions.EDIT_APPLICATION_MEMBER) %} {% set modal_name = "edit_member-{}".format(loop.index) %} {% call Modal(modal_name, classes="form-content--app-mem") %} @@ -52,7 +54,7 @@ {% endcall %} - {%- if member.role_status == 'pending' or member.role_status == 'expired' %} + {%- if invite_pending or invite_expired %} {% set resend_invite_modal = "resend_invite-{}".format(member.role_id) %} {% call Modal(resend_invite_modal, classes="form-content--app-mem") %}