fix(core): Don't create an empty ticket comment if the body is empty when slash commands removed
ref: #691 #681
This commit is contained in:
@ -465,16 +465,32 @@ class TicketComment(
|
||||
|
||||
self.organization = self.ticket.organization
|
||||
|
||||
body = self.body
|
||||
|
||||
self.body = self.slash_command(self.body)
|
||||
|
||||
super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
|
||||
if(
|
||||
(
|
||||
(
|
||||
body is not None
|
||||
and body != ''
|
||||
)
|
||||
and (
|
||||
self.body is not None
|
||||
and self.body != ''
|
||||
)
|
||||
)
|
||||
or self.comment_type == self.CommentType.SOLUTION
|
||||
):
|
||||
|
||||
if self.comment_type == self.CommentType.SOLUTION:
|
||||
super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
|
||||
|
||||
update_ticket = self.ticket.__class__.objects.get(pk=self.ticket.id)
|
||||
update_ticket.status = int(Ticket.TicketStatus.All.SOLVED.value)
|
||||
if self.comment_type == self.CommentType.SOLUTION:
|
||||
|
||||
update_ticket.save()
|
||||
update_ticket = self.ticket.__class__.objects.get(pk=self.ticket.id)
|
||||
update_ticket.status = int(Ticket.TicketStatus.All.SOLVED.value)
|
||||
|
||||
update_ticket.save()
|
||||
|
||||
|
||||
@property
|
||||
|
@ -82,20 +82,22 @@ class TicketCommentModelSerializer(
|
||||
'_self': item.get_url( request = self._context['view'].request )
|
||||
}
|
||||
|
||||
threads = TicketComment.objects.filter(parent = item.id, ticket = ticket_id)
|
||||
if item.id is not None:
|
||||
|
||||
if len(threads) > 0:
|
||||
threads = TicketComment.objects.filter(parent = item.id, ticket = ticket_id)
|
||||
|
||||
urls.update({
|
||||
'threads': reverse(
|
||||
'API:_api_v2_ticket_comment_threads-list',
|
||||
request = self._context['view'].request,
|
||||
kwargs={
|
||||
'ticket_id': ticket_id,
|
||||
'parent_id': item.id
|
||||
}
|
||||
)
|
||||
})
|
||||
if len(threads) > 0:
|
||||
|
||||
urls.update({
|
||||
'threads': reverse(
|
||||
'API:_api_v2_ticket_comment_threads-list',
|
||||
request = self._context['view'].request,
|
||||
kwargs={
|
||||
'ticket_id': ticket_id,
|
||||
'parent_id': item.id
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
return urls
|
||||
|
||||
|
Reference in New Issue
Block a user