@require_objs_permissions_for_view(
    perm_names=["can_delete_slices"],
    permittee_func=get_user_from_req,
    target_func=get_queryset(Project, "proj_id"),
    methods=["GET", "POST"],
)
@require_objs_permissions_for_view(
    perm_names=["can_delete_project"],
    permittee_func=get_user_from_req,
    target_func=get_queryset(Project, "proj_id"),
    methods=["GET", "POST"],
)
def delete(request, proj_id):
    '''Delete the project'''
    project = get_object_or_404(Project, id=proj_id)
    if request.method == "POST":
        try:
            for s in project.slice_set.all():
                s.stop(request.user)
            project.delete()
            DatedMessage.objects.post_message_to_user(
                "Successfully deleted project %s" % project.name,
               request.user, msg_type=DatedMessage.TYPE_SUCCESS)
        except Exception as e:
            if isinstance(e,ldap.LDAPError):
                DatedMessage.objects.post_message_to_user(
                "Project %s can not be deleted because there is no connection to LDAP" % project.name,
                request.user, msg_type=DatedMessage.TYPE_ERROR)
            else:
                DatedMessage.objects.post_message_to_user(
                "Problems ocurred while trying to delete project %s: %s" % (project.name,str(e)),
                request.user, msg_type=DatedMessage.TYPE_ERROR)
        return HttpResponseRedirect(reverse("home"))
    else:
        from vt_plugin.models.VM import VM
        if VM.objects.filter(projectId = project.uuid):
            DatedMessage.objects.post_message_to_user(
            project.name % "Please delete all VMS inside project '%s' before deleting it",
            request.user, msg_type=DatedMessage.TYPE_ERROR)
            return detail(request, proj_id) 
            #return HttpResponseRedirect(reverse("home"))
        return simple.direct_to_template(
            request,
            template=TEMPLATE_PATH+"/confirm_delete.html",
            extra_context={"object": project},
        )
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/project/views.py/delete/swapped operands of `%`