From: Damien Lespiau Date: Thu, 17 Dec 2015 18:33:29 +0000 (+0000) Subject: urls: Create a project version of bundles X-Git-Tag: v1.1.0~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a74bd81a8f6b00e8f2baf08c205f05c45b659e07;p=thirdparty%2Fpatchwork.git urls: Create a project version of bundles We'd like to have a per-project list of bundles as we present all data in the context of a single project anyway. Still keep the instance-wide list bundles around. v2: Rename the existing 'bundle-list' url to 'user-bundles', as this is more inkeeping with the other URLs Signed-off-by: Damien Lespiau Signed-off-by: Stephen Finucane --- diff --git a/patchwork/templates/patchwork/profile.html b/patchwork/templates/patchwork/profile.html index 04fe12ed..acc90de0 100644 --- a/patchwork/templates/patchwork/profile.html +++ b/patchwork/templates/patchwork/profile.html @@ -107,7 +107,7 @@ address.

  • {{ bundle.name }}
  • {% endfor %} -

    Visit the bundles +

    Visit the bundles page to manage your bundles.

    {% else %}

    You have no bundles.

    diff --git a/patchwork/urls.py b/patchwork/urls.py index 550e5675..022b92cf 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -42,6 +42,8 @@ urlpatterns = [ url(r'^$', project_views.list, name='project-list'), url(r'^project/(?P[^/]+)/list/$', patch_views.list, name='patch-list'), + url(r'^project/(?P[^/]+)/bundles/$', bundle_views.bundles, + name='bundle-list'), url(r'^project/(?P[^/]+)/$', project_views.project, name='project-detail'), @@ -53,15 +55,15 @@ urlpatterns = [ url(r'^patch/(?P\d+)/mbox/$', patch_views.mbox, name='patch-mbox'), + # logged-in user stuff url(r'^user/$', user_views.profile, name='user-profile'), url(r'^user/todo/$', user_views.todo_lists, name='user-todos'), url(r'^user/todo/(?P[^/]+)/$', user_views.todo_list, name='user-todo'), - url(r'^user/bundles/$', bundle_views.bundles, - name='bundle-list'), + name='user-bundles'), url(r'^user/link/$', user_views.link, name='user-link'), diff --git a/patchwork/views/bundle.py b/patchwork/views/bundle.py index 9b88be9b..8870f2e5 100644 --- a/patchwork/views/bundle.py +++ b/patchwork/views/bundle.py @@ -102,12 +102,12 @@ def setbundle(request): ) else: return HttpResponseRedirect( - django.core.urlresolvers.reverse('bundle-list') + django.core.urlresolvers.reverse('user-bundles') ) @login_required -def bundles(request): +def bundles(request, project_id=None): context = PatchworkRequestContext(request) if request.method == 'POST': @@ -120,12 +120,19 @@ def bundles(request): id=form.cleaned_data['bundle_id']) bundle.delete() - bundles = Bundle.objects.filter(owner=request.user) + if project_id is None: + project = None + bundles = Bundle.objects.filter(owner=request.user) + else: + project = get_object_or_404(Project, linkname=project_id) + bundles = Bundle.objects.filter(owner=request.user, project=project) + for bundle in bundles: bundle.delete_form = DeleteBundleForm(auto_id=False, initial={'bundle_id': bundle.id}) context['bundles'] = bundles + context['project'] = project return render_to_response('patchwork/bundles.html', context)