Merge pull request #1196 from dod-ccpo/revoke-env-access

Catch CSP exceptions and display a flash message with the error
This commit is contained in:
leigh-mil 2019-11-22 14:46:34 -05:00 committed by GitHub
commit 25a5cb136c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -6,6 +6,7 @@ from atst.domain.environments import Environments
from atst.domain.applications import Applications
from atst.domain.application_roles import ApplicationRoles
from atst.domain.audit_log import AuditLog
from atst.domain.csp.cloud import GeneralCSPException
from atst.domain.common import Paginator
from atst.domain.environment_roles import EnvironmentRoles
from atst.domain.invitations import ApplicationInvitations
@ -221,14 +222,22 @@ def handle_update_member(application_id, application_role_id, form_data):
)
if form.validate():
ApplicationRoles.update_permission_sets(app_role, form.data["permission_sets"])
try:
ApplicationRoles.update_permission_sets(
app_role, form.data["permission_sets"]
)
for env_role in form.environment_roles:
environment = Environments.get(env_role.environment_id.data)
new_role = None if env_role.disabled.data else env_role.data["role"]
Environments.update_env_role(environment, app_role, new_role)
for env_role in form.environment_roles:
environment = Environments.get(env_role.environment_id.data)
new_role = None if env_role.disabled.data else env_role.data["role"]
Environments.update_env_role(environment, app_role, new_role)
flash("application_member_updated", user_name=app_role.user_name)
flash("application_member_updated", user_name=app_role.user_name)
except GeneralCSPException:
flash(
"application_member_update_error", user_name=app_role.user_name,
)
else:
pass
# TODO: flash error message

View File

@ -54,6 +54,11 @@ MESSAGES = {
"message_template": "You have successfully deleted {{ user_name }} from {{ application_name }}",
"category": "success",
},
"application_member_update_error": {
"title_template": "{{ user_name }} could not be updated",
"message_template": "An unexpected problem occurred with your request, please try again. If the problem persists, contact an administrator.",
"category": "error",
},
"application_member_updated": {
"title_template": "Team member updated",
"message_template": "You have successfully updated the permissions for {{ user_name }}",