-
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.
Merge branch 'main' into tadhg/uei-ignore-status-handle-multiple
- Loading branch information
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
backend/dissemination/management/commands/delete_and_regenerate_dissemination_from_intake.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,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() |
20 changes: 20 additions & 0 deletions
20
backend/dissemination/migrations/0004_alter_findingtext_contains_chart_or_table.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,20 @@ | ||
# Generated by Django 4.2.5 on 2023-10-05 22:49 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("dissemination", "0003_alter_general_fac_accepted_date"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="findingtext", | ||
name="contains_chart_or_table", | ||
field=models.TextField( | ||
help_text="Census mapping: FINDINGSTEXT, CHARTSTABLES", | ||
verbose_name="Indicates whether or not the text contained charts or tables that could not be entered due to formatting restrictions", | ||
), | ||
), | ||
] |
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