diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py index f2d252a9..7d5c20d4 100644 --- a/atst/routes/applications/settings.py +++ b/atst/routes/applications/settings.py @@ -337,21 +337,6 @@ def update(application_id): return render_settings_page(application=application, application_form=form) -@applications_bp.route("/applications//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//delete", methods=["POST"]) @user_can(Permissions.DELETE_ENVIRONMENT, message="delete environment") def delete_environment(environment_id): diff --git a/templates/applications/settings.html b/templates/applications/settings.html index c8e41fcd..9d2fb146 100644 --- a/templates/applications/settings.html +++ b/templates/applications/settings.html @@ -59,59 +59,8 @@ environments_obj, 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 %} - -

- {{ "portfolios.applications.delete.subheading" | translate }} -

-
-
- {{ "portfolios.applications.delete.text" | translate({"application_name": application.name}) | safe }} -
-
-
- -
-
-
- - {% call Modal(name="delete-application") %} -

{{ "portfolios.applications.delete.header" | translate }}

-
- {{ - 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 %} - -
- {% if user_can(permissions.VIEW_APPLICATION_ACTIVITY_LOG) and config.get("USE_AUDIT_LOG", False) %} +
{% include "fragments/audit_events_log.html" %} {{ Pagination(audit_events, url=url_for('applications.settings', application_id=application.id)) }} {% endif %} diff --git a/tests/routes/applications/test_settings.py b/tests/routes/applications/test_settings.py index 08c979ad..cd075c80 100644 --- a/tests/routes/applications/test_settings.py +++ b/tests/routes/applications/test_settings.py @@ -288,41 +288,6 @@ def test_user_can_only_access_apps_in_their_portfolio(client, user_session): 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): user = UserFactory.create() portfolio = PortfolioFactory(owner=user) diff --git a/tests/test_access.py b/tests/test_access.py index ad4bd5be..5c8d5ae1 100644 --- a/tests/test_access.py +++ b/tests/test_access.py @@ -343,40 +343,6 @@ def test_portfolios_invite_member_access(post_url_assert_status): 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 def test_application_settings_access(get_url_assert_status): ccpo = user_with(PermissionSets.VIEW_PORTFOLIO_APPLICATION_MANAGEMENT)