From f8858c944f63e842f8a47fc112d7f9aa144d0a35 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 2 May 2025 14:56:46 -0400 Subject: [PATCH] Fix references to TemplateType enum in the schema Signed-off-by: Carlo Costino --- Makefile | 4 ++++ app/schemas.py | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 90f5a45fb..b4664264f 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,10 @@ test: ## Run tests and create coverage report poetry run coverage report -m --fail-under=93 poetry run coverage html -d .coverage_cache +.PHONY: test-debug +test-debug: + poetry run pytest --pdb -x + .PHONY: py-lock py-lock: ## Syncs dependencies and updates lock file without performing recursive internal updates poetry lock --no-update diff --git a/app/schemas.py b/app/schemas.py index 68e587385..83e2c5811 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -375,6 +375,7 @@ class TemplateSchema(BaseTemplateSchema, UUIDsAsStringsMixin): created_by = field_for(models.Template, "created_by", required=True) process_type = field_for(models.Template, "process_type") redact_personalisation = fields.Method("redact") + template_type = auto_field(by_value=True) created_at = FlexibleDateTime() updated_at = FlexibleDateTime() @@ -419,6 +420,7 @@ class TemplateHistorySchema(BaseSchema): reply_to = fields.Method("get_reply_to", allow_none=True) reply_to_text = fields.Method("get_reply_to_text", allow_none=True) process_type = field_for(models.Template, "process_type") + template_type = auto_field(by_value=True) created_by = fields.Nested( UserSchema, only=["id", "name", "email_address"], dump_only=True @@ -464,7 +466,7 @@ class JobSchema(BaseSchema): processing_started = FlexibleDateTime() processing_finished = FlexibleDateTime() - job_status = auto_field() + job_status = auto_field(by_value=True) scheduled_for = FlexibleDateTime() service_name = fields.Nested( @@ -482,7 +484,7 @@ class JobSchema(BaseSchema): return job.template.name def get_template_type(self, job): - return job.template.template_type + return job.template.template_type.value @validates("scheduled_for") def validate_scheduled_for(self, value): @@ -597,11 +599,12 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema): created_at = auto_field() id = auto_field() job_row_number = auto_field() - notification_type = auto_field() + notification_type = auto_field(by_value=True) reference = auto_field() sent_at = auto_field() sent_by = auto_field() status = auto_field() + template_type = auto_field(by_value=True) template_version = auto_field() to = auto_field() updated_at = auto_field()