def get_ticket_attachments(ticket_id):
"""
Get ticket attachments..
"""
try:
ticket = Ticket.objects.get(id=ticket_id)
except (IndexError, ObjectDoesNotExist, ValueError):
raise NotFound('Ticket not found')
ticket_reports_id = ticket.reportTicket.all().values_list(
'id',
flat=True
).distinct()
attachments = AttachedDocument.objects.filter(report__id__in=ticket_reports_id).distinct()
attachments = list(attachments)
attachments.extend(ticket.attachments.all())
attachments = list(set(attachments))
attachments = [model_to_dict(attach) for attach in attachments]
return attachments
评论列表
文章目录