From 018af1ba1d28ee49648852c78bdff47e7a6744dd Mon Sep 17 00:00:00 2001 From: Ross Perry Date: Wed, 6 Nov 2024 14:33:01 -0700 Subject: [PATCH 1/9] systen service modal mods --- seed/migrations/0237_auto_20241106_1325.py | 23 +++++++++++++++++++ seed/models/systems.py | 4 ++-- .../inventory_detail_meters_controller.js | 4 ++-- ...nventory_group_detail_meters_controller.js | 2 +- ...ventory_group_detail_systems_controller.js | 17 +++++++++----- .../seed/partials/meter_edit_modal.html | 2 +- seed/static/seed/partials/service_modal.html | 2 +- seed/static/seed/partials/services_table.html | 15 ++---------- seed/static/seed/partials/system_modal.html | 16 ++++++------- seed/static/seed/partials/systems_table.html | 2 +- 10 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 seed/migrations/0237_auto_20241106_1325.py diff --git a/seed/migrations/0237_auto_20241106_1325.py b/seed/migrations/0237_auto_20241106_1325.py new file mode 100644 index 0000000000..55913f22d7 --- /dev/null +++ b/seed/migrations/0237_auto_20241106_1325.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.25 on 2024-11-06 21:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seed', '0236_auto_20241030_1434'), + ] + + operations = [ + migrations.AlterField( + model_name='batterysystem', + name='efficiency', + field=models.FloatField(), + ), + migrations.AlterField( + model_name='service', + name='emission_factor', + field=models.FloatField(null=True), + ), + ] diff --git a/seed/models/systems.py b/seed/models/systems.py index 1d4964fbdc..1c4a81b634 100644 --- a/seed/models/systems.py +++ b/seed/models/systems.py @@ -52,7 +52,7 @@ class EVSESystem(System): class BatterySystem(System): - efficiency = models.IntegerField(null=False) + efficiency = models.FloatField(null=False) capacity = models.IntegerField(null=False) voltage = models.IntegerField(null=False) @@ -60,7 +60,7 @@ class BatterySystem(System): class Service(models.Model): system = models.ForeignKey(System, on_delete=models.CASCADE, related_name="services") name = models.CharField(max_length=255) - emission_factor = models.IntegerField(null=True) + emission_factor = models.FloatField(null=True) objects = InheritanceManager() diff --git a/seed/static/seed/js/controllers/inventory_detail_meters_controller.js b/seed/static/seed/js/controllers/inventory_detail_meters_controller.js index 747afc21f2..8896f5603b 100644 --- a/seed/static/seed/js/controllers/inventory_detail_meters_controller.js +++ b/seed/static/seed/js/controllers/inventory_detail_meters_controller.js @@ -71,9 +71,9 @@ angular.module('SEED.controller.inventory_detail_meters', []).controller('invent // dont show edit if disabled? const buttons = ( '
' + - ' ' + ' ' + - ' ' + + // ' ' + + ' ' + '
' ); diff --git a/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js b/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js index 5c5e45b0b8..91666417dc 100644 --- a/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js +++ b/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js @@ -91,8 +91,8 @@ angular.module('SEED.controller.inventory_group_detail_meters', []) const buttons = ( '
' + - ' ' + ' ' + + ' ' + '
' ); diff --git a/seed/static/seed/js/controllers/inventory_group_detail_systems_controller.js b/seed/static/seed/js/controllers/inventory_group_detail_systems_controller.js index 5e5d8e86c1..5a6ea4ddc9 100644 --- a/seed/static/seed/js/controllers/inventory_group_detail_systems_controller.js +++ b/seed/static/seed/js/controllers/inventory_group_detail_systems_controller.js @@ -120,12 +120,17 @@ angular.module('SEED.controller.inventory_group_detail_systems', []) } }); - modalInstance.result.finally(() => { - $state.reload().then(() => { - $timeout(() => { - expand_service(system); - }, 0); - }); + modalInstance.result.then( + () => { + $state.reload().then(() => { + $timeout(() => { + expand_service(system); + }, 0); + }); + }, + () => { + console.log('here') + // do nothing }); }; diff --git a/seed/static/seed/partials/meter_edit_modal.html b/seed/static/seed/partials/meter_edit_modal.html index b1b1288295..f92fda04e0 100644 --- a/seed/static/seed/partials/meter_edit_modal.html +++ b/seed/static/seed/partials/meter_edit_modal.html @@ -26,7 +26,7 @@

Configure {$ meter_parent $} Meter Details

