Commit 0c0237c7 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler
Browse files

views/patch: 404 if the patch is not queried series/revision



Let's say that patch was added in 2nd revision of series. The following
URL can be used to browse the patch within that context:

/patch/123/?series=12&rev=2

If someone by mistake changes the revision to 1, which does not contain
patch 123 it used to result in error 500.

Let's be more graceful and 404 with some explanation instead.
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 6256a38d
...@@ -101,8 +101,12 @@ def patch(request, patch_id): ...@@ -101,8 +101,12 @@ def patch(request, patch_id):
all_patches = [x for x in current_revision.patches.all()] all_patches = [x for x in current_revision.patches.all()]
patch_count = len(all_patches) patch_count = len(all_patches)
current_patch_index = all_patches.index(patch) try:
current_patch_number = current_patch_index + 1 current_patch_index = all_patches.index(patch)
current_patch_number = current_patch_index + 1
except ValueError:
raise Http404("Patch {} does not belong to {}v{}"
.format(patch_id, series, rev))
if (current_patch_index + 1) < patch_count: if (current_patch_index + 1) < patch_count:
next_patch = all_patches[current_patch_index + 1] next_patch = all_patches[current_patch_index + 1]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment