Skip to content

Commit

Permalink
Add manual route for sending OT emails
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRyanSmith committed Jan 15, 2025
1 parent f6c1a85 commit 9c3d475
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions internals/maintenance_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,3 +801,37 @@ def calc_needs_work_started_on(

return max(v.set_on for v in votes
if v.state == Vote.NEEDS_WORK)


class SendManualOTCreatedEmail(FlaskHandler):
"""Manually send an email to origin trial contacts that an origin trial has
been created but not yet activated."""
def get_template_data(self):
self.require_cron_header()

stage_id = self.get_param('stage_id')
stage: Stage|None = Stage.get_by_id(stage_id)
if not stage:
self.abort(400, f'Stage {stage_id} not found')

cloud_tasks_helpers.enqueue_task(
'/tasks/email-ot-creation-processed',
{'stage': converters.stage_to_json_dict(stage)})
return 'Email task enqueued.'


class SendManualOTActivatedEmail(FlaskHandler):
"""Manually send an email to origin trial contacts that an origin trial has
been created and also activated."""
def get_template_data(self):
self.require_cron_header()

stage_id = self.get_param('stage_id')
stage: Stage|None = Stage.get_by_id(stage_id)
if not stage:
self.abort(400, f'Stage {stage_id} not found')

cloud_tasks_helpers.enqueue_task(
'/tasks/email-ot-activated',
{'stage': converters.stage_to_json_dict(stage)})
return 'Email task enqueued.'
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ class Route:
maintenance_scripts.BackfillShippingYear),
Route('/scripts/backfill_gate_dates',
maintenance_scripts.BackfillGateDates),
Route('/scripts/send_ot_creation_email/<int:stage_id>',
maintenance_scripts.SendManualOTCreatedEmail),
Route('/scripts/send_ot_activation_email/<int:stage_id>',
maintenance_scripts.SendManualOTActivatedEmail),
]

dev_routes: list[Route] = []
Expand Down

0 comments on commit 9c3d475

Please sign in to comment.