diff --git a/app/core/serializers/ticket.py b/app/core/serializers/ticket.py index e16cd840..985ccc32 100644 --- a/app/core/serializers/ticket.py +++ b/app/core/serializers/ticket.py @@ -310,6 +310,28 @@ class TicketModelSerializer( data['status'] = int(Ticket.TicketStatus.All.NEW) + if( + data['parent_ticket'] + and ( + self._context['view'].action == 'partial_update' + or self._context['view'].action == 'update' + ) + ): + + if not data['parent_ticket'].circular_dependency_check( + ticket = self.instance, + parent = data['parent_ticket'] + ): + + raise centurion_exception.ValidationError( + detail = { + 'parent_ticket': 'Adding this ticket will create a circular dependency' + }, + code = 'no_parent_circular_dependency', + ) + + + self.validate_field_organization() self.validate_field_milestone()