2020-09-15 14:25:09 +01:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
Revision ID: 0330_broadcast_invite_email
|
|
|
|
|
|
Revises: 0329_purge_broadcast_data
|
|
|
|
|
|
Create Date: 2020-09-15 14:17:01.963181
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
from alembic import op
|
2023-07-17 15:04:22 -07:00
|
|
|
|
from sqlalchemy import text
|
2020-09-15 14:25:09 +01:00
|
|
|
|
|
2024-06-14 16:01:04 -06:00
|
|
|
|
from app.utils import utc_now
|
|
|
|
|
|
|
2023-08-29 14:54:30 -07:00
|
|
|
|
revision = "0330_broadcast_invite_email"
|
|
|
|
|
|
down_revision = "0329_purge_broadcast_data"
|
2020-09-15 14:25:09 +01:00
|
|
|
|
|
2023-08-29 14:54:30 -07:00
|
|
|
|
user_id = "6af522d0-2915-4e52-83a3-3690455a5fe6"
|
|
|
|
|
|
service_id = "d6aa2c68-a2d9-4437-ab19-3ae8eb202553"
|
|
|
|
|
|
template_id = "46152f7c-6901-41d5-8590-a5624d0d4359"
|
2020-09-15 14:25:09 +01:00
|
|
|
|
|
2023-08-29 14:54:30 -07:00
|
|
|
|
broadcast_invitation_template_name = "Notify broadcast invitation email"
|
|
|
|
|
|
broadcast_invitation_subject = (
|
|
|
|
|
|
"((user_name)) has invited you to join ((service_name)) on GOV.UK Notify"
|
|
|
|
|
|
)
|
2020-09-15 14:25:09 +01:00
|
|
|
|
broadcast_invitation_content = """((user_name)) has invited you to join ((service_name)) on GOV.UK Notify.
|
|
|
|
|
|
|
|
|
|
|
|
In an emergency, use Notify to broadcast an alert, warning the public about an imminent risk to life.
|
|
|
|
|
|
|
|
|
|
|
|
Use this link to join the team:
|
|
|
|
|
|
((url))
|
|
|
|
|
|
|
|
|
|
|
|
This invitation will stop working at midnight tomorrow. This is to keep ((service_name)) secure.
|
|
|
|
|
|
|
|
|
|
|
|
Thanks
|
|
|
|
|
|
|
|
|
|
|
|
GOV.UK Notify team
|
|
|
|
|
|
https://www.gov.uk/notify
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade():
|
2023-07-17 15:04:22 -07:00
|
|
|
|
insert_query_t = """
|
|
|
|
|
|
INSERT INTO templates
|
2020-09-15 14:25:09 +01:00
|
|
|
|
(id, name, template_type, created_at, content, archived, service_id,
|
|
|
|
|
|
subject, created_by_id, version, process_type, hidden)
|
|
|
|
|
|
VALUES
|
2023-07-17 15:04:22 -07:00
|
|
|
|
(:template_id, :template_name, 'email', :time_now, :content, False, :service_id, :subject, :user_id, 1, 'normal', False)
|
2020-09-15 14:25:09 +01:00
|
|
|
|
"""
|
|
|
|
|
|
|
2023-07-17 15:04:22 -07:00
|
|
|
|
insert_query_th = """
|
|
|
|
|
|
INSERT INTO templates_history
|
|
|
|
|
|
(id, name, template_type, created_at, content, archived, service_id,
|
|
|
|
|
|
subject, created_by_id, version, process_type, hidden)
|
|
|
|
|
|
VALUES
|
|
|
|
|
|
(:template_id, :template_name, 'email', :time_now, :content, False, :service_id, :subject, :user_id, 1, 'normal', False)
|
|
|
|
|
|
"""
|
|
|
|
|
|
conn = op.get_bind()
|
|
|
|
|
|
|
|
|
|
|
|
input_params = {
|
|
|
|
|
|
"template_id": template_id,
|
|
|
|
|
|
"template_name": broadcast_invitation_template_name,
|
2024-06-14 16:01:04 -06:00
|
|
|
|
"time_now": utc_now(),
|
2023-07-17 15:04:22 -07:00
|
|
|
|
"content": broadcast_invitation_content,
|
|
|
|
|
|
"service_id": service_id,
|
|
|
|
|
|
"subject": broadcast_invitation_subject,
|
2023-08-29 14:54:30 -07:00
|
|
|
|
"user_id": user_id,
|
2023-07-17 15:04:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
conn.execute(text(insert_query_t), input_params)
|
|
|
|
|
|
conn.execute(text(insert_query_th), input_params)
|
2020-09-15 14:25:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade():
|
2023-07-17 15:04:22 -07:00
|
|
|
|
conn = op.get_bind()
|
2023-08-29 14:54:30 -07:00
|
|
|
|
input_params = {"template_id": template_id}
|
2023-07-17 15:04:22 -07:00
|
|
|
|
conn.execute(text("delete from templates where id = :template_id"), input_params)
|
2023-08-29 14:54:30 -07:00
|
|
|
|
conn.execute(
|
|
|
|
|
|
text("delete from templates_history where id = :template_id"), input_params
|
|
|
|
|
|
)
|