Merge pull request #3963 from alphagov/audit-service-resume-178770416

Audit when a service is resumed
This commit is contained in:
Ben Thorner
2021-07-13 12:09:54 +01:00
committed by GitHub
7 changed files with 171 additions and 184 deletions

View File

@@ -44,7 +44,7 @@ def archive_user(user_id):
flash('User cant be removed from a service - '
'check all services have another team member with manage_settings')
return redirect(url_for('main.user_information', user_id=user_id))
create_archive_user_event(str(user_id), current_user.id)
create_archive_user_event(user_id=str(user_id), archived_by_id=current_user.id)
return redirect(url_for('.user_information', user_id=user_id))
else:

View File

@@ -173,7 +173,11 @@ def remove_user_from_service(service_id, user_id):
else:
abort(500, e)
else:
create_remove_user_from_service_event(user_id=user_id, removed_by_id=current_user.id, service_id=service_id)
create_remove_user_from_service_event(
user_id=user_id,
removed_by_id=current_user.id,
service_id=service_id
)
return redirect(url_for(
'.manage_users',
@@ -228,7 +232,12 @@ def confirm_edit_user_email(service_id, user_id):
except HTTPError as e:
abort(500, e)
else:
create_email_change_event(user.id, current_user.id, user.email_address, new_email)
create_email_change_event(
user_id=user.id,
updated_by_id=current_user.id,
original_email_address=user.email_address,
new_email_address=new_email
)
finally:
session.pop(session_key, None)
@@ -286,7 +295,12 @@ def confirm_edit_user_mobile_number(service_id, user_id):
except HTTPError as e:
abort(500, e)
else:
create_mobile_number_change_event(user.id, current_user.id, user.mobile_number, new_number)
create_mobile_number_change_event(
user_id=user.id,
updated_by_id=current_user.id,
original_mobile_number=user.mobile_number,
new_mobile_number=new_number
)
finally:
session.pop('team_member_mobile_change', None)

View File

@@ -31,6 +31,7 @@ from app import (
from app.event_handlers import (
create_archive_service_event,
create_broadcast_account_type_change_event,
create_resume_service_event,
create_suspend_service_event,
)
from app.extensions import zendesk_client
@@ -430,7 +431,7 @@ def archive_service(service_id):
cached_service_user_ids = [user.id for user in current_service.active_users]
service_api_client.archive_service(service_id, cached_service_user_ids)
create_archive_service_event(service_id, archived_by_id=current_user.id)
create_archive_service_event(service_id=service_id, archived_by_id=current_user.id)
flash(
'{} was deleted'.format(current_service.name),
@@ -450,7 +451,7 @@ def archive_service(service_id):
def suspend_service(service_id):
if request.method == 'POST':
service_api_client.suspend_service(service_id)
create_suspend_service_event(service_id, suspended_by_id=current_user.id)
create_suspend_service_event(service_id=service_id, suspended_by_id=current_user.id)
return redirect(url_for('.service_settings', service_id=service_id))
else:
flash("This will suspend the service and revoke all api keys. Are you sure you want to suspend this service?",
@@ -463,6 +464,7 @@ def suspend_service(service_id):
def resume_service(service_id):
if request.method == 'POST':
service_api_client.resume_service(service_id)
create_resume_service_event(service_id=service_id, resumed_by_id=current_user.id)
return redirect(url_for('.service_settings', service_id=service_id))
else:
flash("This will resume the service. New api key are required for this service to use the API.", 'resume')