def unblock_item(item_id, report_id=None, ticket_id=None):
"""
Unblock given `abuse.models.ReportItem`
"""
try:
item = ReportItem.objects.get(id=item_id)
if report_id:
report = Report.objects.get(id=report_id)
if item.report.id != report.id:
raise BadRequest('Given item not attached to given report')
if ticket_id:
ticket = Ticket.objects.get(id=ticket_id)
if item.report.id not in ticket.reportTicket.all().values_list('id', flat=True):
raise BadRequest('Given item not attached to given ticket')
except (AttributeError, ObjectDoesNotExist, TypeError, ValueError):
raise NotFound('Item not found')
utils.default_queue.enqueue(
'phishing.unblock_url',
url=item.rawItem,
)
return {'message': 'Unblocking job successfully scheduled'}
评论列表
文章目录