urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
- url(r'^$', project_views.projects, name='project-list'),
- url(r'^project/(?P<project_id>[^/]+)/list/$', patch_views.patches,
+ url(r'^$', project_views.project_list, name='project-list'),
+ url(r'^project/(?P<project_id>[^/]+)/list/$', patch_views.patch_list,
name='patch-list'),
- url(r'^project/(?P<project_id>[^/]+)/bundles/$', bundle_views.bundles,
+ url(r'^project/(?P<project_id>[^/]+)/bundles/$', bundle_views.bundle_list,
name='bundle-list'),
- url(r'^project/(?P<project_id>[^/]+)/$', project_views.project,
+ url(r'^project/(?P<project_id>[^/]+)/$', project_views.project_detail,
name='project-detail'),
# patch views
- url(r'^patch/(?P<patch_id>\d+)/$', patch_views.patch,
+ url(r'^patch/(?P<patch_id>\d+)/$', patch_views.patch_detail,
name='patch-detail'),
- url(r'^patch/(?P<patch_id>\d+)/raw/$', patch_views.content,
+ url(r'^patch/(?P<patch_id>\d+)/raw/$', patch_views.patch_raw,
name='patch-raw'),
- url(r'^patch/(?P<patch_id>\d+)/mbox/$', patch_views.mbox,
+ url(r'^patch/(?P<patch_id>\d+)/mbox/$', patch_views.patch_mbox,
name='patch-mbox'),
# cover views
- url(r'^cover/(?P<cover_id>\d+)/$', cover_views.cover,
+ url(r'^cover/(?P<cover_id>\d+)/$', cover_views.cover_detail,
name='cover-detail'),
# comment urls
name='user-todos'),
url(r'^user/todo/(?P<project_id>[^/]+)/$', 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,
# public view for bundles
url(r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$',
- bundle_views.bundle,
+ bundle_views.bundle_detail,
name='bundle-detail'),
url(r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/mbox/$',
- bundle_views.mbox,
+ bundle_views.bundle_mbox,
name='bundle-mbox'),
url(r'^confirm/(?P<key>[0-9a-f]+)/$', notification_views.confirm,
if settings.COMPAT_REDIR:
urlpatterns += [
url(r'^user/bundle/(?P<bundle_id>[^/]+)/$',
- bundle_views.bundle_redir,
+ bundle_views.bundle_detail_redir,
name='bundle-redir'),
url(r'^user/bundle/(?P<bundle_id>[^/]+)/mbox/$',
- bundle_views.mbox_redir,
+ bundle_views.bundle_mbox_redir,
name='bundle-mbox-redir'),
]
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
if settings.ENABLE_REST_API:
from rest_framework.authentication import BasicAuthentication # noqa
@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':
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)]
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)
@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={
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)
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)
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)
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
from patchwork.models import Project
-def projects(request):
+def project_list(request):
projects = Project.objects.all()
if projects.count() == 1:
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)