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

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

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

    return render_to_response('identities/field_delete', context,
                              context_instance=RequestContext(request), response_format=response_format)
dataset/ETHPy150Open treeio/treeio/treeio/identities/views.py/field_delete/original