require fields in marshmallow schema to try and make it as hard

to break backwards compatability as possible
This commit is contained in:
Leo Hemsted
2016-08-10 10:59:22 +01:00
parent f184bb7996
commit 52b2f4f583

View File

@@ -294,6 +294,20 @@ class NotificationWithTemplateSchema(BaseSchema):
class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
class Meta(NotificationWithTemplateSchema.Meta):
# mark as many fields as possible as required since this is a public api.
# WARNING: Does _not_ reference fields computed in handle_template_merge, such as
# 'body', 'subject' [for emails], and 'content_char_count'
fields = (
# db rows
'id', 'to', 'job_row_number', 'template_version', 'billable_units', 'notification_type', 'created_at',
'sent_at', 'sent_by', 'updated_at', 'status', 'reference',
# computed fields
'personalisation',
# relationships
'service', 'job', 'api_key', 'template'
)
@pre_dump
def handle_personalisation_property(self, in_data):
self.personalisation = in_data.personalisation
@@ -533,7 +547,6 @@ job_email_template_notification_schema = JobEmailTemplateNotificationSchema()
notification_schema = NotificationModelSchema()
notification_with_template_schema = NotificationWithTemplateSchema()
notification_with_personalisation_schema = NotificationWithPersonalisationSchema()
notification_with_personalisation_schema_load_json = NotificationWithPersonalisationSchema(load_json=True)
invited_user_schema = InvitedUserSchema()
permission_schema = PermissionSchema()
email_data_request_schema = EmailDataSchema()