diff options
author | Jelte Fennema-Nio | 2024-06-24 20:33:42 +0000 |
---|---|---|
committer | Magnus Hagander | 2024-08-02 11:46:01 +0000 |
commit | 9f12a5e83f135c106f200565a427c0e13ae474af (patch) | |
tree | 36e17bab12033915580449fba0093dcbf7fe51e1 | |
parent | 429ea84fe875505fa840eda246a83960f76dda28 (diff) |
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.
-rw-r--r-- | pgcommitfest/commitfest/views.py | 6 | ||||
-rw-r--r-- | pgcommitfest/urls.py | 1 |
2 files changed, 7 insertions, 0 deletions
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) diff --git a/pgcommitfest/urls.py b/pgcommitfest/urls.py index 4f6e9d2..53fce1c 100644 --- a/pgcommitfest/urls.py +++ b/pgcommitfest/urls.py @@ -19,6 +19,7 @@ urlpatterns = [ re_path(r'^(\d+)/$', views.commitfest), re_path(r'^(open|inprogress|current)/(.*)$', views.redir), re_path(r'^(?P<cfid>\d+)/activity(?P<rss>\.rss)?/$', views.activity), + re_path(r'^patch/(\d+)/$', views.patch_redirect), re_path(r'^(\d+)/(\d+)/$', views.patch), re_path(r'^(\d+)/(\d+)/edit/$', views.patchform), re_path(r'^(\d+)/new/$', views.newpatch), |