From 343a8e43e7cfb682c32bcfcdf7a8f0f98bba35a4 Mon Sep 17 00:00:00 2001 From: Sudha Kumar <135276194+gsa-suk@users.noreply.github.com> Date: Mon, 11 Dec 2023 08:59:19 -0800 Subject: [PATCH 1/3] Sk/2841 record migration status (#2956) * Record migration status * Fixed format * Recording migration status --- .../historic_data_loader.py | 17 +++++++++++++++++ .../commands/historic_data_migrator.py | 11 ++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/backend/census_historical_migration/historic_data_loader.py b/backend/census_historical_migration/historic_data_loader.py index 283c2693e6..015cb30e05 100644 --- a/backend/census_historical_migration/historic_data_loader.py +++ b/backend/census_historical_migration/historic_data_loader.py @@ -1,8 +1,10 @@ from .models import ELECAUDITHEADER as AuditHeader +from .models import ReportMigrationStatus from .workbooklib.end_to_end_core import run_end_to_end from django.contrib.auth import get_user_model from django.core.paginator import Paginator +from django.utils import timezone User = get_user_model() @@ -34,6 +36,12 @@ def load_historic_data_for_year(audit_year, page_size, pages): result_log[(audit_year, submission.DBKEY)] = result total_count += 1 + migration_status = "SUCCESS" + if len(result["errors"]) > 0: + migration_status = "FAILURE" + + record_migration_status(audit_year, submission.DBKEY, migration_status) + if len(result["errors"]) > 0: error_count += 1 if total_count % 5 == 0: @@ -65,3 +73,12 @@ def create_or_get_user(): user.save() return user + + +def record_migration_status(audit_year, dbkey, status): + ReportMigrationStatus( + audit_year=audit_year, + dbkey=dbkey, + run_datetime=timezone.now(), + migration_status=status, + ).save() diff --git a/backend/census_historical_migration/management/commands/historic_data_migrator.py b/backend/census_historical_migration/management/commands/historic_data_migrator.py index 0f300654b4..e31ba14125 100644 --- a/backend/census_historical_migration/management/commands/historic_data_migrator.py +++ b/backend/census_historical_migration/management/commands/historic_data_migrator.py @@ -7,7 +7,10 @@ from census_historical_migration.workbooklib.excel_creation_utils import ( get_audit_header, ) -from census_historical_migration.historic_data_loader import create_or_get_user +from census_historical_migration.historic_data_loader import ( + create_or_get_user, + record_migration_status, +) from census_historical_migration.workbooklib.end_to_end_core import run_end_to_end from django.conf import settings @@ -52,6 +55,12 @@ def initiate_migration(self, dbkeys_str, years_str): run_end_to_end(user, audit_header, result) logger.info(result) + migration_status = "SUCCESS" + if len(result["errors"]) > 0: + migration_status = "FAILURE" + + record_migration_status(year, dbkey, migration_status) + def handle(self, *args, **options): dbkeys_str = options["dbkeys"] years_str = options["years"] From 520ae5517e93616e68c8d7c46d81df104ae004ad Mon Sep 17 00:00:00 2001 From: Tadhg O'Higgins <2626258+tadhg-ohiggins@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:44:31 -0800 Subject: [PATCH 2/3] Add quick explainer for Django admin operations. (#2970) --- docs/django-admin-operations.md | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/django-admin-operations.md diff --git a/docs/django-admin-operations.md b/docs/django-admin-operations.md new file mode 100644 index 0000000000..5aaee33726 --- /dev/null +++ b/docs/django-admin-operations.md @@ -0,0 +1,43 @@ +# Django admin operations + +This is a how-to guide for common FAC Django admin operations. + +The Django admin interface path is `/admin/`; the production instance is at [https://app.fac.gov/admin/](https://app.fac.gov/admin/). + +To use it, you must have logged into the application and have an account that has been granted access. + +If you need to grant someone read-only access to the Django admin, see [Granting `staff` access](#granting-staff-access). + +If you need to investigate why a user cannot see or access a submission, see [Looking up access information by `report_id` or email address](#looking-up-access-information-by-report_id-or-email-address). + +If you need to investigate problems with a submission unrelated to access issues, see [Looking up submission information by `report_id` or UEI](#looking-up-submission-information-by-report_id-or-uei). + +## Granting `staff` access + +You must have `superuser` access to do this. + +1. Get the email address of the account to grant `staff` access to. +2. Go to [https://app.fac.gov/admin/users/staffuser/add](https://app.fac.gov/admin/users/staffuser/add), enter the email address, and click on the **SAVE** button. +3. Verify that the email address is in the list of users at [https://app.fac.gov/admin/users/staffuser/]([https://app.fac.gov/admin/users/staffuser/). +4. Confirm with the user in question that they can log into the Django admin site. + +## Looking up access information by `report_id` or email address + +You must have `staff` or `superuser` access to do this. + +1. Get the `report_id` of the submission or the email address in question. +2. Go to [https://fac-dev.app.cloud.gov/admin/audit/access/](https://fac-dev.app.cloud.gov/admin/audit/access/). +3. Enter the `report_id` or email address into the search field at the top of the page and hit enter. +4. You should now see only the list of `Access` entries associated with that `report_id` or email address. +5. The roles and email addresses are displayed here and are usually all that’s required. +6. If necessary, click on any of the entries in the **SAC** column in order to find more information about that `Access`. + +## Looking up submission information by `report_id` or UEI + +You must have `staff` or `superuser` access to do this. + +1. Get the `report_id` or UEI in question. +2. Go to [https://fac-dev.app.cloud.gov/admin/audit/singleauditchecklist/](https://fac-dev.app.cloud.gov/admin/audit/singleauditchecklist/). +3. Enter the `report_id` or UEI into the search field at the top of the page and hit enter. +4. You should now see only the list of `SingleAuditChecklist` entries associated with that `report_id` or UEI. +5. To see more information about a particular `SingleAuditChecklist`, click the number in the **ID** column. From 03c599720c55faa9350b25b7ad0dc9a6f58bdb35 Mon Sep 17 00:00:00 2001 From: Tadhg O'Higgins <2626258+tadhg-ohiggins@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:14:14 -0800 Subject: [PATCH 3/3] URL corrections for Django Admin howto. (#2972) --- docs/django-admin-operations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/django-admin-operations.md b/docs/django-admin-operations.md index 5aaee33726..5a618c345e 100644 --- a/docs/django-admin-operations.md +++ b/docs/django-admin-operations.md @@ -26,7 +26,7 @@ You must have `superuser` access to do this. You must have `staff` or `superuser` access to do this. 1. Get the `report_id` of the submission or the email address in question. -2. Go to [https://fac-dev.app.cloud.gov/admin/audit/access/](https://fac-dev.app.cloud.gov/admin/audit/access/). +2. Go to [https://app.fac.gov/admin/audit/access/](https://app.fac.gov/admin/audit/access/). 3. Enter the `report_id` or email address into the search field at the top of the page and hit enter. 4. You should now see only the list of `Access` entries associated with that `report_id` or email address. 5. The roles and email addresses are displayed here and are usually all that’s required. @@ -37,7 +37,7 @@ You must have `staff` or `superuser` access to do this. You must have `staff` or `superuser` access to do this. 1. Get the `report_id` or UEI in question. -2. Go to [https://fac-dev.app.cloud.gov/admin/audit/singleauditchecklist/](https://fac-dev.app.cloud.gov/admin/audit/singleauditchecklist/). +2. Go to [https://app.fac.gov/admin/audit/singleauditchecklist/](https://app.fac.gov/admin/audit/singleauditchecklist/). 3. Enter the `report_id` or UEI into the search field at the top of the page and hit enter. 4. You should now see only the list of `SingleAuditChecklist` entries associated with that `report_id` or UEI. 5. To see more information about a particular `SingleAuditChecklist`, click the number in the **ID** column.