...
 
Commits (2)
......@@ -89,6 +89,8 @@ urlpatterns = [
url(r'^api/1.0/', include(patches_router.urls)),
url(r'^api/1.0/', include(patch_results_router.urls)),
url(r'^api/1.0/', include(event_router.urls)),
url(r'^api/1.0/msgids/(?P<msgid>[^/]+)/$', api.msgid,
name='msgid_to_patches'),
# project views:
url(r'^$', patchwork.views.base.projects,
......
......@@ -23,7 +23,7 @@ from django.core.exceptions import FieldDoesNotExist, PermissionDenied
from django.conf import settings
from django.core import mail
from django.db.models import Q
from django.http import HttpResponse
from django.http import HttpResponse, JsonResponse
from patchwork.tasks import send_reviewer_notification
from patchwork.models import (Project, Series, SeriesRevision, Patch, EventLog,
State, Test, TestResult, TestState, Person,
......@@ -540,6 +540,27 @@ class PatchViewSet(mixins.ListModelMixin,
return patch_mbox(request, pk)
def msgid(request, msgid):
output = []
if not (msgid.startswith('<') and msgid.endswith('>')):
msgid = '<{}>'.format(msgid)
patches = Patch.objects.filter(msgid=msgid)
for patch in patches:
series = patch.series()
revisions = series.revisions().filter(patches=patch)
desc = {'patch_id': patch.id,
'project_id': patch.project_id,
'series_id': series.id,
'revision_ids': [rev.id for rev in revisions]}
output += [desc]
return JsonResponse(output, safe=False)
class PatchResultViewSet(viewsets.ViewSet, ResultMixin):
permission_classes = (MaintainerPermission, )
authentication_classes = (BasicAuthentication, )
......
......@@ -126,7 +126,7 @@ def list(request, project_id):
return render(request, 'patchwork/list.html', context)
def _get_patch_or_404(request, msgid):
def _get_patch_or_404(msgid):
patch = Patch.objects.filter(msgid='<' + msgid + '>').first()
if patch is None:
raise Http404("Patch not found")
......@@ -134,5 +134,5 @@ def _get_patch_or_404(request, msgid):
def msgid(request, msgid):
patch = _get_patch_or_404(Patch, msgid)
patch = _get_patch_or_404(msgid)
return redirect(patch)