'Delete a Team
Schedules a team for deletion.
**Note:** Deletion happens asynchronously and therefor is not
immediate.  However once deletion has begun the state of a project
changes and will be hidden from most public views.'

@sudo_required
def delete(self, request, team):

    updated = Team.objects.filter(id=team.id, status=TeamStatus.VISIBLE).update(status=TeamStatus.PENDING_DELETION)
    if updated:
        transaction_id = uuid4().hex
        delete_team.apply_async(kwargs={'object_id': team.id, 'transaction_id': transaction_id}, countdown=3600)
        self.create_audit_entry(request=request, organization=team.organization, target_object=team.id, event=AuditLogEntryEvent.TEAM_REMOVE, data=team.get_audit_log_data(), transaction_id=transaction_id)
        delete_logger.info('object.delete.queued', extra={'object_id': team.id, 'transaction_id': transaction_id, 'model': type(team).__name__})
    return Response(status=204)
