Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""adding project components and area inspected to inspecton model

Revision ID: f71662d8e6c6
Revises: 36db02e529a3
Create Date: 2026-02-19 14:04:12.318696

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f71662d8e6c6'
down_revision = '36db02e529a3'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('inspections', sa.Column('area_inspected', sa.String(), nullable=True))
op.add_column('inspections_version', sa.Column('area_inspected', sa.String(), nullable=True))
op.add_column('inspections_version', sa.Column('area_inspected_mod', sa.Boolean(), nullable=True))


def downgrade():
op.drop_column('inspections', 'area_inspected')
op.drop_column('inspections_version', 'area_inspected')
op.drop_column('inspections_version', 'area_inspected_mod')
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class Inspection(BaseModelVersioned):
Integer,
nullable=True,
)
area_inspected = Column(String, nullable=True, comment="A brief description of Project Components / Area Inspected")

initiation = relationship(
"InspectionInitiationOption", foreign_keys=[initiation_id], lazy="joined"
Expand Down
4 changes: 4 additions & 0 deletions compliance-api/src/compliance_api/schemas/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ class InspectionUpdateSchema(BaseSchema): # pylint: disable=too-many-ancestors
),
required=False,
)
area_inspected = fields.Str(
metadata={"description": "A brief description of Project Components / Area Inspected"},
allow_none=True,
)

@pre_load
def end_date_populate(
Expand Down
1 change: 1 addition & 0 deletions compliance-api/src/compliance_api/services/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ def _create_inspection_update_obj(inspection_data: dict):
"initiation_id": inspection_data.get("initiation_id"),
"debrief_date": inspection_data.get("debrief_date", None),
"project_status_id": inspection_data.get("project_status_id", None),
"area_inspected": inspection_data.get("area_inspected", None),
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,13 @@ def build_inspection_scope(self):
self.data["inspection_scope"] = self.existing_ir.inspection_scope
return self
debreif_date = self.inspection.debrief_date
area_inspected = self.inspection.area_inspected
inspection_scope_data = {
"debrief_date": (
convert_to_full_month_format(debreif_date) if debreif_date else None
), # handling of the null case
"requirements": [],
"area_inspected": area_inspected if area_inspected else None,
}
requirements = InspectionRequirementModel.get_by_inspection_id(
self.inspection.id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""IR template related constants."""

INSPECTION_SCOPE = """<p class="editor-paragraph" dir="ltr">
<span>The Officer inspected [Brief description of Project Components / Area inspected]</span>
<span>The Officer inspected {{ area_inspected }}.</span>
</p>
<p class="editor-paragraph" dir="ltr">
<span>The inspection included a debrief of observations with Project staff on {{ debrief_date }}.</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe("InspectionFormUtils", () => {
other: "Other Info",
firstNations: [{ id: 1, name: "First Nation 1" }],
agencies: [{ id: 1, name: "Agency 1" }],
areaInspected: "Area A",
};

const expectedFormattedData = {
Expand All @@ -94,6 +95,7 @@ describe("InspectionFormUtils", () => {
attendance_option_ids: [1, AttendanceEnum.OFFICERS],
attending_officer_ids: [2],
is_history: false,
area_inspected: "Area A",
};

const formattedData = formatInspectionAPIData(formData, 123);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const initFormData: InspectionFormData = {
projectDescription: "",
locationDescription: "",
utm: "",
debriefDate: undefined,
debriefDate: undefined,
areaInspected: "",
};

const InspectionDrawer: React.FC<InspectionDrawerProps> = ({
Expand Down Expand Up @@ -147,6 +148,7 @@ const InspectionDrawer: React.FC<InspectionDrawerProps> = ({
projectDescription: inspection.project_description ?? "",
locationDescription: inspection.location_description ?? "",
utm: inspection.utm ?? "",
areaInspected: inspection.area_inspected ?? "",
};
}
const selectedOfficer = staffUserList.find(
Expand All @@ -157,6 +159,7 @@ const InspectionDrawer: React.FC<InspectionDrawerProps> = ({
caseFileId: caseFile.id?.toString(),
primaryOfficer: selectedOfficer,
projectDescription: caseFile.project_description ?? "",
areaInspected: "",
};
}, [inspection, caseFile, staffUserList, currentUser?.preferred_username]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const InspectionFormLeft: FC<InspectionFormLeftProps> = ({
<ControlledTextField
name="locationDescription"
label="Location Description"
placeholder="Specify inspected location"
placeholder="Specify the project location"
multiline
fullWidth
minRows={2}
Expand All @@ -72,6 +72,14 @@ const InspectionFormLeft: FC<InspectionFormLeftProps> = ({
placeholder="eg. 9U 454135 6399452"
fullWidth
/>
<ControlledTextField
name="areaInspected"
label="Project Components / Area Inspected"
placeholder="Provide a brief description of Project Components / Area Inspected"
multiline
fullWidth
minRows={2}
/>
<Stack direction={"row"} gap={2}>
<ControlledAutoComplete
name="primaryOfficer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const InspectionFormSchema = yup.object().shape({
.required("Agencies are required"),
otherwise: (schema) => schema.notRequired(),
}),
areaInspected: yup.string().nullable(),
});

export type InspectionSchemaType = yup.InferType<typeof InspectionFormSchema>;
Expand Down Expand Up @@ -139,6 +140,7 @@ export const formatInspectionAPIData = (
utm: formData.utm ?? "",
project_status_id: (formData.projectStatus as ProjectStatus)?.id,
attendance_option_ids: inAttendanceOptions,
area_inspected: formData.areaInspected ?? "",
};

if (formData.officers?.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const InspectionGeneralInformation: React.FC<
value: inspectionData.location_description,
},
{ name: "UTM", value: inspectionData.utm },
{ name: "Project Components / Area Inspected", value: inspectionData.area_inspected },
{ name: "Primary", value: inspectionData.primary_officer?.name },
{ name: "Initiation", value: inspectionData.initiation?.name },
{
Expand Down
3 changes: 3 additions & 0 deletions compliance-web/src/models/Inspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface Inspection {
enforcement?: string;
ir_progress?: IRProgress;
is_history?: boolean;
area_inspected?: string;
}

export interface InspectionGridQueryParams extends BaseTableQueryParams {
Expand Down Expand Up @@ -131,6 +132,7 @@ export interface InspectionFormData {
projectDescription?: string;
locationDescription?: string;
utm?: string;
areaInspected?: string;
}

export interface InspectionAPIData {
Expand Down Expand Up @@ -158,6 +160,7 @@ export interface InspectionAPIData {
unapproved_project_type?: string;
unapproved_project_sub_type?: string;
is_history?: boolean;
area_inspected?: string;
}

export interface InspectionStatusAPIData {
Expand Down