def METHOD_NAME(request, username, bundlename):
    bundle = get_object_or_404(
        Bundle, owner__username=username, name=bundlename
    )
    filter_settings = [(DelegateFilter, DelegateFilter.ANY_DELEGATE)]
    is_owner = request.user == bundle.owner
    if not (is_owner or bundle.public):
        return HttpResponseNotFound()
    if is_owner:
        if request.method == 'POST' and request.POST.get('form') == 'bundle':
            action = request.POST.get('action', '').lower()
            if action == 'delete':
                bundle.delete()
                return HttpResponseRedirect(reverse('user-profile'))
            elif action == 'update':
                form = BundleForm(request.POST, instance=bundle)
                if form.is_valid():
                    form.save()
                # if we've changed the bundle name, redirect to new URL
                bundle = Bundle.objects.get(pk=bundle.pk)
                if bundle.name != bundlename:
                    return HttpResponseRedirect(bundle.get_absolute_url())
            else:
                form = BundleForm(instance=bundle)
        else:
            form = BundleForm(instance=bundle)
        if (
            request.method == 'POST'
            and request.POST.get('form') == 'reorderform'
        ):
            order = get_object_or_404(
                BundlePatch,
                bundle=bundle,
                patch__id=request.POST.get('order_start'),
            ).order
            for patch_id in request.POST.getlist('neworder'):
                bundlepatch = get_object_or_404(
                    BundlePatch, bundle=bundle, patch__id=patch_id
                )
                bundlepatch.order = order
                bundlepatch.save()
                order += 1
    else:
        form = None
    context = generic_list(
        request,
        bundle.project,
        'bundle-detail',
        view_args={
            'username': bundle.owner.username,
            'bundlename': bundle.name,
        },
        filter_settings=filter_settings,
        patches=bundle.ordered_patches(),
        editable_order=is_owner,
    )
    context['bundle'] = bundle
    context['bundleform'] = form
    return render(request, 'patchwork/bundle.html', context)