mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Delete service cache when changing an organisation's sector
When we change an organisation's sector we now also change the sector of all its services, so we need to delete those services from Redis.
This commit is contained in:
@@ -216,8 +216,11 @@ def edit_organisation_type(org_id):
|
||||
)
|
||||
|
||||
if form.validate_on_submit():
|
||||
org_service_ids = [service['id'] for service in current_organisation.services]
|
||||
|
||||
organisations_client.update_organisation(
|
||||
current_organisation.id,
|
||||
cached_service_ids=org_service_ids,
|
||||
organisation_type=form.organisation_type.data,
|
||||
)
|
||||
return redirect(url_for('.organisation_settings', org_id=org_id))
|
||||
|
||||
@@ -2,6 +2,7 @@ from itertools import chain
|
||||
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.extensions import redis_client
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
|
||||
|
||||
@@ -45,8 +46,13 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
|
||||
@cache.delete('domains')
|
||||
@cache.delete('organisations')
|
||||
def update_organisation(self, org_id, **kwargs):
|
||||
return self.post(url="/organisations/{}".format(org_id), data=kwargs)
|
||||
def update_organisation(self, org_id, cached_service_ids=None, **kwargs):
|
||||
api_response = self.post(url="/organisations/{}".format(org_id), data=kwargs)
|
||||
|
||||
if kwargs.get('organisation_type') and cached_service_ids:
|
||||
redis_client.delete(*map('service-{}'.format, cached_service_ids))
|
||||
|
||||
return api_response
|
||||
|
||||
def update_organisation_name(self, org_id, name):
|
||||
return self.update_organisation(org_id, name=name)
|
||||
|
||||
Reference in New Issue
Block a user