From e771631a040b02d239e8d36efa782107149c17ba Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 4 Nov 2024 00:46:21 +0930 Subject: [PATCH] fix(core): Ensure that when creating a ticket an organization is specified ref: #248 #378 --- app/core/serializers/ticket.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/core/serializers/ticket.py b/app/core/serializers/ticket.py index fb059120..b1b77389 100644 --- a/app/core/serializers/ticket.py +++ b/app/core/serializers/ticket.py @@ -214,11 +214,24 @@ class TicketModelSerializer(TicketBaseSerializer): is_valid = False - centurion_exception.ValidationError( + raise centurion_exception.ValidationError( detail = 'cant edit field: organization', code = 'cant_edit_field_organization', ) + elif self.instance is None: + + if 'organization' not in self.initial_data: + + is_valid = False + + raise centurion_exception.ValidationError( + detail = { + 'organization': 'this field is required' + }, + code = 'required', + ) + return is_valid