Skip to content

Commit

Permalink
Merge pull request #2377 from bcgov/fix-operation-registration-back-n…
Browse files Browse the repository at this point in the history
…avigation

Fix operation registration back navigation
  • Loading branch information
Sepehr-Sobhani authored Oct 17, 2024
2 parents 7fa4844 + 711619e commit 60b20dd
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 18 deletions.
4 changes: 2 additions & 2 deletions bc_obps/registration/api/v1/_facilities/facility_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


@router.get(
"/facilities/{facility_id}",
"/facilities/{uuid:facility_id}",
response={200: FacilityOut, custom_codes_4xx: Message},
tags=FACILITY_TAGS,
description="""Retrieves the details of a specific facility by its ID. The endpoint checks if the current user is authorized to access the facility.
Expand All @@ -36,7 +36,7 @@ def get_facility(request: HttpRequest, facility_id: UUID) -> Tuple[Literal[200],


@router.put(
"/facilities/{facility_id}",
"/facilities/{uuid:facility_id}",
response={200: FacilityOut, custom_codes_4xx: Message},
tags=FACILITY_TAGS,
description="""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


@router.get(
"/operations/{operation_id}/facilities",
"/operations/{uuid:operation_id}/facilities",
response={200: List[FacilityDesignatedOperationTimelineOut], custom_codes_4xx: Message},
tags=FACILITY_TAGS,
description="""Retrieves a paginated list of facilities based on the provided filters.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from uuid import UUID
from registration.models.facility_designated_operation_timeline import FacilityDesignatedOperationTimeline
from ninja import FilterSchema, ModelSchema, Field
from typing import Optional
Expand All @@ -7,6 +8,7 @@ class FacilityDesignatedOperationTimelineOut(ModelSchema):
facility__name: str = Field(..., alias="facility.name")
facility__type: str = Field(..., alias="facility.type")
facility__bcghg_id: Optional[str] = Field(None, alias="facility.bcghg_id")
facility__id: UUID = Field(..., alias="facility.id")

class Meta:
model = FacilityDesignatedOperationTimeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ def test_facilities_endpoint_unauthorized_roles_cannot_get(self):
)
assert response.status_code == 401

def test_get_facility_with_invalid_facility_id(self):
response = TestUtils.mock_get_with_auth_role(
self, endpoint=custom_reverse_lazy("get_facility", kwargs={"facility_id": '99999'}), role_name="cas_admin"
)
assert response.status_code == 422
assert (
response.json().get('detail')[0].get('msg')
== 'Input should be a valid UUID, invalid length: expected length 32 for simple format, found 5'
)

def test_industry_users_can_get_their_own_facilities(self):

operator = operator_baker()
Expand All @@ -113,7 +103,7 @@ def test_industry_users_can_get_their_own_facilities(self):
role_name="industry_user",
)
assert response.status_code == 200
response.json().get('name') is not None
assert response.json().get('name') is not None

def test_industry_users_cannot_get_other_users_facilities(self):
facility = facility_baker()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const FacilityInformationForm = ({
return (
<MultiStepBase
allowBackNavigation
baseUrl={`/register-an-operation/${operation}`}
cancelUrl="/"
formData={formState}
onChange={handleFormChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ const FacilityInformationPage = async ({
searchParams,
);

// Is there a cleaner way to get the facilityId for a single facility operation?
// May be worth creating an API endpoint to get the facilityId for a single facility operation
// in https://github.com/bcgov/cas-registration/issues/2065
const facilityId =
isOperationSfo && initialGridData.rows.length === 1
? initialGridData.rows[0].id
? initialGridData.rows[0].facility__id
: null;

// Get facility form data for SFO operations if facilityId is available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const RegistrationSubmissionForm = ({
) : (
<MultiStepBase
allowBackNavigation
baseUrl={`/register-an-operation/${operation}`}
cancelUrl="/"
formData={formState}
onSubmit={handleSubmit}
Expand Down

0 comments on commit 60b20dd

Please sign in to comment.