Skip to content

Commit 4d77309

Browse files
committed
Fixed django#1724 -- Renamed "patch" to "pull request"
This follows Django ticket # 35894
1 parent 538d2e6 commit 4d77309

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

dashboard/fixtures/dashboard_production_metrics.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"model": "dashboard.category",
1212
"pk": 2,
1313
"fields": {
14-
"name": "Patches",
14+
"name": "Pull requests",
1515
"position": 2
1616
}
1717
},
@@ -51,7 +51,7 @@
5151
"model": "dashboard.tracticketmetric",
5252
"pk": 2,
5353
"fields": {
54-
"name": "Patches needing review",
54+
"name": "PRs needing review",
5555
"slug": "patches",
5656
"category": 2,
5757
"position": 3,
@@ -67,7 +67,7 @@
6767
"model": "dashboard.tracticketmetric",
6868
"pk": 3,
6969
"fields": {
70-
"name": "Doc. patches needing review",
70+
"name": "Doc. PRs needing review",
7171
"slug": "doc-patches",
7272
"category": 2,
7373
"position": 4,

dashboard/fixtures/dashboard_test_data.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"fields": {
1212
"position": 2,
13-
"name": "Patches"
13+
"name": "Pull requests"
1414
},
1515
"model": "dashboard.category",
1616
"pk": 2
@@ -51,7 +51,7 @@
5151
"fields": {
5252
"category": 2,
5353
"show_on_dashboard": true,
54-
"name": "Patches needing review",
54+
"name": "PRs needing review",
5555
"period": "instant",
5656
"show_sparkline": true,
5757
"query": "status=!closed&needs_better_patch=0&needs_tests=0&needs_docs=0&has_patch=1&stage=Accepted",
@@ -67,7 +67,7 @@
6767
"fields": {
6868
"category": 2,
6969
"show_on_dashboard": true,
70-
"name": "Doc. patches needing review",
70+
"name": "Doc. PRs needing review",
7171
"period": "instant",
7272
"show_sparkline": true,
7373
"query": "status=!closed&needs_better_patch=0&component=Documentation&needs_tests=0&needs_docs=0&has_patch=1&stage=Accepted",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from django.db import migrations
2+
3+
CATEGORY_RENAMES = {
4+
"Patches": "Pull requests",
5+
}
6+
7+
TRACMETRIC_RENAMES = {
8+
"Patches needing review": "PRs needing review",
9+
"Doc. patches needing review": "Doc. PRs needing review",
10+
}
11+
12+
13+
def _reverse(d):
14+
"""
15+
Reverse the given dict (values become keys and vice-versa).
16+
"""
17+
return {v: k for k, v in d.items()}
18+
19+
20+
def rename(apps, schema_editor):
21+
Category = apps.get_model("dashboard", "Category")
22+
TracTicketMetric = apps.get_model("dashboard", "TracTicketMetric")
23+
24+
for old, new in CATEGORY_RENAMES.items():
25+
Category.objects.filter(name=old).update(name=new)
26+
27+
for old, new in TRACMETRIC_RENAMES.items():
28+
TracTicketMetric.objects.filter(name=old).update(name=new)
29+
30+
31+
def rename_backwards(apps, schema_editor):
32+
Category = apps.get_model("dashboard", "Category")
33+
TracTicketMetric = apps.get_model("dashboard", "TracTicketMetric")
34+
35+
for old, new in _reverse(CATEGORY_RENAMES).items():
36+
Category.objects.filter(name=old).update(name=new)
37+
38+
for old, new in _reverse(TRACMETRIC_RENAMES).items():
39+
TracTicketMetric.objects.filter(name=old).update(name=new)
40+
41+
42+
class Migration(migrations.Migration):
43+
44+
dependencies = [
45+
('dashboard', '0002_delete_rssfeedmetric_create_githubsearchcountmetric'),
46+
]
47+
48+
operations = [
49+
migrations.RunPython(rename, rename_backwards),
50+
]

0 commit comments

Comments
 (0)