From b82318b11c33dfe7873468d76ebb3a9a4441fa21 Mon Sep 17 00:00:00 2001 From: Dennis Siemensma Date: Mon, 23 Oct 2023 20:00:03 +0200 Subject: [PATCH] Fix sorted graph names #1901 --- docs/reference/changelog.rst | 5 +- dsmr_frontend/admin.py | 2 +- .../migrations/0050_sorted_graphs_names.py | 51 +++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 dsmr_frontend/migrations/0050_sorted_graphs_names.py diff --git a/docs/reference/changelog.rst b/docs/reference/changelog.rst index 893581c43..b359a613e 100644 --- a/docs/reference/changelog.rst +++ b/docs/reference/changelog.rst @@ -25,12 +25,13 @@ Current release series :depth: 1 -v5.11.0 - August 2023 ------------------------- +v5.11.0 - November 2023 +----------------------- - ``Fixed`` Bugfix for Archive which was causing the electricity returned meter positions to be displayed at all times. - ``Fixed`` [`#1767 `_] Slightly alter debug info for unsupported database engines. - ``Fixed`` [`#1841 `_] Restored broken `v4-upgrade-redirect` route for legacy upgrades. +- ``Fixed`` [`#1901 `_] Naamgeving in configuratie van sorted graphs. - ``Changed`` [`#1827 `_] Update to python 3.11.2 - by ``goegol`` - ``Changed`` [`#1861 `_] Added undocumented env var for low level datalogger usage diff --git a/dsmr_frontend/admin.py b/dsmr_frontend/admin.py index 911a3e1a9..022736040 100644 --- a/dsmr_frontend/admin.py +++ b/dsmr_frontend/admin.py @@ -120,7 +120,7 @@ class FrontendNotificationAdmin(ModelAdmin): @admin.register(SortedGraph) class SortedGraphAdmin(ChangeOnlyAdminModel, SortableAdmin): - list_display = ("sorting_order", "name") + list_display = ("sorting_order", "name", "graph_type") fieldsets = ( ( None, diff --git a/dsmr_frontend/migrations/0050_sorted_graphs_names.py b/dsmr_frontend/migrations/0050_sorted_graphs_names.py new file mode 100644 index 000000000..fa9930270 --- /dev/null +++ b/dsmr_frontend/migrations/0050_sorted_graphs_names.py @@ -0,0 +1,51 @@ +# Generated by Django 3.2.22 on 2023-10-23 17:37 + +from django.db import migrations + + +def migrate_forward(apps, schema_editor): + GRAPH_TYPE_ELECTRICITY = "electricity" + GRAPH_TYPE_PHASES = "phases" + GRAPH_TYPE_VOLTAGE = "voltage" + GRAPH_TYPE_POWER_CURRENT = "power_current" + GRAPH_TYPE_GAS = "gas" + GRAPH_TYPE_WEATHER = "weather" + GRAPH_TYPE_ELECTRICITY_PEAKS = "electricity-peaks" + + SortedGraph = apps.get_model("dsmr_frontend", "SortedGraph") + SortedGraph.objects.filter(graph_type=GRAPH_TYPE_ELECTRICITY).update( + name="Recent Electricity usage" + ) + SortedGraph.objects.filter(graph_type=GRAPH_TYPE_PHASES).update( + name="Recent phase usage" + ) + SortedGraph.objects.filter(graph_type=GRAPH_TYPE_VOLTAGE).update( + name="Recent phase voltages" + ) + SortedGraph.objects.filter(graph_type=GRAPH_TYPE_POWER_CURRENT).update( + name="Recent phase currents" + ) + SortedGraph.objects.filter(graph_type=GRAPH_TYPE_GAS).update( + name="Recent gas consumption" + ) + SortedGraph.objects.filter(graph_type=GRAPH_TYPE_WEATHER).update( + name="Recent temperatures" + ) + SortedGraph.objects.filter(graph_type=GRAPH_TYPE_ELECTRICITY_PEAKS).update( + name="Recent quarter hour electricity peak consumption" + ) + + +def migrate_backward(apps, schema_editor): + # No-op. Idempotent when running migrate_forward() again. + pass + + +class Migration(migrations.Migration): + dependencies = [ + ("dsmr_frontend", "0049_alter_notification_options"), + ] + + operations = [ + migrations.RunPython(migrate_forward, migrate_backward), + ]