-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logic to fix auditee name and title
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
33 changes: 33 additions & 0 deletions
33
backend/audit/data_curation/fix_census_sac_auditee_certification.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,33 @@ | ||
import logging | ||
|
||
|
||
from django.conf import settings | ||
|
||
from census_historical_migration.transforms.xform_string_to_string import ( | ||
string_to_string, | ||
) | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def update_census_sac_auditee_name(sac, audit_header): | ||
"""Fix the erroneous auditee_name and auditee_title in the auditee_certification of a SAC object.""" | ||
auditee_certification = sac.auditee_certification | ||
auditee_signature = auditee_certification.get("auditee_signature", {}) | ||
|
||
# Get auditee name and title from audit_header or default to settings.GSA_MIGRATION | ||
auditee_name = string_to_string( | ||
getattr(audit_header, "AUDITEECERTIFYNAME", settings.GSA_MIGRATION) | ||
) | ||
auditee_title = string_to_string( | ||
getattr(audit_header, "AUDITEECERTIFYTITLE", settings.GSA_MIGRATION) | ||
) | ||
# Update auditee_signature with new auditee_name and auditee_title | ||
auditee_signature["auditee_name"] = auditee_name | ||
auditee_signature["auditee_title"] = auditee_title | ||
# Update auditee_signature in auditee_certification | ||
auditee_certification["auditee_signature"] = auditee_signature | ||
|
||
sac.auditee_certification = auditee_certification | ||
sac.save() |