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

Add dissemination regeneration command #2420

Merged
merged 2 commits into from
Oct 5, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import logging
from django.core.management.base import BaseCommand
from dissemination.models import (
AdditionalEin,
AdditionalUei,
CapText,
FederalAward,
Finding,
FindingText,
General,
Note,
Passthrough,
SecondaryAuditor,
)
from audit.models import SingleAuditChecklist

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = """
Deletes everything in `dissemination` tables and
regenerates them from data in the intake tables.
"""

dissemination_models = [
AdditionalEin,
AdditionalUei,
CapText,
FederalAward,
Finding,
FindingText,
General,
Note,
Passthrough,
SecondaryAuditor,
]

def delete_everything_in_dissemination_model(self, model):
model.objects.all().delete()

def handle(self, *args, **kwargs):
logger.info("Re-running dissemination for all records.")

# Begin by deleting all of the dissemination table contents.
for model in Command.dissemination_models:
logger.info(f"Deleting {model.__name__}")
self.delete_everything_in_dissemination_model(model)

# Now, re-run dissemination for everything
# in the intake tables.
for sac in SingleAuditChecklist.objects.all():
if sac.submission_status == SingleAuditChecklist.STATUS.DISSEMINATED:
logger.info(f"Disseminating {sac.report_id}")
sac.disseminate()