From 5d116c7224c8fb7f03b5f6912216d46875f0d8b1 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 13 Sep 2024 12:25:30 +0930 Subject: [PATCH] feat(core): Extend all ticket endpoints to contain ticket categories ref: #14 #96 #93 #95 #90 #283 #284 --- app/api/serializers/assistance/request.py | 12 ++++++++++++ app/api/serializers/itim/change.py | 12 ++++++++++++ app/api/serializers/itim/incident.py | 12 ++++++++++++ app/api/serializers/itim/problem.py | 12 ++++++++++++ .../serializers/project_management/project_task.py | 12 ++++++++++++ app/core/forms/validate_ticket.py | 1 + 6 files changed, 61 insertions(+) diff --git a/app/api/serializers/assistance/request.py b/app/api/serializers/assistance/request.py index d4df3d56b..fa6ce01d3 100644 --- a/app/api/serializers/assistance/request.py +++ b/app/api/serializers/assistance/request.py @@ -1,3 +1,5 @@ +from rest_framework.fields import empty + from api.serializers.core.ticket import TicketSerializer from core.models.ticket.ticket import Ticket @@ -16,6 +18,7 @@ class Meta: 'id', 'assigned_teams', 'assigned_users', + 'category', 'created', 'modified', 'status', @@ -47,3 +50,12 @@ class Meta: 'ticket_type', 'url', ] + + + def __init__(self, instance=None, data=empty, **kwargs): + + super().__init__(instance=instance, data=data, **kwargs) + + self.fields.fields['category'].queryset = self.fields.fields['category'].queryset.filter( + request = True + ) diff --git a/app/api/serializers/itim/change.py b/app/api/serializers/itim/change.py index e7a920c75..03d3dbac2 100644 --- a/app/api/serializers/itim/change.py +++ b/app/api/serializers/itim/change.py @@ -1,3 +1,5 @@ +from rest_framework.fields import empty + from api.serializers.core.ticket import TicketSerializer from core.models.ticket.ticket import Ticket @@ -16,6 +18,7 @@ class Meta: 'id', 'assigned_teams', 'assigned_users', + 'category', 'created', 'modified', 'status', @@ -47,3 +50,12 @@ class Meta: 'ticket_type', 'url', ] + + + def __init__(self, instance=None, data=empty, **kwargs): + + super().__init__(instance=instance, data=data, **kwargs) + + self.fields.fields['category'].queryset = self.fields.fields['category'].queryset.filter( + project_task = True + ) diff --git a/app/api/serializers/itim/incident.py b/app/api/serializers/itim/incident.py index ceff1ef05..a5a61c053 100644 --- a/app/api/serializers/itim/incident.py +++ b/app/api/serializers/itim/incident.py @@ -1,3 +1,5 @@ +from rest_framework.fields import empty + from api.serializers.core.ticket import TicketSerializer from core.models.ticket.ticket import Ticket @@ -16,6 +18,7 @@ class Meta: 'id', 'assigned_teams', 'assigned_users', + 'category', 'created', 'modified', 'status', @@ -47,3 +50,12 @@ class Meta: 'ticket_type', 'url', ] + + + def __init__(self, instance=None, data=empty, **kwargs): + + super().__init__(instance=instance, data=data, **kwargs) + + self.fields.fields['category'].queryset = self.fields.fields['category'].queryset.filter( + incident = True + ) diff --git a/app/api/serializers/itim/problem.py b/app/api/serializers/itim/problem.py index 2c0378648..6ed59e48d 100644 --- a/app/api/serializers/itim/problem.py +++ b/app/api/serializers/itim/problem.py @@ -1,3 +1,5 @@ +from rest_framework.fields import empty + from api.serializers.core.ticket import TicketSerializer from core.models.ticket.ticket import Ticket @@ -16,6 +18,7 @@ class Meta: 'id', 'assigned_teams', 'assigned_users', + 'category', 'created', 'modified', 'status', @@ -47,3 +50,12 @@ class Meta: 'ticket_type', 'url', ] + + + def __init__(self, instance=None, data=empty, **kwargs): + + super().__init__(instance=instance, data=data, **kwargs) + + self.fields.fields['category'].queryset = self.fields.fields['category'].queryset.filter( + problem = True + ) diff --git a/app/api/serializers/project_management/project_task.py b/app/api/serializers/project_management/project_task.py index b876d95ba..efc9dfd17 100644 --- a/app/api/serializers/project_management/project_task.py +++ b/app/api/serializers/project_management/project_task.py @@ -1,3 +1,5 @@ +from rest_framework.fields import empty + from api.serializers.core.ticket import TicketSerializer from core.models.ticket.ticket import Ticket @@ -16,6 +18,7 @@ class Meta: 'id', 'assigned_teams', 'assigned_users', + 'category', 'created', 'modified', 'status', @@ -47,3 +50,12 @@ class Meta: 'ticket_type', 'url', ] + + + def __init__(self, instance=None, data=empty, **kwargs): + + super().__init__(instance=instance, data=data, **kwargs) + + self.fields.fields['category'].queryset = self.fields.fields['category'].queryset.filter( + project_task = True + ) diff --git a/app/core/forms/validate_ticket.py b/app/core/forms/validate_ticket.py index 777d367b2..a50247e5a 100644 --- a/app/core/forms/validate_ticket.py +++ b/app/core/forms/validate_ticket.py @@ -37,6 +37,7 @@ class TicketValidation( import_fields: list = [ 'assigned_users', 'assigned_teams', + 'category', 'created', 'date_closed', 'external_ref',