[PATCH 05/19] urls: Create a project version of bundles

Stephen Finucane stephen.finucane at intel.com
Thu Feb 4 08:31:40 AEDT 2016


From: Damien Lespiau <damien.lespiau at intel.com>

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 <damien.lespiau at intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
 patchwork/templates/patchwork/profile.html |  2 +-
 patchwork/urls.py                          |  6 ++++--
 patchwork/views/bundle.py                  | 13 ++++++++++---
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/patchwork/templates/patchwork/profile.html b/patchwork/templates/patchwork/profile.html
index 04fe12e..acc90de 100644
--- a/patchwork/templates/patchwork/profile.html
+++ b/patchwork/templates/patchwork/profile.html
@@ -107,7 +107,7 @@ address.</p>
  <li><a href="{{ bundle.get_absolute_url }}">{{ bundle.name }}</a></li>
 {% endfor %}
 </ul>
-<p>Visit the <a href="{%url 'bundle-list' %}">bundles
+<p>Visit the <a href="{%url 'user-bundles' %}">bundles
  page</a> to manage your bundles.</p>
 {% else %}
 <p>You have no bundles.</p>
diff --git a/patchwork/urls.py b/patchwork/urls.py
index 67167c1..e763ba6 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<project_id>[^/]+)/list/$', patch_views.list,
         name='patch-list'),
+    url(r'^project/(?P<project_id>[^/]+)/bundles/$', bundle_views.bundles,
+        name='bundle-list'),
     url(r'^project/(?P<project_id>[^/]+)/$', project_views.project,
         name='project-detail'),
 
@@ -53,15 +55,15 @@ urlpatterns = [
     url(r'^patch/(?P<patch_id>\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<project_id>[^/]+)/$', 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 9b88be9..8870f2e 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)
 
-- 
2.0.0



More information about the Patchwork mailing list