mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Revert "Avoid extra query when serialising Template created_by"
This reverts commit 58a9862cd1.
That commit tried to optimize the fetch template query by
However it had the side effect of making Marshmallow ignore `created_by`
when loading the JSON in the post request. So the field on the model was
never being updated, just copied from the original template.
The quick way of getting things to work again is to revert this
optimisation.
There’s probably some Marshmallow magic we could use to avoid the extra
query and still have created_by not be ignored.
It does mean we’re introducing an extra query, but I’m not too fussed
about that since the caching seems to be working well.
This commit is contained in:
@@ -356,9 +356,7 @@ class BaseTemplateSchema(BaseSchema):
|
||||
|
||||
class TemplateSchema(BaseTemplateSchema, UUIDsAsStringsMixin):
|
||||
|
||||
created_by_id = field_for(
|
||||
models.Template, 'created_by_id', dump_to='created_by', dump_only=True
|
||||
)
|
||||
created_by = field_for(models.Template, 'created_by', required=True)
|
||||
process_type = field_for(models.Template, 'process_type')
|
||||
redact_personalisation = fields.Method("redact")
|
||||
|
||||
@@ -372,9 +370,6 @@ class TemplateSchema(BaseTemplateSchema, UUIDsAsStringsMixin):
|
||||
if not subject or subject.strip() == '':
|
||||
raise ValidationError('Invalid template subject', 'subject')
|
||||
|
||||
class Meta(BaseTemplateSchema.Meta):
|
||||
exclude = BaseTemplateSchema.Meta.exclude + ('created_by',)
|
||||
|
||||
|
||||
class TemplateSchemaNoDetail(TemplateSchema):
|
||||
class Meta(TemplateSchema.Meta):
|
||||
|
||||
Reference in New Issue
Block a user