-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a migration command to create needed proposal drafts (#2931)
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
backend/benefit/applications/management/commands/create-proposal-drafts.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 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from applications.models import AhjoDecisionProposalDraft, Application | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Create decision proposal drafts for older than 2024-04-16 applications" | ||
|
||
def handle(self, *args, **options): | ||
applications = Application.objects.all() | ||
total_created = 0 | ||
for application in applications: | ||
try: | ||
application.decision_proposal_draft | ||
except: # noqa | ||
AhjoDecisionProposalDraft.objects.create( | ||
application=application, | ||
) | ||
total_created += 1 | ||
self.stdout.write(f"Created {total_created} decision proposal drafts") |