@require_objs_permissions_for_view(
    perm_names=["can_edit_aggregate"],
    permittee_func=get_user_from_req,
    target_func=get_leaf_queryset(Aggregate, "agg_id"),
    methods=["GET", "POST"])
def delete(request, agg_id):
    next = request.GET.get("next", None) or reverse("home")
    aggregate = get_object_or_404(Aggregate, id=agg_id).as_leaf_class()
    # Stop all slices using the aggregate
    if request.method == "POST":
        for s in aggregate.slice_set.all():
            aggregate.stop_slice(s)
    # Delete the aggregate.
    req = create_update.delete_object(
        request,
        model=aggregate.__class__,
        post_delete_redirect=next,
        object_id=agg_id,
        extra_context={"next": next},
        template_name=TEMPLATE_PATH+"/delete.html",
    )
    if req.status_code == HttpResponseRedirect.status_code:
        DatedMessage.objects.post_message_to_user(
            "Successfully deleted aggregate %s" % aggregate.name,
            request.user, msg_type=DatedMessage.TYPE_SUCCESS,
        )
    return req
POSTing to the delete view with an unsafe next url will ignore the
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/aggregate/views.py/delete--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/tests/regressiontests/comment_tests/tests/moderation_view_tests.py/DeleteViewTests.testDeletePostUnsafeNext