From 9f12a5e83f135c106f200565a427c0e13ae474af Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Mon, 24 Jun 2024 22:33:42 +0200 Subject: 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. --- pgcommitfest/commitfest/views.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'pgcommitfest/commitfest') diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 40ae3c5..0dcdb88 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -258,6 +258,12 @@ def global_search(request): 'title': 'Patch search results', }) +def patch_redirect(request, patchid): + last_commitfest = PatchOnCommitFest.objects.select_related('commitfest').filter(patch_id=patchid).order_by('-commitfest__startdate').first() + if not last_commitfest: + raise Http404("Patch not found") + return HttpResponseRedirect(f'/{last_commitfest.commitfest_id}/{patchid}/') + def patch(request, cfid, patchid): cf = get_object_or_404(CommitFest, pk=cfid) -- cgit v1.2.3