Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Perry authored and Ross Perry committed Nov 22, 2024
1 parent 5461321 commit 15ddbc1
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 40 deletions.
59 changes: 31 additions & 28 deletions seed/migrations/0237_auto_20241106_1339.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Django 3.2.25 on 2024-11-06 21:39

from django.db import migrations, models
import quantityfield.fields
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down Expand Up @@ -36,53 +36,56 @@ class Migration(migrations.Migration):
field=models.FloatField(null=True),
),
migrations.RemoveField(
model_name='batterysystem',
name='capacity',
model_name="batterysystem",
name="capacity",
),
migrations.RemoveField(
model_name='dessystem',
name='capacity',
model_name="dessystem",
name="capacity",
),
migrations.AddField(
model_name='batterysystem',
name='energy_capacity',
field=quantityfield.fields.QuantityField(base_units='kWh', default=1, unit_choices=['kWh']),
model_name="batterysystem",
name="energy_capacity",
field=quantityfield.fields.QuantityField(base_units="kWh", default=1, unit_choices=["kWh"]),
preserve_default=False,
),
migrations.AddField(
model_name='batterysystem',
name='power_capacity',
field=quantityfield.fields.QuantityField(base_units='kW', default=1, unit_choices=['kW']),
model_name="batterysystem",
name="power_capacity",
field=quantityfield.fields.QuantityField(base_units="kW", default=1, unit_choices=["kW"]),
preserve_default=False,
),
migrations.AddField(
model_name='dessystem',
name='cooling_capacity',
field=quantityfield.fields.QuantityField(base_units='Ton', null=True, unit_choices=['Ton']),
model_name="dessystem",
name="cooling_capacity",
field=quantityfield.fields.QuantityField(base_units="Ton", null=True, unit_choices=["Ton"]),
),
migrations.AddField(
model_name='dessystem',
name='heating_capacity',
field=quantityfield.fields.QuantityField(base_units='MMBtu', null=True, unit_choices=['MMBtu']),
model_name="dessystem",
name="heating_capacity",
field=quantityfield.fields.QuantityField(base_units="MMBtu", null=True, unit_choices=["MMBtu"]),
),
migrations.AddField(
model_name='evsesystem',
name='voltage',
field=quantityfield.fields.QuantityField(base_units='V', default=1, unit_choices=['V']),
model_name="evsesystem",
name="voltage",
field=quantityfield.fields.QuantityField(base_units="V", default=1, unit_choices=["V"]),
preserve_default=False,
),
migrations.AlterField(
model_name='batterysystem',
name='voltage',
field=quantityfield.fields.QuantityField(base_units='V', unit_choices=['V']),
model_name="batterysystem",
name="voltage",
field=quantityfield.fields.QuantityField(base_units="V", unit_choices=["V"]),
),
migrations.AlterField(
model_name='evsesystem',
name='power',
field=quantityfield.fields.QuantityField(base_units='kW', unit_choices=['kW']),
model_name="evsesystem",
name="power",
field=quantityfield.fields.QuantityField(base_units="kW", unit_choices=["kW"]),
),
migrations.AddConstraint(
model_name='dessystem',
constraint=models.CheckConstraint(check=models.Q(('heating_capacity__isnull', False), ('cooling_capacity__isnull', False), _connector='OR'), name='heating_or_cooling_capacity_required'),
model_name="dessystem",
constraint=models.CheckConstraint(
check=models.Q(("heating_capacity__isnull", False), ("cooling_capacity__isnull", False), _connector="OR"),
name="heating_or_cooling_capacity_required",
),
),
]
6 changes: 3 additions & 3 deletions seed/models/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ureg.define("MMBtu = 1e6 * Btu")
ureg.define("Ton = 12000 * Btu / hour")


class System(models.Model):
name = models.CharField(max_length=255)
group = models.ForeignKey(InventoryGroup, on_delete=models.CASCADE, related_name="systems")
Expand Down Expand Up @@ -44,11 +45,11 @@ class DESSystem(System):
class Meta:
constraints = [
models.CheckConstraint(
check=Q(heating_capacity__isnull=False) | Q(cooling_capacity__isnull=False),
name="heating_or_cooling_capacity_required"
check=Q(heating_capacity__isnull=False) | Q(cooling_capacity__isnull=False), name="heating_or_cooling_capacity_required"
)
]


