Skip to content

Commit

Permalink
rename organization for organization_name
Browse files Browse the repository at this point in the history
  • Loading branch information
areyeslo committed Dec 9, 2024
1 parent a55abae commit fa63911
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Add Organization to FSE
"""Add Organization name to FSE
Revision ID: 9206124a098b
Revises: aeaa26f5cdd5
Expand All @@ -10,16 +10,16 @@

# revision identifiers, used by Alembic.
revision = '9206124a098b'
down_revision = '8491890dd688'
down_revision = '26ab15f8ab18'
branch_labels = None
depends_on = None


def upgrade():
# Add the column 'organization' to 'final_supply_equipment' table
op.add_column("final_supply_equipment", sa.Column("organization", sa.String(), nullable=True))
# Add the column 'organization_name' to 'final_supply_equipment' table
op.add_column("final_supply_equipment", sa.Column("organization_name", sa.String(), nullable=True))


def downgrade():
# Remove the column 'organization' from 'final_supply_equipment' table
op.drop_column("final_supply_equipment", "organization")
# Remove the column 'organization_name' from 'final_supply_equipment' table
op.drop_column("final_supply_equipment", "organization_name")
2 changes: 1 addition & 1 deletion backend/lcfs/db/models/compliance/FinalSupplyEquipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class FinalSupplyEquipment(BaseModel, Auditable):
Double, nullable=False, comment="The longitude of the equipment location."
)
notes = Column(Text, comment="Any additional notes related to the equipment.")
organization = Column(Text, comment="External organization.")
organization_name = Column(Text, comment="External organization name.")

# relationships
compliance_report = relationship(
Expand Down
2 changes: 1 addition & 1 deletion backend/lcfs/web/api/compliance_report/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class FSEOptionsSchema(BaseSchema):
class FinalSupplyEquipmentSchema(BaseSchema):
final_supply_equipment_id: int
compliance_report_id: int
organization: str
organization_name: str
supply_from_date: date
supply_to_date: date
registration_nbr: str
Expand Down
10 changes: 5 additions & 5 deletions backend/lcfs/web/api/final_supply_equipment/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ async def get_fse_options(
levels_of_equipment = await self.get_levels_of_equipment()
fuel_measurement_types = await self.get_fuel_measurement_types()
intended_user_types = await self.get_intended_user_types()
organizations = await self.get_organizations(organization)
organization_names = await self.get_organization_names(organization)
ports = list(PortsEnum)
return (
intended_use_types,
levels_of_equipment,
fuel_measurement_types,
intended_user_types,
ports,
organizations,
organization_names,
)

async def get_intended_use_types(self) -> List[EndUseType]:
Expand Down Expand Up @@ -102,7 +102,7 @@ async def get_intended_user_types(self) -> List[EndUserType]:
.all()
)

async def get_organizations(self, organization) -> List[str]:
async def get_organization_names(self, organization) -> List[str]:
"""
Retrieve unique organization names for Final Supply Equipment records
associated with the given organization_id via ComplianceReport.
Expand All @@ -115,10 +115,10 @@ async def get_organizations(self, organization) -> List[str]:
"""
organization_names = (
await self.db.execute(
select(distinct(FinalSupplyEquipment.organization))
select(distinct(FinalSupplyEquipment.organization_name))
.join(ComplianceReport, FinalSupplyEquipment.compliance_report_id == ComplianceReport.compliance_report_id)
.filter(ComplianceReport.organization_id == organization.organization_id)
.filter(FinalSupplyEquipment.organization.isnot(None))
.filter(FinalSupplyEquipment.organization_name.isnot(None))
)
).all()

Expand Down
4 changes: 2 additions & 2 deletions backend/lcfs/web/api/final_supply_equipment/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class FSEOptionsSchema(BaseSchema):
levels_of_equipment: List[LevelOfEquipmentSchema]
intended_user_types: List[EndUserTypeSchema]
ports: List[PortsEnum]
organizations: List[str]
organization_names: List[str]


class FinalSupplyEquipmentCreateSchema(BaseSchema):
final_supply_equipment_id: Optional[int] = None
compliance_report_id: Optional[int] = None
organization: str
organization_name: str
supply_from_date: date
supply_to_date: date
kwh_usage: float
Expand Down
8 changes: 4 additions & 4 deletions backend/lcfs/web/api/final_supply_equipment/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def __init__(
@service_handler
async def get_fse_options(self):
"""Fetches all FSE options concurrently."""
organization= self.request.user.organization
organization = self.request.user.organization
(
intended_use_types,
levels_of_equipment,
fuel_measurement_types,
intended_user_types,
ports,
organizations
organization_names,
) = await self.repo.get_fse_options(organization)

return {
Expand All @@ -54,7 +54,7 @@ async def get_fse_options(self):
EndUserTypeSchema.model_validate(u) for u in intended_user_types
],
"ports": [port.value for port in ports],
"organizations": organizations,
"organization_names": organization_names,
}

async def convert_to_fse_model(self, fse: FinalSupplyEquipmentCreateSchema):
Expand Down Expand Up @@ -144,7 +144,7 @@ async def update_final_supply_equipment(
if not existing_fse:
raise ValueError("final supply equipment not found")

existing_fse.organization = fse_data.organization
existing_fse.organization_name = fse_data.organization_name
existing_fse.kwh_usage = fse_data.kwh_usage
existing_fse.serial_nbr = fse_data.serial_nbr
existing_fse.manufacturer = fse_data.manufacturer
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/locales/en/finalSupplyEquipment.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"rows": "rows",
"finalSupplyEquipmentColLabels": {
"complianceReportId": "Compliance Report ID",
"organization": "Organization",
"organizationName": "Organization",
"supplyFrom": "Supply date range",
"kwhUsage":"kWh usage",
"supplyFromDate": "Dates of supply from",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export const FinalSupplyEquipmentSummary = ({ data }) => {
() => [
{
headerName: t(
'finalSupplyEquipment:finalSupplyEquipmentColLabels.organization'
'finalSupplyEquipment:finalSupplyEquipmentColLabels.organizationName'
),
field: 'organization'
field: 'organizationName'
},
{
headerName: t(
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/views/FinalSupplyEquipments/_schema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ export const finalSupplyEquipmentColDefs = (
hide: true
},
{
field: 'organization',
field: 'organizationName',
headerComponent: RequiredHeader,
headerName: i18n.t(
'finalSupplyEquipment:finalSupplyEquipmentColLabels.organization'
'finalSupplyEquipment:finalSupplyEquipmentColLabels.organizationName'
),
cellEditor: AutocompleteCellEditor,
cellRenderer: (params) =>
params.value ||
(!params.value && <Typography variant="body4">Select</Typography>),
cellEditorParams: {
options: optionsData?.organizations?.sort() || [],
options: optionsData?.organizationNames?.sort() || [],
multiple: false,
disableCloseOnSelect: false,
freeSolo: true,
Expand All @@ -64,18 +64,18 @@ export const finalSupplyEquipmentColDefs = (
minWidth: 260,
editable: true,
valueGetter: (params) => {
return params.data?.organization || '';
return params.data?.organizationName || '';
},
valueSetter: (params) => {
if (params.newValue) {
const isValidOrganization = optionsData?.organizations.includes(params.newValue);
const isValidOrganizationName = optionsData?.organizationNames.includes(params.newValue);

params.data.organization = isValidOrganization ? params.newValue : params.newValue;
params.data.organizationName = isValidOrganizationName ? params.newValue : params.newValue;
return true;
}
return false;
},
tooltipValueGetter: (params) => "Select the organization from the list"
tooltipValueGetter: (params) => "Select the organization name from the list"
},
{
field: 'supplyFrom',
Expand Down

0 comments on commit fa63911

Please sign in to comment.