Skip to content

Commit

Permalink
Allow sending of OT creation/activation emails manually (#4706)
Browse files Browse the repository at this point in the history
* Add manual route for sending OT emails

* fix reference to stage ID

---------

Co-authored-by: DanielRyanSmith <[email protected]>
  • Loading branch information
DanielRyanSmith and DanielRyanSmith authored Jan 21, 2025
1 parent 1e4e528 commit d129229
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internals/maintenance_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,3 +801,39 @@ 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, **kwargs):
self.require_cron_header()

stage_id = kwargs.get('stage_id')
stage: Stage|None = Stage.get_by_id(stage_id)
if not stage:
return 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, **kwargs):
self.require_cron_header()

stage_id = kwargs.get('stage_id')
stage: Stage|None = Stage.get_by_id(stage_id)
if not stage:
return 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 d129229

Please sign in to comment.