diff --git a/dashboard/fixtures/dashboard_production_metrics.json b/dashboard/fixtures/dashboard_production_metrics.json index 14dff7d40f..21d0e1b771 100644 --- a/dashboard/fixtures/dashboard_production_metrics.json +++ b/dashboard/fixtures/dashboard_production_metrics.json @@ -11,7 +11,7 @@ "model": "dashboard.category", "pk": 2, "fields": { - "name": "Patches", + "name": "Pull requests", "position": 2 } }, @@ -51,7 +51,7 @@ "model": "dashboard.tracticketmetric", "pk": 2, "fields": { - "name": "Patches needing review", + "name": "PRs needing review", "slug": "patches", "category": 2, "position": 3, @@ -67,7 +67,7 @@ "model": "dashboard.tracticketmetric", "pk": 3, "fields": { - "name": "Doc. patches needing review", + "name": "Doc. PRs needing review", "slug": "doc-patches", "category": 2, "position": 4, diff --git a/dashboard/fixtures/dashboard_test_data.json b/dashboard/fixtures/dashboard_test_data.json index e398fd78dd..4b71a22822 100644 --- a/dashboard/fixtures/dashboard_test_data.json +++ b/dashboard/fixtures/dashboard_test_data.json @@ -10,7 +10,7 @@ { "fields": { "position": 2, - "name": "Patches" + "name": "Pull requests" }, "model": "dashboard.category", "pk": 2 @@ -51,7 +51,7 @@ "fields": { "category": 2, "show_on_dashboard": true, - "name": "Patches needing review", + "name": "PRs needing review", "period": "instant", "show_sparkline": true, "query": "status=!closed&needs_better_patch=0&needs_tests=0&needs_docs=0&has_patch=1&stage=Accepted", @@ -67,7 +67,7 @@ "fields": { "category": 2, "show_on_dashboard": true, - "name": "Doc. patches needing review", + "name": "Doc. PRs needing review", "period": "instant", "show_sparkline": true, "query": "status=!closed&needs_better_patch=0&component=Documentation&needs_tests=0&needs_docs=0&has_patch=1&stage=Accepted", diff --git a/dashboard/migrations/0003_rename_patch_to_pr.py b/dashboard/migrations/0003_rename_patch_to_pr.py new file mode 100644 index 0000000000..d2ee8af701 --- /dev/null +++ b/dashboard/migrations/0003_rename_patch_to_pr.py @@ -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), + ]