mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-10 23:32:27 -05:00
Ensure templates are cached with correct schema
For some reason our V1 get template response wraps the whole template in
a dictionary with one key, `'data'`:
0d99033889/app/template/rest.py (L166)
That means when the admin app caches the response it also caches it in
this format.
The API needs to do the same, otherwise it will be cacheing data with a
schema that the admin app isn’t expecting, and vice-versa.
This commit is contained in:
@@ -69,7 +69,7 @@ class SerialisedTemplate(SerialisedModel):
|
||||
@classmethod
|
||||
@memory_cache
|
||||
def from_id_and_service_id(cls, template_id, service_id):
|
||||
return cls(cls.get_dict(template_id, service_id))
|
||||
return cls(cls.get_dict(template_id, service_id)['data'])
|
||||
|
||||
@staticmethod
|
||||
@redis_cache.set('template-{template_id}-version-None')
|
||||
@@ -83,4 +83,4 @@ class SerialisedTemplate(SerialisedModel):
|
||||
|
||||
template_dict = template_schema.dump(fetched_template).data
|
||||
|
||||
return template_dict
|
||||
return {'data': template_dict}
|
||||
|
||||
Reference in New Issue
Block a user