mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Clear service cache for when updating org branding
Updating an organisation’s branding might now also update the branding of services associated to that organisation. This is similar to how updating an organisation’s type can update the organisation type for its services. In the latter case we already make sure to clear the cached version of these services which is held in Redis. This commit does the same clearing of the caches when updating an organisation’s branding (and does a bit of refactoring to do so without duplication of code.)
This commit is contained in:
@@ -135,6 +135,10 @@ class Organisation(JSONModel):
|
||||
def services(self):
|
||||
return organisations_client.get_organisation_services(self.id)
|
||||
|
||||
@cached_property
|
||||
def service_ids(self):
|
||||
return [s['id'] for s in self.services]
|
||||
|
||||
@property
|
||||
def live_services(self):
|
||||
return [s for s in self.services if s['active'] and not s['restricted']]
|
||||
@@ -180,8 +184,12 @@ class Organisation(JSONModel):
|
||||
self.letter_branding_id
|
||||
)
|
||||
|
||||
def update(self, **kwargs):
|
||||
response = organisations_client.update_organisation(self.id, **kwargs)
|
||||
def update(self, delete_services_cache=False, **kwargs):
|
||||
response = organisations_client.update_organisation(
|
||||
self.id,
|
||||
cached_service_ids=self.service_ids if delete_services_cache else None,
|
||||
**kwargs
|
||||
)
|
||||
self.__init__(response)
|
||||
|
||||
def associate_service(self, service_id):
|
||||
|
||||
Reference in New Issue
Block a user