Skip to content

Commit

Permalink
feat(core): Extend all ticket endpoints to contain ticket categories
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Sep 13, 2024
1 parent 2a31815 commit 5d116c7
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/api/serializers/assistance/request.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from rest_framework.fields import empty

from api.serializers.core.ticket import TicketSerializer

from core.models.ticket.ticket import Ticket
Expand All @@ -16,6 +18,7 @@ class Meta:
'id',
'assigned_teams',
'assigned_users',
'category',
'created',
'modified',
'status',
Expand Down Expand Up @@ -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
)
12 changes: 12 additions & 0 deletions app/api/serializers/itim/change.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from rest_framework.fields import empty

from api.serializers.core.ticket import TicketSerializer

from core.models.ticket.ticket import Ticket
Expand All @@ -16,6 +18,7 @@ class Meta:
'id',
'assigned_teams',
'assigned_users',
'category',
'created',
'modified',
'status',
Expand Down Expand Up @@ -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
)
12 changes: 12 additions & 0 deletions app/api/serializers/itim/incident.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from rest_framework.fields import empty

from api.serializers.core.ticket import TicketSerializer

from core.models.ticket.ticket import Ticket
Expand All @@ -16,6 +18,7 @@ class Meta:
'id',
'assigned_teams',
'assigned_users',
'category',
'created',
'modified',
'status',
Expand Down Expand Up @@ -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
)
12 changes: 12 additions & 0 deletions app/api/serializers/itim/problem.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from rest_framework.fields import empty

from api.serializers.core.ticket import TicketSerializer

from core.models.ticket.ticket import Ticket
Expand All @@ -16,6 +18,7 @@ class Meta:
'id',
'assigned_teams',
'assigned_users',
'category',
'created',
'modified',
'status',
Expand Down Expand Up @@ -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
)
12 changes: 12 additions & 0 deletions app/api/serializers/project_management/project_task.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from rest_framework.fields import empty

from api.serializers.core.ticket import TicketSerializer

from core.models.ticket.ticket import Ticket
Expand All @@ -16,6 +18,7 @@ class Meta:
'id',
'assigned_teams',
'assigned_users',
'category',
'created',
'modified',
'status',
Expand Down Expand Up @@ -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
)
1 change: 1 addition & 0 deletions app/core/forms/validate_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TicketValidation(
import_fields: list = [
'assigned_users',
'assigned_teams',
'category',
'created',
'date_closed',
'external_ref',
Expand Down

0 comments on commit 5d116c7

Please sign in to comment.