From a6caafada4e191641647bc950f4d1c9dc631a0d9 Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Fri, 6 Sep 2019 11:11:22 -0400 Subject: [PATCH] Update delete app button and section --- Pipfile | 1 + atst/filters.py | 11 ++++++ .../portfolios/applications/settings.html | 36 ++++++++++++++----- translations.yaml | 2 ++ 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Pipfile b/Pipfile index a84969ea..08d9e35b 100644 --- a/Pipfile +++ b/Pipfile @@ -26,6 +26,7 @@ azure-storage = "*" azure-storage-common = "*" boto3 = "*" celery = "*" +inflect = "*" [dev-packages] bandit = "*" diff --git a/atst/filters.py b/atst/filters.py index 48b8166c..408b5afa 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -1,5 +1,6 @@ import re import datetime +import inflect from atst.utils.localization import translate from flask import render_template from jinja2 import contextfilter @@ -67,6 +68,14 @@ def renderAuditEvent(event): return render_template("audit_log/events/default.html", event=event) +def numberToWords(integer): + return inflect.engine().number_to_words(integer) + + +def pluralize(word, number): + return inflect.engine().plural(word, number) + + def register_filters(app): app.jinja_env.filters["iconSvg"] = iconSvg app.jinja_env.filters["dollars"] = dollars @@ -76,6 +85,8 @@ def register_filters(app): app.jinja_env.filters["pageWindow"] = pageWindow app.jinja_env.filters["renderAuditEvent"] = renderAuditEvent app.jinja_env.filters["withExtraParams"] = with_extra_params + app.jinja_env.filters["numberToWords"] = numberToWords + app.jinja_env.filters["pluralize"] = pluralize @contextfilter def translateWithoutCache(context, *kwargs): diff --git a/templates/portfolios/applications/settings.html b/templates/portfolios/applications/settings.html index 574dd0b9..7ab84a3f 100644 --- a/templates/portfolios/applications/settings.html +++ b/templates/portfolios/applications/settings.html @@ -176,15 +176,35 @@ +
+ {% if user_can(permissions.DELETE_APPLICATION) %} -
- + {% set env_count = application.environments | length %} + {% set pluralized_env = "environment" | pluralize(env_count) %} + +
+ {{ "portfolios.applications.delete.subheading" | translate }} +
+ +
+
+
+
+ {{ "portfolios.applications.delete.panel_text" | translate({"name": application.name, "env_count": env_count | numberToWords, "pluralized_env": pluralized_env}) | safe }} +
+
+
+ +
+
+
+
{% call Modal(name="delete-application") %} diff --git a/translations.yaml b/translations.yaml index 4060ece1..faa4ad0e 100644 --- a/translations.yaml +++ b/translations.yaml @@ -298,6 +298,8 @@ portfolios: message: You will lose access to this application and all environments will be removed from the CSP. Your reporting and activity will still be accessible. button: Delete application header: Are you sure you want to delete this application? + panel_text: 'Deleting {name} will delete this applicaiton along with all {env_count} {pluralized_env}. This cannot be undone.' + subheading: Delete Application enter_env_name: "Enter environment name:" environments: name: Name