@handle_response_format
@treeio_login_required
def messaging_delete(request, message_id, response_format='html'):
    "Delete message page"

    message = get_object_or_404(Message, pk=message_id)

    if not request.user.profile.has_permission(message, mode="w"):
        return user_denied(request, message="You don't have access to this Message",
                           response_format=response_format)

    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                message.trash = True
                message.save()
            else:
                message.delete()
            return HttpResponseRedirect('/messaging/')
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('messaging_stream_view', args=[message.stream.id]))

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

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