mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Merge pull request #3459 from alphagov/delete-cache-on-archive
Delete cached users and templates when archiving a service
This commit is contained in:
@@ -302,7 +302,11 @@ def archive_service(service_id):
|
||||
):
|
||||
abort(403)
|
||||
if request.method == 'POST':
|
||||
service_api_client.archive_service(service_id)
|
||||
# We need to purge the cache for the services users as otherwise, although they will have had their permissions
|
||||
# removed in the DB, they would still have permissions in the cache to view/edit/manage this service
|
||||
cached_service_user_ids = [user.id for user in current_service.active_users]
|
||||
|
||||
service_api_client.archive_service(service_id, cached_service_user_ids)
|
||||
flash(
|
||||
'‘{}’ was deleted'.format(current_service.name),
|
||||
'default_with_tick',
|
||||
|
||||
@@ -129,7 +129,10 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
return self.update_service(service_id, **properties)
|
||||
|
||||
@cache.delete('service-{service_id}')
|
||||
def archive_service(self, service_id):
|
||||
@cache.delete('service-{service_id}-templates')
|
||||
def archive_service(self, service_id, cached_service_user_ids):
|
||||
if cached_service_user_ids:
|
||||
cache.delete(*map('user-{}'.format, cached_service_user_ids))
|
||||
return self.post('/service/{}/archive'.format(service_id), data=None)
|
||||
|
||||
@cache.delete('service-{service_id}')
|
||||
|
||||
Reference in New Issue
Block a user