diff --git a/seed/static/seed/partials/service_modal.html b/seed/static/seed/partials/service_modal.html index d55225ee92..3f3dd9cff6 100644 --- a/seed/static/seed/partials/service_modal.html +++ b/seed/static/seed/partials/service_modal.html @@ -15,7 +15,7 @@
- @@ -28,9 +28,9 @@ - + - +
@@ -40,19 +40,19 @@ - + - +
- + - + - +
diff --git a/seed/static/seed/partials/systems_table.html b/seed/static/seed/partials/systems_table.html index 192b0b1710..c0def42ebf 100644 --- a/seed/static/seed/partials/systems_table.html +++ b/seed/static/seed/partials/systems_table.html @@ -22,7 +22,7 @@
- +
From aaefb605da6f458dec8063230716e446199c4e1e Mon Sep 17 00:00:00 2001 From: Ross Perry Date: Wed, 6 Nov 2024 16:14:40 -0700 Subject: [PATCH 2/9] update meter enums --- ...106_1325.py => 0237_auto_20241106_1339.py} | 7 +++- seed/models/meters.py | 32 +++++++-------- seed/tests/test_inventory_groups.py | 4 +- seed/tests/test_meter_views.py | 40 +++++++++---------- seed/tests/test_property_views.py | 6 +-- seed/utils/meters.py | 12 +++--- seed/views/v3/inventory_groups.py | 4 +- 7 files changed, 55 insertions(+), 50 deletions(-) rename seed/migrations/{0237_auto_20241106_1325.py => 0237_auto_20241106_1339.py} (58%) diff --git a/seed/migrations/0237_auto_20241106_1325.py b/seed/migrations/0237_auto_20241106_1339.py similarity index 58% rename from seed/migrations/0237_auto_20241106_1325.py rename to seed/migrations/0237_auto_20241106_1339.py index 55913f22d7..cac5d72bbe 100644 --- a/seed/migrations/0237_auto_20241106_1325.py +++ b/seed/migrations/0237_auto_20241106_1339.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.25 on 2024-11-06 21:25 +# Generated by Django 3.2.25 on 2024-11-06 21:39 from django.db import migrations, models @@ -15,6 +15,11 @@ class Migration(migrations.Migration): name='efficiency', field=models.FloatField(), ), + migrations.AlterField( + model_name='meter', + name='connection_type', + field=models.IntegerField(choices=[(1, 'Imported'), (2, 'Exported'), (3, 'Receiving Service'), (4, 'Returning To Service'), (5, 'Total From Users'), (6, 'Total To Users')], default=1), + ), migrations.AlterField( model_name='service', name='emission_factor', diff --git a/seed/models/meters.py b/seed/models/meters.py index 1003a447ba..934449e936 100644 --- a/seed/models/meters.py +++ b/seed/models/meters.py @@ -15,24 +15,24 @@ class Meter(models.Model): ## CONNECTION TYPES # These connection types do not require services. May be on a property or system - FROM_OUTSIDE = 1 # tracks what is received via an unknown source - TO_OUTSIDE = 2 # tracks what is expelled via an unknown source + IMPORTED = 1 # tracks what is received via an unknown source + EXPORTED = 2 # tracks what is expelled via an unknown source # These connection types require services. May be on a property or system - FROM_SERVICE_TO_PATRON = 3 # tracks what is received via my service - FROM_PATRON_TO_SERVICE = 4 # tracks what is expelled via my service + RECEIVING_SERVICE = 3 # tracks what is received via my service + RETURNING_TO_SERVICE = 4 # tracks what is expelled via my service # These connection types require services and may only be on Systems - TOTAL_FROM_PATRON = 5 # tracks everything that this system expelled via my service - TOTAL_TO_PATRON = 6 # tracks everything that this system received via my service + TOTAL_FROM_USERS = 5 # tracks everything that this system expelled via my service + TOTAL_TO_USERS = 6 # tracks everything that this system received via my service CONNECTION_TYPES = ( - (FROM_OUTSIDE, "From Outside"), - (TO_OUTSIDE, "To Outside"), - (FROM_SERVICE_TO_PATRON, "From Service To Patron"), - (FROM_PATRON_TO_SERVICE, "From Patron To Service"), - (TOTAL_FROM_PATRON, "Total From Patron"), - (TOTAL_TO_PATRON, "Total To Patron"), + (IMPORTED, "Imported"), + (EXPORTED, "Exported"), + (RECEIVING_SERVICE, "Receiving Service"), + (RETURNING_TO_SERVICE, "Returning To Service"), + (TOTAL_FROM_USERS, "Total From Users"), + (TOTAL_TO_USERS, "Total To Users"), ) COAL_ANTHRACITE = 1 @@ -165,7 +165,7 @@ class Meter(models.Model): type = models.IntegerField(choices=ENERGY_TYPES, default=None, null=True) service = models.ForeignKey("Service", on_delete=models.SET_NULL, related_name="meters", null=True, blank=True) - connection_type = models.IntegerField(choices=CONNECTION_TYPES, default=FROM_OUTSIDE, null=False) + connection_type = models.IntegerField(choices=CONNECTION_TYPES, default=IMPORTED, null=False) def copy_readings(self, source_meter, overlaps_possible=True): """ @@ -218,7 +218,7 @@ def presave_meter(sender, instance, **kwargs): if property is not None and system is not None: raise IntegrityError(f"Meter {instance.id} has both a property and a system. It must only have one.") - outside_connection = connection_type in [Meter.FROM_OUTSIDE, Meter.TO_OUTSIDE] + outside_connection = connection_type in [Meter.IMPORTED, Meter.EXPORTED] if outside_connection: # outside connections don't have services if instance.service is not None: @@ -228,7 +228,7 @@ def presave_meter(sender, instance, **kwargs): if service is None: raise IntegrityError(f"Meter {instance.id} has connection_type '{connection_string}', but is not connected to a service") - total_connections = connection_type in [Meter.TOTAL_FROM_PATRON, Meter.TOTAL_TO_PATRON] + total_connections = connection_type in [Meter.TOTAL_FROM_USERS, Meter.TOTAL_TO_USERS] if total_connections: # Only systems have connection type "total" if system is None: @@ -245,7 +245,7 @@ def presave_meter(sender, instance, **kwargs): if Meter.objects.filter(service=service, connection_type=connection_type).exclude(pk=instance.pk).exists(): raise IntegrityError(f"Service {service.id} already has a meter with connection type '{connection_string}'") - elif property: # Meter.FROM_PATRON_TO_SERVICE and Meter.FROM_SERVICE_TO_PATRON + elif property: # Meter.RETURNING_TO_SERVICE and Meter.RECEIVING_SERVICE # service must be within the meter's property's group property_groups = InventoryGroupMapping.objects.filter(property=property).values_list("group_id", flat=True) if service is not None and service.system.group.id not in property_groups: diff --git a/seed/tests/test_inventory_groups.py b/seed/tests/test_inventory_groups.py index 415c2c1643..4f51687f72 100644 --- a/seed/tests/test_inventory_groups.py +++ b/seed/tests/test_inventory_groups.py @@ -74,7 +74,7 @@ def setUp(self): # helper functions to create meters and readings def create_meter_entry(property_view_id, source_id): - payload = {"type": "Electric", "source": "Manual Entry", "source_id": source_id, "connection_type": "From Outside"} + payload = {"type": "Electric", "source": "Manual Entry", "source_id": source_id, "connection_type": "Imported"} url = reverse_lazy("api:v3:property-meters-list", kwargs={"property_pk": property_view_id}) + f"?organization_id={self.org.id}" response = self.client.post(url, data=json.dumps(payload), content_type="application/json") return response.json()["id"] @@ -212,7 +212,7 @@ def setUp(self): # helper functions to create meters and readings def create_meter_entry(property_view_id, source_id): - payload = {"type": "Electric", "source": "Manual Entry", "source_id": source_id, "connection_type": "From Outside"} + payload = {"type": "Electric", "source": "Manual Entry", "source_id": source_id, "connection_type": "Imported"} url = reverse_lazy("api:v3:property-meters-list", kwargs={"property_pk": property_view_id}) + f"?organization_id={self.org.id}" response = self.client.post(url, data=json.dumps(payload), content_type="application/json") return response.json()["id"] diff --git a/seed/tests/test_meter_views.py b/seed/tests/test_meter_views.py index 3dc2104c5d..f7b15596a0 100644 --- a/seed/tests/test_meter_views.py +++ b/seed/tests/test_meter_views.py @@ -73,7 +73,7 @@ def test_create_meter(self): "type": "Electric - Grid", "source": "GreenButton", "source_id": "1234567890", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -84,7 +84,7 @@ def test_create_meter(self): "type": "Electric - Grid", "source": "GreenButton", "source_id": "/v1/User/000/UsagePoint/123fakeID/MeterReading/000", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -98,7 +98,7 @@ def test_create_meter(self): "source": "Portfolio Manager", "source_id": "A Custom Source ID", "is_virtual": True, - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -120,7 +120,7 @@ def test_create_meter_with_scenario(self): "source": "GreenButton", "source_id": "1234567890", "scenario_id": scenario.pk, - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -150,7 +150,7 @@ def test_create_meter_with_not_my_scenario(self): "source": "GreenButton", "source_id": "1234567890", "scenario_id": their_scenario.pk, - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") self.assertEqual(response.status_code, 400) @@ -166,7 +166,7 @@ def test_delete_meter(self): "source": "Portfolio Manager", "source_id": "A Custom Source ID", "is_virtual": True, - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") self.assertEqual(response.status_code, 201) @@ -198,7 +198,7 @@ def test_update_meter(self): "source": "Portfolio Manager", "source_id": "A Custom Source ID", "is_virtual": False, - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") self.assertEqual(response.status_code, 201) @@ -281,7 +281,7 @@ def test_get_meters_delete_permissions(self): def test_create_meter_permissions(self): url = reverse("api:v3:property-meters-list", kwargs={"property_pk": self.property_view.id}) + f"?organization_id={self.org.id}" - payload = {"type": "Electric", "source": "Manual Entry", "source_id": "1234567890", "connection_type": "From Outside"} + payload = {"type": "Electric", "source": "Manual Entry", "source_id": "1234567890", "connection_type": "Imported"} # root users can create meters in root self.login_as_root_member() @@ -298,7 +298,7 @@ def test_update_meter_permissions(self): reverse("api:v3:property-meters-detail", kwargs={"property_pk": self.property_view.id, "pk": self.meter.id}) + f"?organization_id={self.org.id}" ) - payload = {"type": "Electric", "source": "Manual Entry", "source_id": "boo", "connection_type": "From Outside"} + payload = {"type": "Electric", "source": "Manual Entry", "source_id": "boo", "connection_type": "Imported"} # root users can see meters in root self.login_as_root_member() @@ -461,7 +461,7 @@ def test_create_meter_readings(self): "type": "Electric", "source": "Manual Entry", "source_id": "1234567890", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -507,7 +507,7 @@ def test_create_two_meters_readings(self): "type": "Electric", "source": "Manual Entry", "source_id": "1234567890", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url_meters, data=json.dumps(payload), content_type="application/json") meter_pk_1 = response.json()["id"] @@ -516,7 +516,7 @@ def test_create_two_meters_readings(self): "type": "Natural Gas", "source": "Manual Entry", "source_id": "9876543210", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url_meters, data=json.dumps(payload), content_type="application/json") meter_pk_2 = response.json()["id"] @@ -572,7 +572,7 @@ def test_create_two_meters_bulk_readings(self): "type": "Electric", "source": "Manual Entry", "source_id": "1234567890", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url_meters, data=json.dumps(payload), content_type="application/json") meter_pk_1 = response.json()["id"] @@ -581,7 +581,7 @@ def test_create_two_meters_bulk_readings(self): "type": "Natural Gas", "source": "Manual Entry", "source_id": "9876543210", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url_meters, data=json.dumps(payload), content_type="application/json") meter_pk_2 = response.json()["id"] @@ -644,7 +644,7 @@ def test_error_with_time_aware(self): "type": "Electric", "source": "Manual Entry", "source_id": "1234567890", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -694,7 +694,7 @@ def test_bulk_import(self): "type": "Electric", "source": "Manual Entry", "source_id": "1234567890", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -744,7 +744,7 @@ def test_bulk_import_duplicate_dates(self): "type": "Electric", "source": "Manual Entry", "source_id": "1234567890", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -788,7 +788,7 @@ def test_delete_meter_readings(self): "type": "Natural Gas", "source": "Manual Entry", "source_id": "9876543210", - "connection_type": "From Outside", + "connection_type": "Imported", } response = self.client.post(url, data=json.dumps(payload), content_type="application/json") @@ -875,7 +875,7 @@ def test_meter_readings_update(self): reverse("api:v3:property-meters-detail", kwargs={"property_pk": self.view.id, "pk": self.meter.id}) + f"?organization_id={self.org.id}" ) - param = json.dumps({"type": "Electric", "source": "Manual Entry", "source_id": "boo", "connection_type": "From Outside"}) + param = json.dumps({"type": "Electric", "source": "Manual Entry", "source_id": "boo", "connection_type": "Imported"}) # root member can self.login_as_root_member() @@ -889,7 +889,7 @@ def test_meter_readings_update(self): def test_meter_readings_create(self): url = reverse("api:v3:property-meters-list", kwargs={"property_pk": self.view.id}) + f"?organization_id={self.org.id}" - param = json.dumps({"type": "Electric", "source": "Manual Entry", "source_id": "boo", "connection_type": "From Outside"}) + param = json.dumps({"type": "Electric", "source": "Manual Entry", "source_id": "boo", "connection_type": "Imported"}) # root member can self.login_as_root_member() diff --git a/seed/tests/test_property_views.py b/seed/tests/test_property_views.py index f91daee215..2ee64b7ef3 100644 --- a/seed/tests/test_property_views.py +++ b/seed/tests/test_property_views.py @@ -1996,7 +1996,7 @@ def test_property_meters_endpoint_returns_a_list_of_meters_of_a_view(self): "system_id": None, "use": "outside", }, - "connection_type": "From Outside", + "connection_type": "Imported", "service_name": None, "service_group": None, "service_id": None, @@ -2021,7 +2021,7 @@ def test_property_meters_endpoint_returns_a_list_of_meters_of_a_view(self): "system_id": None, "use": "outside", }, - "connection_type": "From Outside", + "connection_type": "Imported", "service_name": None, "service_group": None, "service_id": None, @@ -2046,7 +2046,7 @@ def test_property_meters_endpoint_returns_a_list_of_meters_of_a_view(self): "system_id": None, "use": "outside", }, - "connection_type": "From Outside", + "connection_type": "Imported", "service_name": None, "service_group": None, "service_id": None, diff --git a/seed/utils/meters.py b/seed/utils/meters.py index a49a300a07..429cc1faa5 100644 --- a/seed/utils/meters.py +++ b/seed/utils/meters.py @@ -315,12 +315,12 @@ def update_meter_connection(meter, meter_config): meter.service = Service.objects.get(pk=service_id) if service_id else None connection_lookup = { - "inflow using": Meter.FROM_SERVICE_TO_PATRON, - "inflow offering": Meter.TOTAL_FROM_PATRON, - "inflow outside": Meter.FROM_OUTSIDE, - "outflow using": Meter.FROM_PATRON_TO_SERVICE, - "outflow offering": Meter.TOTAL_TO_PATRON, - "outflow outside": Meter.TO_OUTSIDE, + "inflow using": Meter.RECEIVING_SERVICE, + "inflow offering": Meter.TOTAL_FROM_USERS, + "inflow outside": Meter.IMPORTED, + "outflow using": Meter.RETURNING_TO_SERVICE, + "outflow offering": Meter.TOTAL_TO_USERS, + "outflow outside": Meter.EXPORTED, } direction = meter_config.get("direction") use = meter_config.get("use") or "outside" diff --git a/seed/views/v3/inventory_groups.py b/seed/views/v3/inventory_groups.py index defaa9506f..96d7d39838 100644 --- a/seed/views/v3/inventory_groups.py +++ b/seed/views/v3/inventory_groups.py @@ -116,7 +116,7 @@ def dashboard(self, request, pk): # add meter based info systems = System.objects.filter(group_id=pk) - system_import_meters = Meter.objects.filter(system__in=systems, connection_type=Meter.FROM_OUTSIDE) + system_import_meters = Meter.objects.filter(system__in=systems, connection_type=Meter.IMPORTED) system_import_meters_readings_in_cycle = MeterReading.objects.filter( meter__in=system_import_meters, start_time__gte=cycle.start, end_time__lte=cycle.end ) @@ -136,7 +136,7 @@ def dashboard(self, request, pk): # add service based info services = Service.objects.filter(system__in=systems) - service_total_meters = Meter.objects.filter(service__in=services, connection_type=Meter.TOTAL_TO_PATRON) + service_total_meters = Meter.objects.filter(service__in=services, connection_type=Meter.TOTAL_TO_USERS) service_total_meter_readings = MeterReading.objects.filter( meter__in=service_total_meters, start_time__gte=cycle.start, end_time__lte=cycle.end ) From 24a93ca56d3ca7100058d199fa03901b67b8e5da Mon Sep 17 00:00:00 2001 From: Ross Perry Date: Wed, 6 Nov 2024 16:14:49 -0700 Subject: [PATCH 3/9] property display field --- seed/serializers/meters.py | 12 +++++++----- .../inventory_group_detail_meters_controller.js | 8 ++++++-- seed/static/seed/js/seed.js | 10 +++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/seed/serializers/meters.py b/seed/serializers/meters.py index cc8434a774..7d9f3b796a 100644 --- a/seed/serializers/meters.py +++ b/seed/serializers/meters.py @@ -6,7 +6,7 @@ from rest_framework import serializers from seed.data_importer.utils import usage_point_id -from seed.models import Meter, Scenario +from seed.models import Meter, Scenario, Property from seed.serializers.base import ChoiceField from seed.utils.api import OrgMixin @@ -47,15 +47,12 @@ def validate_scenario_id(self, scenario_id): def to_representation(self, obj): result = super().to_representation(obj) - if obj.source == Meter.GREENBUTTON: result["source_id"] = usage_point_id(obj.source_id) - result["scenario_name"] = obj.scenario.name if obj.scenario else None - if obj.alias is None or obj.alias == "": result["alias"] = f"{obj.get_type_display()} - {obj.get_source_display()} - {result['source_id']}" - + self.get_property_display_name(obj, result) self.set_config(obj, result) return result @@ -80,3 +77,8 @@ def set_config(self, obj, result): config = {"group_id": group_id, "system_id": system_id, "service_id": obj.service_id, **connection_lookup[obj.connection_type]} result["config"] = config + + def get_property_display_name(self, obj, result): + state = obj.property.views.first().state + property_display_field = state.organization.property_display_field + result["property_display_field"] = getattr(state, property_display_field, 'Unknown') diff --git a/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js b/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js index 91666417dc..134c6c5b49 100644 --- a/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js +++ b/seed/static/seed/js/controllers/inventory_group_detail_meters_controller.js @@ -20,6 +20,7 @@ angular.module('SEED.controller.inventory_group_detail_meters', []) 'urls', 'organization_payload', 'group', + 'columns', // eslint-disable-next-line func-names function ( $scope, @@ -37,7 +38,8 @@ angular.module('SEED.controller.inventory_group_detail_meters', []) property_meter_usage, urls, organization_payload, - group + group, + columns, ) { // Ideally, these should be translatable, but the "selected" property // should always be in English as this gets sent to BE. @@ -58,6 +60,8 @@ angular.module('SEED.controller.inventory_group_detail_meters', []) $scope.organization = organization_payload.organization; $scope.filler_cycle = cycles.cycles[0].id; + const property_display_name = columns.find(col => col.column_name == $scope.organization.property_display_field).display_name; + $scope.inventory = { view_id: $stateParams.view_id }; @@ -111,7 +115,7 @@ angular.module('SEED.controller.inventory_group_detail_meters', []) { field: 'source_id' }, { field: 'scenario_id' }, { field: 'connection_type' }, - { field: 'property_id' }, + { field: 'property_display_field', displayName: property_display_name}, { field: 'system_name' }, { field: 'service_name', displayName: 'Connection', cellTemplate: '{$ row.entity.service_name $}' }, { field: 'is_virtual' }, diff --git a/seed/static/seed/js/seed.js b/seed/static/seed/js/seed.js index a531d0a71c..5c8f24a50c 100644 --- a/seed/static/seed/js/seed.js +++ b/seed/static/seed/js/seed.js @@ -2337,7 +2337,15 @@ '$stateParams', 'inventory_group_service', 'user_service', ($stateParams, inventory_group_service, user_service) => inventory_group_service.get_group(user_service.get_organization().id, $stateParams.group_id) ], - groups: () => null + columns: [ + '$stateParams', + 'inventory_service', + 'user_service', + ($stateParams, inventory_service, user_service) => { + const org_id = user_service.get_organization().id; + return inventory_service.get_property_column_names_for_org(org_id) + } + ], } }) .state({ From d9fd6fcece435b56a21ee56859c89c07a6f15294 Mon Sep 17 00:00:00 2001 From: Ross Perry Date: Thu, 7 Nov 2024 09:18:58 -0700 Subject: [PATCH 4/9] alphabetical actions --- seed/static/seed/partials/inventory_list.html | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/seed/static/seed/partials/inventory_list.html b/seed/static/seed/partials/inventory_list.html index 0f12369b9b..c6aa566093 100644 --- a/seed/static/seed/partials/inventory_list.html +++ b/seed/static/seed/partials/inventory_list.html @@ -52,10 +52,15 @@

{$:: (group_id? 'Group - ': '')$}{$:: (inventory_type === 'taxlots' ? 'Tax L - - + + + + + + + + - - - - - - + + + - - - - + - +