def create_resource(request, slice_id, agg_id):
    """Show a page that allows user to add a SampleResource to the aggregate."""

    if request.method == "POST":
        # Shows error message when aggregate unreachable, disable SampleResource creation and get back to slice detail page
        agg = Aggregate.objects.get(id = agg_id)
        if agg.check_status() == False:
            DatedMessage.objects.post_message_to_user(
                "SampleResource Aggregate '%s' is not available" % agg.name,
                request.user, msg_type=DatedMessage.TYPE_ERROR,)
            return HttpResponseRedirect(reverse("slice_detail", args=[slice_id]))

        if 'create_resource' in request.POST:
            return HttpResponseRedirect(reverse("sample_resource_resource_crud", args=[slice_id, agg_id]))
        else:
            return HttpResponseRedirect(reverse("slice_detail", args=[slice_id]))
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/doc/plugins/samples/plugin/sample_resource/controller/GUIdispatcher.py/create_resource/original