@handle_response_format
@treeio_login_required
def contact_delete(request, contact_id, response_format='html'):
    "Contact delete"

    contact = get_object_or_404(Contact, pk=contact_id)
    if not request.user.profile.has_permission(contact, mode='w'):
        return user_denied(request, message="You don't have access to this Contact")

    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                contact.trash = True
                contact.save()
            else:
                contact.delete()
            return HttpResponseRedirect(reverse('identities_index'))
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('identities_contact_view', args=[contact.id]))

    types = Object.filter_by_request(
        request, ContactType.objects.order_by('name'))

    return render_to_response('identities/contact_delete',
                              {'contact': contact, 'types': types},
                              context_instance=RequestContext(request), response_format=response_format)
dataset/ETHPy150Open treeio/treeio/treeio/identities/views.py/contact_delete/original