-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1962 eio form #2738
1962 eio form #2738
Conversation
registration_purpose: Optional[Operation.Purposes] = None | ||
regulated_products: Optional[List[int]] = None | ||
activities: List[int] | ||
activities: Optional[List[int]] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only field that isn't already optional, so perhaps it's not worth making a separate EIO schema
"This type of operation (SFO or EIO) can only have one facility, this page should not be accessible" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this error for EIO too because I did manage to create a second facility while testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of get_current_facilities_by_operation
can we just say: operation.facilities.count()
? In a couple of places, we should change our approach and use the direct operation-facility/operator-operation relationships which are easier to understand and more readable.
Also, RuntimeError
is typically used for unexpected runtime issues rather than business logic validation. Since this is a domain-specific constraint, using an Exception
or ValueError
might be more appropriate.
ae1f6d1
to
c6baea2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
A couple of nits and comments but not blocker.
"This type of operation (SFO or EIO) can only have one facility, this page should not be accessible" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of get_current_facilities_by_operation
can we just say: operation.facilities.count()
? In a couple of places, we should change our approach and use the direct operation-facility/operator-operation relationships which are easier to understand and more readable.
Also, RuntimeError
is typically used for unexpected runtime issues rather than business logic validation. Since this is a domain-specific constraint, using an Exception
or ValueError
might be more appropriate.
eio_payload = FacilityIn( | ||
name=payload.name, type=Facility.Types.ELECTRICITY_IMPORT, operation_id=operation.id | ||
) | ||
facility = FacilityDataAccessService.get_current_facilities_by_operation(operation).first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well! We could say operation.facilities.first()
if operation.registration_purpose == Operation.Purposes.ELECTRICITY_IMPORT_OPERATION: | ||
# EIO operations have a facility with the same data as the operation | ||
eio_payload = FacilityIn( | ||
name=payload.name, type=Facility.Types.ELECTRICITY_IMPORT, operation_id=operation.id | ||
) | ||
facility = FacilityDataAccessService.get_current_facilities_by_operation(operation).first() | ||
|
||
if not facility: | ||
FacilityService.create_facilities_with_designated_operations(user_guid, [eio_payload]) | ||
else: | ||
FacilityService.update_facility(user_guid, facility.id, eio_payload) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this whole condition into a separate function?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently doing work on this function in the optimization PR, so I'll handle this there instead to avoid merge conflicts/accidentally un-optimizing
approved_user_operator = baker.make_recipe('utils.approved_user_operator') | ||
owning_operation: Operation = baker.make_recipe( | ||
'utils.operation', operator=approved_user_operator.operator, type="Linear Facility Operation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: suggest using the absolute path for recipes.(registration.tests.utils....
)
For some reason Model Bakery can't find our recipes after adding the RLS app; The only workaround is to use the absolute path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've hit this a few times now, thanks!
assert operation.registration_purpose == Operation.Purposes.ELECTRICITY_IMPORT_OPERATION | ||
assert operation.status == Operation.Statuses.DRAFT | ||
# check facility | ||
facilities = Facility.objects.filter(designated_operations__operation=operation).all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operation.facilities.all()
assert operation.status == Operation.Statuses.DRAFT | ||
facilities = Facility.objects.filter(designated_operations__operation=operation).all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here!
@@ -411,6 +472,8 @@ def test_register_operation_information_existing_operation(): | |||
# check purpose | |||
assert operation.registration_purpose == Operation.Purposes.POTENTIAL_REPORTING_OPERATION | |||
assert operation.status == Operation.Statuses.DRAFT | |||
facilities = Facility.objects.filter(designated_operations__operation=operation).all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here! :)
...(app === Apps.ADMINISTRATION | ||
? { | ||
bc_obps_regulated_operation: { | ||
type: "string", | ||
title: "BORO ID", | ||
}, | ||
} | ||
: {}), | ||
...(app === Apps.ADMINISTRATION | ||
? { | ||
bcghg_id: { | ||
type: "string", | ||
title: "BCGHGID", | ||
}, | ||
} | ||
: {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we say?
...(app === Apps.ADMINISTRATION && {
bc_obps_regulated_operation: {
type: "string",
title: "BORO ID",
},
bcghg_id: {
type: "string",
title: "BCGHGID",
},
}),
) { | ||
steps.splice(2, 0, OperationRegistrationSteps.OPT_IN_APPLICATION); | ||
} | ||
if (purpose == RegistrationPurposes.NEW_ENTRANT_OPERATION) | ||
if (purpose === RegistrationPurposes.NEW_ENTRANT_OPERATION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩
card: https://github.com/orgs/bcgov/projects/123/views/16?pane=issue&itemId=80445774&issue=bcgov%7Ccas-registration%7C1962
This PR: