Skip to content

Commit

Permalink
Merge pull request #2976 from GSA-TTS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm authored Dec 12, 2023
2 parents 1acd3ce + 03c5997 commit a708979
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
17 changes: 17 additions & 0 deletions backend/census_historical_migration/historic_data_loader.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]
Expand Down
43 changes: 43 additions & 0 deletions docs/django-admin-operations.md
Original file line number Diff line number Diff line change
@@ -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://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.
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://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.

0 comments on commit a708979

Please sign in to comment.