-
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.
* feat: add datetime when ahjo has downloaded a file * feat: send any new records to ahjo before decision * feat: quarter hourly cron job to send new records * fix: use update_or_create for pdf_summary * feat: send only the application pdf on update * chore: dump into json data only once * fix: conflicting migration * fix: use types and titles for decision in payload * chore: newline in quarter_hourly_job * feat: reformat record titles for AHJO * fix: call with correct parameters * chore: add missing migration file * fix: comparison with in instead of ==
- Loading branch information
Showing
16 changed files
with
439 additions
and
50 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
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
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
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
Empty file.
11 changes: 11 additions & 0 deletions
11
backend/benefit/applications/jobs/quarter_hourly/quarter_hourly_ahjo_job.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,11 @@ | ||
from django.conf import settings | ||
from django.core.management import call_command | ||
from django_extensions.management.jobs import QuarterHourlyJob | ||
|
||
|
||
class Job(QuarterHourlyJob): | ||
help = "Quarter hourly Ahjo integration jobs are executed here." | ||
|
||
def execute(self): | ||
if settings.ENABLE_AHJO_AUTOMATION: | ||
call_command("send_new_records") |
39 changes: 39 additions & 0 deletions
39
backend/benefit/applications/management/commands/send_new_records.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,39 @@ | ||
import logging | ||
import time | ||
|
||
from django.core.exceptions import ImproperlyConfigured | ||
from django.core.management.base import BaseCommand | ||
|
||
from applications.services.ahjo_authentication import AhjoToken | ||
from applications.services.ahjo_integration import ( | ||
get_token, | ||
send_new_attachment_records_to_ahjo, | ||
) | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Send new records to Ahjo" | ||
|
||
def handle(self, *args, **options): | ||
try: | ||
ahjo_auth_token = get_token() | ||
except ImproperlyConfigured as e: | ||
LOGGER.error(f"Failed to get auth token from Ahjo: {e}") | ||
return | ||
|
||
self.run_requests(ahjo_auth_token) | ||
|
||
def run_requests(self, ahjo_auth_token: AhjoToken): | ||
start_time = time.time() | ||
|
||
self.stdout.write("Sending new records to Ahjo") | ||
|
||
responses = send_new_attachment_records_to_ahjo(ahjo_auth_token) | ||
self.stdout.write(f"Sent records for {len(responses)} applications to Ahjo") | ||
end_time = time.time() | ||
elapsed_time = end_time - start_time | ||
self.stdout.write( | ||
f"Done! Sending new records for {len(responses)} applications {elapsed_time} seconds to run." | ||
) |
23 changes: 23 additions & 0 deletions
23
backend/benefit/applications/migrations/0065_downloaded_by_ahjo_timestamp.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,23 @@ | ||
# Generated by Django 3.2.23 on 2024-04-12 10:52 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('applications', '0064_decision_proposal_drafts'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='attachment', | ||
name='downloaded_by_ahjo', | ||
field=models.DateTimeField(blank=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='historicalattachment', | ||
name='downloaded_by_ahjo', | ||
field=models.DateTimeField(blank=True, null=True), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
backend/benefit/applications/migrations/0066_alter_ahjostatus_status.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,18 @@ | ||
# Generated by Django 3.2.23 on 2024-04-17 13:44 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('applications', '0065_downloaded_by_ahjo_timestamp'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='ahjostatus', | ||
name='status', | ||
field=models.CharField(choices=[('submitted_but_not_sent_to_ahjo', 'Submitted but not sent to AHJO'), ('request_to_open_case_sent', 'Request to open the case sent to AHJO'), ('case_opened', 'Case opened in AHJO'), ('update_request_sent', 'Update request sent'), ('update_request_received', 'Update request received'), ('decision_proposal_sent', 'Decision proposal sent'), ('decision_proposal_accepted', 'Decision proposal accepted'), ('decision_proposal_rejected', 'Decision proposal rejected'), ('delete_request_sent', 'Delete request sent'), ('delete_request_received', 'Delete request received'), ('new_record_request_sent', 'New record request sent'), ('new_record_received', 'New record received by Ahjo')], default='submitted_but_not_sent_to_ahjo', max_length=64, verbose_name='status'), | ||
), | ||
] |
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
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
Oops, something went wrong.