-
-
Notifications
You must be signed in to change notification settings - Fork 666
Fix #2685: Redirect Latest News links to blog.python.org #2933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Generated by Django 5.2.11 on 2026-02-22 08:34 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| def rewrite_blog_urls(apps, schema_editor): | ||
| BlogEntry = apps.get_model("blogs", "BlogEntry") | ||
| entries_to_update = [] | ||
| for entry in BlogEntry.objects.filter(url__contains="pythoninsider.blogspot.com"): | ||
| entry.url = entry.url.replace("pythoninsider.blogspot.com", "blog.python.org") | ||
| entries_to_update.append(entry) | ||
| if entries_to_update: | ||
| BlogEntry.objects.bulk_update(entries_to_update, ['url']) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('blogs', '0003_alter_relatedblog_creator_and_more'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(rewrite_blog_urls, migrations.RunPython.noop), | ||
| ] | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,11 +18,16 @@ def get_all_entries(feed_url): | |||||||||||
| for e in d["entries"]: | ||||||||||||
| published = datetime.datetime(*e["published_parsed"][:7], tzinfo=datetime.UTC) | ||||||||||||
|
|
||||||||||||
| # Rewrite Blogger domains to canonical python.org domain (Issue #2685) | ||||||||||||
| url = e["link"].replace( | ||||||||||||
| "//pythoninsider.blogspot.com", | ||||||||||||
| "//blog.python.org" | ||||||||||||
| ) | ||||||||||||
|
Comment on lines
+21
to
+25
|
||||||||||||
| url = e["link"].replace( | |
| "//pythoninsider.blogspot.com", | |
| "//blog.python.org" | |
| ) | |
| url = e["link"].replace("//pythoninsider.blogspot.com", "//blog.python.org") |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||
| import datetime | ||||||||||
| import unittest | ||||||||||
| from unittest.mock import patch | ||||||||||
|
|
||||||||||
| from apps.blogs.parser import get_all_entries | ||||||||||
| from apps.blogs.tests.utils import get_test_rss_path | ||||||||||
|
|
@@ -24,3 +25,26 @@ def test_entries(self): | |||||||||
| self.entries[0]["url"], | ||||||||||
| "http://feedproxy.google.com/~r/PythonInsider/~3/tGNCqyOiun4/introducing-electronic-contributor.html", | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| @patch("apps.blogs.parser.feedparser.parse") | ||||||||||
| def test_rewrites_blogspot_url(self, mock_parse): | ||||||||||
| mock_parse.return_value = { | ||||||||||
| "entries": [ | ||||||||||
| { | ||||||||||
| "title": "Test Title HTTPS", | ||||||||||
| "summary": "Summary", | ||||||||||
| "published_parsed": (2024, 1, 15, 12, 0, 0, 0, 0, 0), | ||||||||||
| "link": "https://pythoninsider.blogspot.com/2024/01/test.html", | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "title": "Test Title HTTP", | ||||||||||
| "summary": "Summary", | ||||||||||
| "published_parsed": (2024, 1, 15, 12, 0, 0, 0, 0, 0), | ||||||||||
| "link": "http://pythoninsider.blogspot.com/2024/01/test2.html", | ||||||||||
| } | ||||||||||
| ] | ||||||||||
|
Comment on lines
+44
to
+45
|
||||||||||
| } | |
| ] | |
| }, | |
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This migration file doesn’t follow the repo’s enforced
ruff-formatstyle (notablyquote-style = "double"inpyproject.toml; e.g.,['url']and('blogs', ...)will be reformatted). Please runruff format/ pre-commit so the lint workflow doesn’t fail on formatting-only differences.