forked from django/djangoproject.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed django#1724 -- Renamed "patch" to "pull request"
This follows Django ticket # 35894
- Loading branch information
Showing
4 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from django.db import migrations | ||
|
||
CATEGORY_RENAMES = { | ||
"Patches": "Pull requests", | ||
} | ||
|
||
TRACMETRIC_RENAMES = { | ||
"Patches needing review": "PRs needing review", | ||
"Doc. patches needing review": "Doc. PRs needing review", | ||
} | ||
|
||
|
||
def _reverse(d): | ||
""" | ||
Reverse the given dict (values become keys and vice-versa). | ||
""" | ||
return {v: k for k, v in d.items()} | ||
|
||
|
||
def rename(apps, schema_editor): | ||
Category = apps.get_model("dashboard", "Category") | ||
TracTicketMetric = apps.get_model("dashboard", "TracTicketMetric") | ||
|
||
for old, new in CATEGORY_RENAMES.items(): | ||
Category.objects.filter(name=old).update(name=new) | ||
|
||
for old, new in TRACMETRIC_RENAMES.items(): | ||
TracTicketMetric.objects.filter(name=old).update(name=new) | ||
|
||
|
||
def rename_backwards(apps, schema_editor): | ||
Category = apps.get_model("dashboard", "Category") | ||
TracTicketMetric = apps.get_model("dashboard", "TracTicketMetric") | ||
|
||
for old, new in _reverse(CATEGORY_RENAMES).items(): | ||
Category.objects.filter(name=old).update(name=new) | ||
|
||
for old, new in _reverse(TRACMETRIC_RENAMES).items(): | ||
TracTicketMetric.objects.filter(name=old).update(name=new) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dashboard', '0002_delete_rssfeedmetric_create_githubsearchcountmetric'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(rename, rename_backwards), | ||
] |