refactor(core): Ticket Linked Item slash command to use serializer

ref: #248 #368 #374
This commit is contained in:
2024-11-01 16:14:20 +09:30
parent e61b883c14
commit 9fe4883f91

View File

@ -1,6 +1,7 @@
import re
class CommandLinkedModel:
# This summary is used for the user documentation
"""Link an item to the current ticket. Supports all ticket
@ -132,14 +133,24 @@ For this command to process the following conditions must be met:
pk = model_id
)
TicketLinkedItem.objects.create(
organization = self.organization,
ticket = ticket,
item_type = item_type,
item = item.id
from core.serializers.ticket_linked_item import TicketLinkedItemModelSerializer
serializer = TicketLinkedItemModelSerializer(
data = {
'organization': ticket.organization,
'ticket': ticket.id,
'item_type': item_type,
'item': item.id
}
)
return None
if serializer.is_valid():
serializer.save()
return None
return str(match.string[match.start():match.end()])
except Exception as e: