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

2024-12-21 | MAIN --> PROD | DEV (31b9a6e) --> STAGING #4560

Merged
merged 2 commits into from
Dec 21, 2024
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
7 changes: 0 additions & 7 deletions backend/.profile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ source tools/api_teardown.sh
source tools/migrate_app_tables.sh
source tools/api_standup.sh
source tools/run_collectstatic.sh
source tools/seed_cog_baseline.sh
source tools/materialized_views.sh
source tools/create_staffusers.sh

Expand Down Expand Up @@ -48,12 +47,6 @@ if [[ "$CF_INSTANCE_INDEX" == 0 ]]; then
# run_collectstatic
# gonogo "run_collectstatic"

#####
# SEED COG/OVER TABLES
# Setup tables for cog/over assignments
seed_cog_baseline
gonogo "seed_cog_baseline"

# materialized_views
# gonogo "materialized_views"

Expand Down
78 changes: 77 additions & 1 deletion backend/audit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
UeiValidationWaiver,
)
from audit.models.models import STATUS
from audit.models.viewflow import sac_transition
from audit.models.viewflow import (
sac_flag_for_removal,
sac_revert_from_flagged_for_removal,
sac_transition,
)
from audit.validators import (
validate_auditee_certification_json,
validate_auditor_certification_json,
Expand All @@ -24,6 +28,76 @@
logger = logging.getLogger(__name__)


@admin.action(description="Revert selected report(s) to In Progress")
def revert_to_in_progress(modeladmin, request, queryset):
successful_reverts = []
errors = []

for sac in queryset:
if sac.submission_status == STATUS.FLAGGED_FOR_REMOVAL:
try:
sac_revert_from_flagged_for_removal(sac, request.user)
sac.save()
successful_reverts.append(sac.report_id)
except Exception as e:
modeladmin.message_user(
request,
f"Error reverting {sac.report_id}: {str(e)}",
level=messages.ERROR,
)
errors.append(sac.report_id)
else:
modeladmin.message_user(
request,
f"Report {sac.report_id} is not flagged for removal.",
level=messages.WARNING,
)
errors.append(sac.report_id)

if successful_reverts:
modeladmin.message_user(
request,
f"Successfully reverted report(s) ({', '.join(successful_reverts)}) back to In Progress.",
level=messages.SUCCESS,
)

if errors:
modeladmin.message_user(
request,
f"Unable to revert report(s) ({', '.join(errors)}) back to In Progress.",
level=messages.ERROR,
)


@admin.action(description="Flag selected report(s) for removal")
def flag_for_removal(modeladmin, request, queryset):

flagged = []
already_flagged = []

for sac in queryset:
if sac.submission_status != STATUS.FLAGGED_FOR_REMOVAL:
sac_flag_for_removal(sac, request.user)
sac.save()
flagged.append(sac.report_id)
else:
already_flagged.append(sac.report_id)

if flagged:
modeladmin.message_user(
request,
f"Successfully flagged report(s) ({', '.join(flagged)}) for removal.",
level=messages.SUCCESS,
)

if already_flagged:
modeladmin.message_user(
request,
f"Report(s) ({', '.join(already_flagged)}) were already flagged.",
level=messages.WARNING,
)


class SACAdmin(admin.ModelAdmin):
"""
Support for read-only staff access, and control of what fields are present and
Expand All @@ -41,6 +115,7 @@ def has_view_permission(self, request, obj=None):
"report_id",
"cognizant_agency",
"oversight_agency",
"submission_status",
)
list_filter = [
"cognizant_agency",
Expand All @@ -50,6 +125,7 @@ def has_view_permission(self, request, obj=None):
]
readonly_fields = ("submitted_by",)
search_fields = ("general_information__auditee_uei", "report_id")
actions = [revert_to_in_progress, flag_for_removal]


class AccessAdmin(admin.ModelAdmin):
Expand Down
42 changes: 0 additions & 42 deletions backend/audit/management/commands/README.md

This file was deleted.

82 changes: 0 additions & 82 deletions backend/audit/management/commands/csv_to_pg.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Generated by Django 5.1.2 on 2024-12-17 16:56

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("audit", "0014_alter_sacvalidationwaiver_waiver_types"),
]

operations = [
migrations.AlterField(
model_name="singleauditchecklist",
name="submission_status",
field=models.CharField(
choices=[
("in_progress", "In Progress"),
("flagged_for_removal", "Flagged for Removal"),
("ready_for_certification", "Ready for Certification"),
("auditor_certified", "Auditor Certified"),
("auditee_certified", "Auditee Certified"),
("certified", "Certified"),
("submitted", "Submitted"),
("disseminated", "Disseminated"),
],
default="in_progress",
),
),
migrations.AlterField(
model_name="singleauditchecklist",
name="transition_name",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(
choices=[
("in_progress", "In Progress"),
("flagged_for_removal", "Flagged for Removal"),
("ready_for_certification", "Ready for Certification"),
("auditor_certified", "Auditor Certified"),
("auditee_certified", "Auditee Certified"),
("certified", "Certified"),
("submitted", "Submitted"),
("disseminated", "Disseminated"),
],
max_length=40,
),
blank=True,
default=list,
null=True,
size=None,
),
),
migrations.AlterField(
model_name="submissionevent",
name="event",
field=models.CharField(
choices=[
("access-granted", "Access granted"),
("additional-eins-updated", "Additional EINs updated"),
("additional-eins-deleted", "Additional EINs deleted"),
("additional-ueis-updated", "Additional UEIs updated"),
("additional-ueis-deleted", "Additional UEIs deleted"),
("audit-information-updated", "Audit information updated"),
("audit-report-pdf-updated", "Audit report PDF updated"),
(
"auditee-certification-completed",
"Auditee certification completed",
),
(
"auditor-certification-completed",
"Auditor certification completed",
),
(
"corrective-action-plan-updated",
"Corrective action plan updated",
),
(
"corrective-action-plan-deleted",
"Corrective action plan deleted",
),
("created", "Created"),
("federal-awards-updated", "Federal awards updated"),
(
"federal-awards-audit-findings-updated",
"Federal awards audit findings updated",
),
(
"federal-awards-audit-findings-deleted",
"Federal awards audit findings deleted",
),
(
"federal-awards-audit-findings-text-updated",
"Federal awards audit findings text updated",
),
(
"federal-awards-audit-findings-text-deleted",
"Federal awards audit findings text deleted",
),
(
"findings-uniform-guidance-updated",
"Findings uniform guidance updated",
),
(
"findings-uniform-guidance-deleted",
"Findings uniform guidance deleted",
),
("general-information-updated", "General information updated"),
("locked-for-certification", "Locked for certification"),
("unlocked-after-certification", "Unlocked after certification"),
("notes-to-sefa-updated", "Notes to SEFA updated"),
("secondary-auditors-updated", "Secondary auditors updated"),
("secondary-auditors-deleted", "Secondary auditors deleted"),
("submitted", "Submitted to the FAC for processing"),
("disseminated", "Copied to dissemination tables"),
("tribal-consent-updated", "Tribal audit consent updated"),
(
"flagged-submission-for-removal",
"Flagged submission for removal",
),
("cancel-removal-flag", "Cancel removal flag"),
]
),
),
]
2 changes: 2 additions & 0 deletions backend/audit/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class STATUS:
CERTIFIED = "certified"
SUBMITTED = "submitted"
DISSEMINATED = "disseminated"
FLAGGED_FOR_REMOVAL = "flagged_for_removal"


class SingleAuditChecklist(models.Model, GeneralInformationMixin): # type: ignore
Expand Down Expand Up @@ -303,6 +304,7 @@ def get_statuses(self) -> type[STATUS]:
# Constants:
STATUS_CHOICES = (
(STATUS.IN_PROGRESS, "In Progress"),
(STATUS.FLAGGED_FOR_REMOVAL, "Flagged for Removal"),
(STATUS.READY_FOR_CERTIFICATION, "Ready for Certification"),
(STATUS.AUDITOR_CERTIFIED, "Auditor Certified"),
(STATUS.AUDITEE_CERTIFIED, "Auditee Certified"),
Expand Down
Loading
Loading