mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 17:38:50 -04:00
DRY-up and enforce kwargs for most events
For most events this makes the purpose of each argument clearer at the point the event is called. It's still worth having a function for each event type, as this abstracts knowledge of the event label. Using a schema approach will make adding new events easier. In the next commit we'll DRY-up the duplication in the tests as well.
This commit is contained in:
@@ -44,7 +44,7 @@ def archive_user(user_id):
|
||||
flash('User can’t 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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -429,7 +429,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),
|
||||
@@ -449,7 +449,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?",
|
||||
|
||||
Reference in New Issue
Block a user