@handle_response_format
@treeio_login_required
def type_delete(request, type_id, response_format='html'):
    "ContactType delete page"
    type = get_object_or_404(ContactType, pk=type_id)
    if not request.user.profile.has_permission(type, mode="w"):
        return user_denied(request, message="You don't have write access to this ContactType")

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

    context = _get_default_context(request)
    context.update({'type': type})

    return render_to_response('identities/contact_type_delete', context,
                              context_instance=RequestContext(request), response_format=response_format)

#
# Fields
#
dataset/ETHPy150Open treeio/treeio/treeio/identities/views.py/type_delete/original