Fix: Add permanent redirects for legacy sponsorship pages (Issue #2645) - #2944
Fix: Add permanent redirects for legacy sponsorship pages (Issue #2645)#2944iampujan wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes broken legacy sponsorship URLs by adding permanent HTTP 301 redirects to their modern counterparts. The issue (#2645) reported that users clicking on old sponsorship links encountered 404 errors, breaking the sponsorship application workflow.
Changes:
- Added permanent redirects from
/psf/sponsorship-old/to/psf/sponsors/and from/psf/forms/sponsor-application/to/sponsors/application/ - Added test coverage to verify both redirects return HTTP 301 status codes and redirect to the correct URLs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pydotorg/urls.py | Added two RedirectView entries for legacy sponsorship URLs with permanent=True flag |
| pydotorg/tests/test_views.py | Added test_legacy_sponsor_redirects() method to verify both redirects work correctly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2adb3f1 to
1e1ea39
Compare
Address Copilot PR feedback: use url patterns and reverse for sponsors redirects
1e1ea39 to
2b3ff57
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_legacy_sponsor_redirects(self): | ||
| """Test that old sponsorship pages correctly redirect to modern active ones.""" | ||
| response = self.client.get("/psf/sponsorship-old/") | ||
| self.assertRedirects( | ||
| response, | ||
| reverse("psf-sponsors"), | ||
| status_code=301, | ||
| fetch_redirect_response=False, | ||
| ) |
There was a problem hiding this comment.
The expected redirect target for /psf/sponsorship-old/ is asserted as reverse('psf-sponsors'). If the legacy redirect destination changes (e.g., to /psf/sponsorship/), this test needs to be updated to assert against the same canonical target to avoid locking in the wrong behavior.
| RedirectView.as_view(pattern_name="psf-sponsors", permanent=True), | ||
| ), | ||
| path( | ||
| "psf/forms/sponsor-application/", | ||
| RedirectView.as_view(pattern_name="new_sponsorship_application", permanent=True), |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
pydotorg/urls.py:45
- The legacy /psf/forms/sponsor-application/ URL currently redirects to the logged-in, cookie-dependent
new_sponsorship_applicationview. That view immediately bounces users back to benefits selection when no benefits cookie is set, and for logged-out users it adds an extra login hop. Redirecting to the public entrypoint (select_sponsorship_application_benefits) matches the current sponsor page link and provides a smoother flow.
path(
"psf/forms/sponsor-application/",
RedirectView.as_view(pattern_name="new_sponsorship_application", permanent=True),
),
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
pydotorg/tests/test_views.py:44
- The test expects
/psf/sponsorship-old/to redirect toreverse('psf-sponsors')(i.e./psf/sponsors/), but the URLconf redirects it to the hard-coded/psf/sponsorship/. As written, this test will fail; update the expected target (or change the redirect target) so they match.
redirect_cases = (
("/psf/sponsorship-old/", "psf-sponsors"),
("/psf/forms/sponsor-application/", "new_sponsorship_application"),
)
Fixes issue #2645 by permanently redirecting the broken /psf/sponsorship-old/ and /psf/forms/sponsor-application/ URLs to their modern counterparts.