Skip to content
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

fix: updated transfer labels for BCeID users according to new Act #2722

Merged
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,38 @@
import logging
from django.db import migrations

def update_sign_auth_assertion(apps, schema_editor):
"""
Updates the signing authority declaration statement

Previous label:
"I confirm that records evidencing each matter reported under section 11.11 (2) of the
Regulation are available on request."

New label:
"I confirm that records evidencing each matter reported under section 17 of the Low Carbon
Fuel (General) Regulation are available on request."
"""
signing_authority_assertion = apps.get_model('api', 'SigningAuthorityAssertion')
try:
assertion = signing_authority_assertion.objects.get(id=1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we certain that id=1 is the correct assertion here? Is there a more consistent way to get the correct assertion across environments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, Alex! Using record IDs isn't a good practice because they can change in different environments. I was unable to find any unique names for the SigningAuthorityAssertion records in the code. Would you like me to add a unique name to each record? Then I could update this migration file to use these unique names instead of the automatically created IDs.

Another solution would be to find the records by their text (description). This isn't ideal, but it is still better than updating the records by their IDs.

Copy link
Collaborator

@AlexZorkin AlexZorkin Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah a bit tricky if there isn't already a different unique field, and selecting by long form text isn't ideal. Let's just continue with your id solution but please confirm that each environment uses those ids for our target records.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that all the environments (test, development, and production) use the same IDs for our target records.

assertion.description = (
'I confirm that records evidencing each matter reported under section 17 '
'of the Low Carbon Fuel (General) Regulation are available on request.'
)
assertion.save()
except signing_authority_assertion.DoesNotExist:
logging.warning('Failed to update SigningAuthorityAssertion: No entry found with id "1".')
raise

class Migration(migrations.Migration):
"""
Attaches the update function to the migration operations
"""
dependencies = [
('api', '0011_report_history_grouping'),
]

operations = [
migrations.RunPython(update_sign_auth_assertion),
]
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CreditTransferFormDetails extends Component {
onChange={this.props.handleInputChange}
required="required"
>
<option key="0" value="" default>Select a Fuel Supplier</option>
<option key="0" value="" default>Select an Organization</option>
{this.props.fuelSuppliers &&
this.props.fuelSuppliers.map(organization => (
this.props.fields.initiator.id !== organization.id &&
Expand Down