Skip to content

Commit 9f12a5e

Browse files
JelteFmhagander
authored andcommitted
Add a stable URL for a patch that redirects to latest cf
Links to patches get outdated ever time we move it to new commitfest.
1 parent 429ea84 commit 9f12a5e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: pgcommitfest/commitfest/views.py

+6
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ def global_search(request):
258258
'title': 'Patch search results',
259259
})
260260

261+
def patch_redirect(request, patchid):
262+
last_commitfest = PatchOnCommitFest.objects.select_related('commitfest').filter(patch_id=patchid).order_by('-commitfest__startdate').first()
263+
if not last_commitfest:
264+
raise Http404("Patch not found")
265+
return HttpResponseRedirect(f'/{last_commitfest.commitfest_id}/{patchid}/')
266+
261267

262268
def patch(request, cfid, patchid):
263269
cf = get_object_or_404(CommitFest, pk=cfid)

Diff for: pgcommitfest/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
re_path(r'^(\d+)/$', views.commitfest),
2020
re_path(r'^(open|inprogress|current)/(.*)$', views.redir),
2121
re_path(r'^(?P<cfid>\d+)/activity(?P<rss>\.rss)?/$', views.activity),
22+
re_path(r'^patch/(\d+)/$', views.patch_redirect),
2223
re_path(r'^(\d+)/(\d+)/$', views.patch),
2324
re_path(r'^(\d+)/(\d+)/edit/$', views.patchform),
2425
re_path(r'^(\d+)/new/$', views.newpatch),

0 commit comments

Comments
 (0)