-
Notifications
You must be signed in to change notification settings - Fork 40
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
AlexZorkin
merged 2 commits into
main-release-jan-2024
from
fix/hamed-transfer-act-label-changes-2690
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
backend/api/migrations/0012_update_signing_authority_declaration_statement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
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), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are we certain that id=1 is the correct assertion here? Is there a more consistent way to get the correct assertion across environments?
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.
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.
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.
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.
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 can confirm that all the environments (test, development, and production) use the same IDs for our target records.