Remove route, tests, and template code for deleting an application
This commit is contained in:
parent
a227044ccf
commit
5b55b5800e
@ -337,21 +337,6 @@ def update(application_id):
|
|||||||
return render_settings_page(application=application, application_form=form)
|
return render_settings_page(application=application, application_form=form)
|
||||||
|
|
||||||
|
|
||||||
@applications_bp.route("/applications/<application_id>/delete", methods=["POST"])
|
|
||||||
@user_can(Permissions.DELETE_APPLICATION, message="delete application")
|
|
||||||
def delete(application_id):
|
|
||||||
application = Applications.get(application_id)
|
|
||||||
Applications.delete(application)
|
|
||||||
|
|
||||||
flash("application_deleted", application_name=application.name)
|
|
||||||
|
|
||||||
return redirect(
|
|
||||||
url_for(
|
|
||||||
"applications.portfolio_applications", portfolio_id=application.portfolio_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@applications_bp.route("/environments/<environment_id>/delete", methods=["POST"])
|
@applications_bp.route("/environments/<environment_id>/delete", methods=["POST"])
|
||||||
@user_can(Permissions.DELETE_ENVIRONMENT, message="delete environment")
|
@user_can(Permissions.DELETE_ENVIRONMENT, message="delete environment")
|
||||||
def delete_environment(environment_id):
|
def delete_environment(environment_id):
|
||||||
|
@ -59,59 +59,8 @@
|
|||||||
environments_obj,
|
environments_obj,
|
||||||
new_env_form) }}
|
new_env_form) }}
|
||||||
|
|
||||||
{% if user_can(permissions.DELETE_APPLICATION) %}
|
|
||||||
{% set env_count = application.environments | length %}
|
|
||||||
{% if env_count == 1 %}
|
|
||||||
{% set pluralized_env = "environment" %}
|
|
||||||
{% else %}
|
|
||||||
{% set pluralized_env = "environments" %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<h3>
|
|
||||||
{{ "portfolios.applications.delete.subheading" | translate }}
|
|
||||||
</h3>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-col form-col--two-thirds">
|
|
||||||
{{ "portfolios.applications.delete.text" | translate({"application_name": application.name}) | safe }}
|
|
||||||
</div>
|
|
||||||
<div class="form-col form-col--third">
|
|
||||||
<div class="usa-input">
|
|
||||||
<input
|
|
||||||
id="delete-application"
|
|
||||||
type="button"
|
|
||||||
v-on:click="openModal('delete-application')"
|
|
||||||
class='usa-button--outline button-danger-outline'
|
|
||||||
value="{{ 'portfolios.applications.delete.button' | translate }}"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% call Modal(name="delete-application") %}
|
|
||||||
<h1>{{ "portfolios.applications.delete.header" | translate }}</h1>
|
|
||||||
<hr>
|
|
||||||
{{
|
|
||||||
Alert(
|
|
||||||
title=("components.modal.destructive_title" | translate),
|
|
||||||
message=("portfolios.applications.delete.alert.message" | translate),
|
|
||||||
level="warning"
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{
|
|
||||||
DeleteConfirmation(
|
|
||||||
modal_id="delete_application",
|
|
||||||
delete_text=('portfolios.applications.delete.button' | translate),
|
|
||||||
delete_action= url_for('applications.delete', application_id=application.id),
|
|
||||||
form=application_form
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
{% endcall %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
{% if user_can(permissions.VIEW_APPLICATION_ACTIVITY_LOG) and config.get("USE_AUDIT_LOG", False) %}
|
{% if user_can(permissions.VIEW_APPLICATION_ACTIVITY_LOG) and config.get("USE_AUDIT_LOG", False) %}
|
||||||
|
<hr>
|
||||||
{% include "fragments/audit_events_log.html" %}
|
{% include "fragments/audit_events_log.html" %}
|
||||||
{{ Pagination(audit_events, url=url_for('applications.settings', application_id=application.id)) }}
|
{{ Pagination(audit_events, url=url_for('applications.settings', application_id=application.id)) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -288,41 +288,6 @@ def test_user_can_only_access_apps_in_their_portfolio(client, user_session):
|
|||||||
assert time_updated == other_application.time_updated
|
assert time_updated == other_application.time_updated
|
||||||
|
|
||||||
|
|
||||||
def test_delete_application(client, user_session):
|
|
||||||
user = UserFactory.create()
|
|
||||||
port = PortfolioFactory.create(
|
|
||||||
owner=user,
|
|
||||||
applications=[
|
|
||||||
{
|
|
||||||
"name": "mos eisley",
|
|
||||||
"environments": [
|
|
||||||
{"name": "bar"},
|
|
||||||
{"name": "booth"},
|
|
||||||
{"name": "band stage"},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
)
|
|
||||||
application = port.applications[0]
|
|
||||||
user_session(user)
|
|
||||||
|
|
||||||
response = client.post(
|
|
||||||
url_for("applications.delete", application_id=application.id)
|
|
||||||
)
|
|
||||||
# appropriate response and redirect
|
|
||||||
assert response.status_code == 302
|
|
||||||
assert response.location == url_for(
|
|
||||||
"applications.portfolio_applications", portfolio_id=port.id, _external=True
|
|
||||||
)
|
|
||||||
# appropriate flash message
|
|
||||||
message = get_flashed_messages()[0]
|
|
||||||
assert "deleted" in message["message"]
|
|
||||||
assert application.name in message["message"]
|
|
||||||
# app and envs are soft deleted
|
|
||||||
assert len(port.applications) == 0
|
|
||||||
assert len(application.environments) == 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_new_environment(client, user_session):
|
def test_new_environment(client, user_session):
|
||||||
user = UserFactory.create()
|
user = UserFactory.create()
|
||||||
portfolio = PortfolioFactory(owner=user)
|
portfolio = PortfolioFactory(owner=user)
|
||||||
|
@ -343,40 +343,6 @@ def test_portfolios_invite_member_access(post_url_assert_status):
|
|||||||
post_url_assert_status(rando, url, 404)
|
post_url_assert_status(rando, url, 404)
|
||||||
|
|
||||||
|
|
||||||
# applications.delete
|
|
||||||
def test_applications_delete_access(post_url_assert_status, monkeypatch):
|
|
||||||
ccpo = UserFactory.create_ccpo()
|
|
||||||
owner = user_with()
|
|
||||||
app_admin = user_with()
|
|
||||||
rando = user_with()
|
|
||||||
|
|
||||||
portfolio = PortfolioFactory.create(
|
|
||||||
owner=owner, applications=[{"name": "mos eisley"}]
|
|
||||||
)
|
|
||||||
application = portfolio.applications[0]
|
|
||||||
|
|
||||||
ApplicationRoleFactory.create(
|
|
||||||
user=app_admin,
|
|
||||||
application=application,
|
|
||||||
permission_sets=PermissionSets.get_many(
|
|
||||||
[
|
|
||||||
PermissionSets.VIEW_APPLICATION,
|
|
||||||
PermissionSets.EDIT_APPLICATION_ENVIRONMENTS,
|
|
||||||
PermissionSets.EDIT_APPLICATION_TEAM,
|
|
||||||
PermissionSets.DELETE_APPLICATION_ENVIRONMENTS,
|
|
||||||
]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
monkeypatch.setattr("atst.domain.applications.Applications.delete", lambda *a: True)
|
|
||||||
|
|
||||||
url = url_for("applications.delete", application_id=application.id)
|
|
||||||
post_url_assert_status(app_admin, url, 404)
|
|
||||||
post_url_assert_status(rando, url, 404)
|
|
||||||
post_url_assert_status(owner, url, 302)
|
|
||||||
post_url_assert_status(ccpo, url, 302)
|
|
||||||
|
|
||||||
|
|
||||||
# applications.settings
|
# applications.settings
|
||||||
def test_application_settings_access(get_url_assert_status):
|
def test_application_settings_access(get_url_assert_status):
|
||||||
ccpo = user_with(PermissionSets.VIEW_PORTFOLIO_APPLICATION_MANAGEMENT)
|
ccpo = user_with(PermissionSets.VIEW_PORTFOLIO_APPLICATION_MANAGEMENT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user