From patchwork Fri Mar 10 17:37:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 737492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vfvds5274z9s7v for ; Sat, 11 Mar 2017 04:39:29 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="AXDreKr5"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vfvds40BRzDqZ6 for ; Sat, 11 Mar 2017 04:39:29 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="AXDreKr5"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from relay1001.mymailcheap.com (relay1001.mymailcheap.com [164.132.144.227]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vfvcv12jwzDqYR for ; Sat, 11 Mar 2017 04:38:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="AXDreKr5"; dkim-atps=neutral Received: from filter1007.mymailcheap.com (filter1007.mymailcheap.com [164.132.58.18]) by relay1001.mymailcheap.com (Postfix) with ESMTPS id 20E161E0BA for ; Fri, 10 Mar 2017 18:38:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by filter1007.mymailcheap.com (Postfix) with ESMTP id 0A8A61E039 for ; Fri, 10 Mar 2017 18:38:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at filter1007.mymailcheap.com Received: from filter1007.mymailcheap.com ([127.0.0.1]) by localhost (filter1007.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ujAoFExBy5Ft for ; Fri, 10 Mar 2017 18:38:23 +0100 (CET) Received: from one.mxroute.com (one-outgoing.mxroute.com [23.92.70.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by filter1007.mymailcheap.com (Postfix) with ESMTPS for ; Fri, 10 Mar 2017 18:38:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IXrcq0OPt00TN2sUthjCzsfGtgBSwGmPGLQiApRPlFw=; b=AXDreKr53mE1uAPfnEZa/Pf4wI OHr0Cli1ejwNVb28t1HvMVOBB7wzOdYEV8J/cRRZLues131dm1Q5yaEgqIFuGH0Ua/DUb1K/RLI2v 4zStWQYa0BgRRxxrDHfBa+EYG0yuSYaV9tQze6HqOumLNsxqGtJ9sXZlQXRll/eK4GD37hpzTKBuy Qp6rQvzz3Sy5Yp1kHg+lx9jHQ1DXK88/NCQ/UOVcKc3+Q9u7awrR2yp4nX+PJ59NJqxfcC+0L/J+y yX1mCy48t5vI84/bbXISZZQoCZ6mHsQnDzXND3/2Cinz88nSZ65+uXORm9j9B2eBzUpncOi9l06dz 905m4jIw==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v4 1/9] views: Use consistent 'list'/'detail' names Date: Fri, 10 Mar 2017 17:37:59 +0000 Message-Id: <20170310173807.13407-2-stephen@that.guru> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170310173807.13407-1-stephen@that.guru> References: <20170310173807.13407-1-stephen@that.guru> X-OutGoing-Spam-Status: No, score=-10.0 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" The 'setbundles' view is also removed as it's not called by anything/anyone. Signed-off-by: Stephen Finucane Reviewed-by: Daniel Axtens --- patchwork/urls.py | 26 ++++++++-------- patchwork/views/bundle.py | 76 +++++----------------------------------------- patchwork/views/cover.py | 2 +- patchwork/views/patch.py | 20 ++++++------ patchwork/views/project.py | 4 +-- 5 files changed, 33 insertions(+), 95 deletions(-) diff --git a/patchwork/urls.py b/patchwork/urls.py index 09b8b31..7a8ea95 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -41,24 +41,24 @@ admin.autodiscover() urlpatterns = [ url(r'^admin/', include(admin.site.urls)), - url(r'^$', project_views.projects, name='project-list'), - url(r'^project/(?P[^/]+)/list/$', patch_views.patches, + url(r'^$', project_views.project_list, name='project-list'), + url(r'^project/(?P[^/]+)/list/$', patch_views.patch_list, name='patch-list'), - url(r'^project/(?P[^/]+)/bundles/$', bundle_views.bundles, + url(r'^project/(?P[^/]+)/bundles/$', bundle_views.bundle_list, name='bundle-list'), - url(r'^project/(?P[^/]+)/$', project_views.project, + url(r'^project/(?P[^/]+)/$', project_views.project_detail, name='project-detail'), # patch views - url(r'^patch/(?P\d+)/$', patch_views.patch, + url(r'^patch/(?P\d+)/$', patch_views.patch_detail, name='patch-detail'), - url(r'^patch/(?P\d+)/raw/$', patch_views.content, + url(r'^patch/(?P\d+)/raw/$', patch_views.patch_raw, name='patch-raw'), - url(r'^patch/(?P\d+)/mbox/$', patch_views.mbox, + url(r'^patch/(?P\d+)/mbox/$', patch_views.patch_mbox, name='patch-mbox'), # cover views - url(r'^cover/(?P\d+)/$', cover_views.cover, + url(r'^cover/(?P\d+)/$', cover_views.cover_detail, name='cover-detail'), # comment urls @@ -71,7 +71,7 @@ urlpatterns = [ name='user-todos'), url(r'^user/todo/(?P[^/]+)/$', user_views.todo_list, name='user-todo'), - url(r'^user/bundles/$', bundle_views.bundles, + url(r'^user/bundles/$', bundle_views.bundle_list, name='user-bundles'), url(r'^user/link/$', user_views.link, @@ -109,10 +109,10 @@ urlpatterns = [ # public view for bundles url(r'^bundle/(?P[^/]*)/(?P[^/]*)/$', - bundle_views.bundle, + bundle_views.bundle_detail, name='bundle-detail'), url(r'^bundle/(?P[^/]*)/(?P[^/]*)/mbox/$', - bundle_views.mbox, + bundle_views.bundle_mbox, name='bundle-mbox'), url(r'^confirm/(?P[0-9a-f]+)/$', notification_views.confirm, @@ -228,9 +228,9 @@ if settings.ENABLE_REST_API: if settings.COMPAT_REDIR: urlpatterns += [ url(r'^user/bundle/(?P[^/]+)/$', - bundle_views.bundle_redir, + bundle_views.bundle_detail_redir, name='bundle-redir'), url(r'^user/bundle/(?P[^/]+)/mbox/$', - bundle_views.mbox_redir, + bundle_views.bundle_mbox_redir, name='bundle-mbox-redir'), ] diff --git a/patchwork/views/bundle.py b/patchwork/views/bundle.py index e717429..1886b7a 100644 --- a/patchwork/views/bundle.py +++ b/patchwork/views/bundle.py @@ -27,74 +27,12 @@ from django.shortcuts import render, get_object_or_404 from patchwork.filters import DelegateFilter from patchwork.forms import BundleForm, DeleteBundleForm -from patchwork.models import Patch, Bundle, BundlePatch, Project -from patchwork.views import generic_list, patch_to_mbox, get_patch_ids +from patchwork.models import Bundle, BundlePatch, Project +from patchwork.views import generic_list, patch_to_mbox @login_required -def setbundle(request): - bundle = None - - if request.method == 'POST': - action = request.POST.get('action', None) - if action is None: - pass - elif action == 'create': - project = get_object_or_404(Project, - id=request.POST.get('project')) - bundle = Bundle(owner=request.user, project=project, - name=request.POST['name']) - bundle.save() - patch_id = request.POST.get('patch_id', None) - if patch_id: - patch = get_object_or_404(Patch, id=patch_id) - bundle.append_patch(patch) - bundle.save() - elif action == 'add': - bundle = get_object_or_404(Bundle, - owner=request.user, - id=request.POST['id']) - bundle.save() - - patch_id = request.get('patch_id', None) - if patch_id: - patch_ids = patch_id - else: - patch_ids = get_patch_ids(request.POST) - - for patch_id in patch_ids: - patch = Patch.objects.get(id=patch_id) - bundle.append_patch(patch) - - bundle.save() - elif action == 'delete': - try: - bundle = Bundle.objects.get(owner=request.user, - id=request.POST['id']) - bundle.delete() - except Bundle.DoesNotExist: - pass - - bundle = None - else: - bundle = get_object_or_404(Bundle, owner=request.user, - id=request.POST['bundle_id']) - - if bundle: - return HttpResponseRedirect( - django.core.urlresolvers.reverse( - 'bundle-detail', - kwargs={'bundle_id': bundle.id} - ) - ) - else: - return HttpResponseRedirect( - django.core.urlresolvers.reverse('user-bundles') - ) - - -@login_required -def bundles(request, project_id=None): +def bundle_list(request, project_id=None): project = None if request.method == 'POST': @@ -125,7 +63,7 @@ def bundles(request, project_id=None): return render(request, 'patchwork/bundles.html', context) -def bundle(request, username, bundlename): +def bundle_detail(request, username, bundlename): bundle = get_object_or_404(Bundle, owner__username=username, name=bundlename) filter_settings = [(DelegateFilter, DelegateFilter.AnyDelegate)] @@ -189,7 +127,7 @@ def bundle(request, username, bundlename): return render(request, 'patchwork/bundle.html', context) -def mbox(request, username, bundlename): +def bundle_mbox(request, username, bundlename): bundle = get_object_or_404(Bundle, owner__username=username, name=bundlename) @@ -208,13 +146,13 @@ def mbox(request, username, bundlename): @login_required -def bundle_redir(request, bundle_id): +def bundle_detail_redir(request, bundle_id): bundle = get_object_or_404(Bundle, id=bundle_id, owner=request.user) return HttpResponseRedirect(bundle.get_absolute_url()) @login_required -def mbox_redir(request, bundle_id): +def bundle_mbox_redir(request, bundle_id): bundle = get_object_or_404(Bundle, id=bundle_id, owner=request.user) return HttpResponseRedirect(django.core.urlresolvers.reverse( 'bundle-mbox', kwargs={ diff --git a/patchwork/views/cover.py b/patchwork/views/cover.py index a9cf0ad..fe3eaf2 100644 --- a/patchwork/views/cover.py +++ b/patchwork/views/cover.py @@ -27,7 +27,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from patchwork.models import CoverLetter, Submission -def cover(request, cover_id): +def cover_detail(request, cover_id): # redirect to patches where necessary try: cover = get_object_or_404(CoverLetter, id=cover_id) diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index caabdd7..469a53a 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -33,7 +33,14 @@ from patchwork.models import Patch, Project, Bundle, Submission from patchwork.views import generic_list, patch_to_mbox -def patch(request, patch_id): +def patch_list(request, project_id): + project = get_object_or_404(Project, linkname=project_id) + context = generic_list(request, project, 'patch-list', + view_args={'project_id': project.linkname}) + return render(request, 'patchwork/list.html', context) + + +def patch_detail(request, patch_id): # redirect to cover letters where necessary try: patch = get_object_or_404(Patch, id=patch_id) @@ -108,14 +115,7 @@ def patch(request, patch_id): return render(request, 'patchwork/submission.html', context) -def patches(request, project_id): - project = get_object_or_404(Project, linkname=project_id) - context = generic_list(request, project, 'patch-list', - view_args={'project_id': project.linkname}) - return render(request, 'patchwork/list.html', context) - - -def content(request, patch_id): +def patch_raw(request, patch_id): patch = get_object_or_404(Patch, id=patch_id) response = HttpResponse(content_type="text/x-patch") response.write(patch.diff) @@ -124,7 +124,7 @@ def content(request, patch_id): return response -def mbox(request, patch_id): +def patch_mbox(request, patch_id): patch = get_object_or_404(Patch, id=patch_id) response = HttpResponse(content_type="text/plain") # NOTE(stephenfin) http://stackoverflow.com/a/28584090/613428 diff --git a/patchwork/views/project.py b/patchwork/views/project.py index 4c59c10..de0c67d 100644 --- a/patchwork/views/project.py +++ b/patchwork/views/project.py @@ -29,7 +29,7 @@ from patchwork.models import Patch from patchwork.models import Project -def projects(request): +def project_list(request): projects = Project.objects.all() if projects.count() == 1: @@ -43,7 +43,7 @@ def projects(request): return render(request, 'patchwork/projects.html', context) -def project(request, project_id): +def project_detail(request, project_id): project = get_object_or_404(Project, linkname=project_id) patches = Patch.objects.filter(project=project)