class EVSESystem(System):
LEVEL1 = 0
LEVEL2 = 1
Expand All @@ -65,7 +66,6 @@ class EVSESystem(System):
count = models.IntegerField(default=1, null=False)



class BatterySystem(System):
efficiency = models.FloatField(null=False)
power_capacity = QuantityField("kW", null=False)
Expand Down
2 changes: 1 addition & 1 deletion seed/serializers/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def to_representation(self, obj):
"cooling_capacity": collapse_unit(org, obj.cooling_capacity),
"count": obj.count,
"heating_capacity": collapse_unit(org, obj.heating_capacity),
"mode": mode
"mode": mode,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ angular.module('SEED.controller.inventory_group_detail_systems', [])
$scope.group_id = $stateParams.group_id;
$scope.inventory_display_name = group.name;
$scope.systems = systems.data;
const system_types = ['DES - Cooling', 'DES - Heating', 'EVSE', 'Battery']
const all_systems = system_types.flatMap(type => $scope.systems[type] ?? [])
const system_types = ['DES - Cooling', 'DES - Heating', 'EVSE', 'Battery'];
const all_systems = system_types.flatMap((type) => $scope.systems[type] ?? []);
const org_id = organization_payload.organization.id;
$scope.filler_cycle = cycles.cycles[0].id;

Expand Down
6 changes: 3 additions & 3 deletions seed/static/seed/js/controllers/system_modal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ angular.module('SEED.controller.system_modal', []).controller('system_modal_cont
} else {
$scope.system_heating_capacity = null;
}
}
};
if ($scope.system.type === 'des') {
$scope.change_des_type();
}
Expand All @@ -65,8 +65,8 @@ angular.module('SEED.controller.system_modal', []).controller('system_modal_cont
},
(response) => {
let errors = response.data.errors;
if (typeof(errors) !== 'string') {
errors = Object.values(errors)
if (typeof (errors) !== 'string') {
errors = Object.values(errors);
}
Notification.error(`${errors}`);
}
Expand Down
2 changes: 1 addition & 1 deletion seed/static/seed/partials/system_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h4 class="modal-title" ng-switch-when="remove" translate>Remove System</h4>
<!-- DES -->
<div class="form-group system-container" ng-if="system.type == 'DES'">
<label class="control-label sectionLabel">DES Type</label>
<select class="form-control" ng-model="system.des_type" ng-dropdown ng-change="change_des_type()" required>
<select class="form-control" ng-model="system.des_type" ng-dropdown ng-change="change_des_type()" required>
<option ng-repeat="des_type in des_types" selected="selected" ng-value="des_type">{$:: des_type $}</option>
</select>
<div ng-if="system.des_type && system.des_type !== 'Chiller'">
Expand Down
5 changes: 3 additions & 2 deletions seed/static/seed/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5821,7 +5821,8 @@ tags-input .tags .tag-item {
}

.system-container {
input, select {
input,
select {
margin-bottom: 15px;
}
}
}
3 changes: 3 additions & 0 deletions seed/tests/test_property_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,7 @@ def test_property_meters_endpoint_returns_a_list_of_meters_of_a_view(self):
"service_name": None,
"service_group": None,
"service_id": None,
"property_display_field": self.property_view_1.state.address_line_1,
},
{
"id": gas_meter.id,
Expand All @@ -2025,6 +2026,7 @@ def test_property_meters_endpoint_returns_a_list_of_meters_of_a_view(self):
"service_name": None,
"service_group": None,
"service_id": None,
"property_display_field": self.property_view_1.state.address_line_1,
},
{
"id": gb_gas_meter.id,
Expand All @@ -2050,6 +2052,7 @@ def test_property_meters_endpoint_returns_a_list_of_meters_of_a_view(self):
"service_name": None,
"service_group": None,
"service_id": None,
"property_display_field": self.property_view_1.state.address_line_1,
},
]

Expand Down

0 comments on commit 15ddbc1

Please sign in to comment.