Let users archive their own trial mode services

At the moment we have a blanket rule that users can’t archive their own
services, to prevent someone accidentally deleting a real live service,
because that would be Very Bad.

But the tickets we get from users asking us to delete services are for
services they set up when they were just trying out Notify. There’s not
much harm in letting users delete these services, the consequences of
doing so are much lower than those of deleting a live service. And it
should mean fewer support tickets for us to deal with.
This commit is contained in:
Chris Hill-Scott
2019-05-29 16:51:25 +01:00
parent 5e9f70c62c
commit 954f43ae48
6 changed files with 96 additions and 45 deletions

View File

@@ -330,11 +330,22 @@ def service_switch_can_upload_document(service_id):
@login_required
@user_has_permissions('manage_service')
def archive_service(service_id):
if not current_service.active and (
current_service.trial_mode or current_user.platform_admin
):
abort(403)
if request.method == 'POST':
service_api_client.archive_service(service_id)
return redirect(url_for('.service_settings', service_id=service_id))
flash(
'{} was deleted'.format(current_service.name),
'default_with_tick',
)
return redirect(url_for('.choose_account'))
else:
flash('There\'s no way to reverse this! Are you sure you want to archive this service?', 'delete')
flash(
'Are you sure you want to delete {}? Theres no way to undo this.'.format(current_service.name),
'delete',
)
return service_settings(service_id)