Allow the admin app to send one-off letters

This commit modifies the code paths the admin app uses to send one off
emails and text messages to also accept letters.

This mostly worked already, the two changes were:
- making sure that one-off letters are processed by the correct task,
  from the correct queue
- one-off letters sent from a service in research mode don’t get put on
  a queue and go straight to `delivered` (because we don’t want to send
  them for real)
This commit is contained in:
Chris Hill-Scott
2018-10-31 14:30:46 +00:00
parent 87017fc3d1
commit 674cdbd265
4 changed files with 65 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ from notifications_utils.recipients import (
from app import redis_store
from app.celery import provider_tasks
from app.celery.letters_pdf_tasks import create_letters_pdf
from app.config import QueueNames
from app.models import (
@@ -149,6 +150,10 @@ def send_notification_to_queue(notification, research_mode, queue=None):
if not queue:
queue = QueueNames.SEND_EMAIL
deliver_task = provider_tasks.deliver_email
if notification.notification_type == LETTER_TYPE:
if not queue:
queue = QueueNames.CREATE_LETTERS_PDF
deliver_task = create_letters_pdf
try:
deliver_task.apply_async([str(notification.id)], queue=queue)