Files
notifications-api/migrations/versions/0082_add_golive_template.py
Anastasia Gradova e293f7e3f5 Updated all usage of datetime.utcnow() to
app.utils utc_now() function. Added new endpoint
/service/{{service_id}}/notifications/month
2024-06-14 16:01:04 -06:00

118 lines
4.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""empty message
Revision ID: 0082_add_go_live_template
Revises: 0081_noti_status_as_enum
Create Date: 2017-05-10 16:06:04.070874
"""
# revision identifiers, used by Alembic.
from datetime import datetime
import sqlalchemy as sa
from alembic import op
from flask import current_app
from sqlalchemy import text
from app.utils import utc_now
revision = "0082_add_go_live_template"
down_revision = "0081_noti_status_as_enum"
template_id = "618185c6-3636-49cd-b7d2-6f6f5eb3bdde"
def upgrade():
template_insert = """
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id, :subject, :user_id, 1, :process_type)
"""
template_history_insert = """
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id, :subject, :user_id, 1, :process_type)
"""
template_content = """Hi ((name)),
((service name)) is now live on GOV.UK Notify.
You can send up to ((message limit)) messages per day.
As a live service, youll need to know who to contact if you have a question, or something goes wrong.
^To get email updates whenever there is a problem with Notify, its important that you subscribe to our system status page:
https://status.notifications.service.gov.uk
If our system status page shows a problem, then weve been alerted and are working on it you dont need to contact us.
#Problems or questions during office hours
Our office hours are 9.30am to 5.30pm, Monday to Friday.
To report a problem or ask a question, go to the support page:
https://www.notifications.service.gov.uk/support
Well reply within 30 minutes whether youre reporting a problem or just asking a question.
The team are also available to answer questions on the cross-government Slack channel:
https://ukgovernmentdigital.slack.com/messages/govuk-notify
#Problems or questions out of hours
We offer out of hours support for emergencies.
Its only an emergency if:
* no one in your team can log in
* a technical difficulties error appears when you try to upload a file
* a 500 response code appears when you try to send messages using the API
If you have one of these emergencies, email details to:
testsender@dispostable.com
^Only use this email address for out of hours emergencies. Dont share this address with people outside of your team.
Well get back to you within 30 minutes and give you hourly updates until the problems fixed.
For non-emergency problems or questions, use our support page and well reply in office hours:
https://www.notifications.service.gov.uk/support
#Escalation for emergency problems
If we havent acknowledged an emergency problem youve reported within 30 minutes and you need to know whats happening, you can escalate to:
or
Thanks
GOV.UK Notify team
"""
template_name = "Automated \"You''re now live\" message"
template_subject = "((service name)) is now live on GOV.UK Notify"
input_params = {
"template_id": template_id,
"template_name": template_name,
"template_type": "email",
"time_now": utc_now(),
"content": template_content,
"notify_service_id": current_app.config["NOTIFY_SERVICE_ID"],
"subject": template_subject,
"user_id": current_app.config["NOTIFY_USER_ID"],
"process_type": "normal",
}
conn = op.get_bind()
conn.execute(text(template_history_insert), input_params)
conn.execute(text(template_insert), input_params)
def downgrade():
input_params = {"template_id": template_id}
conn = op.get_bind()
conn.execute(
text("DELETE FROM notifications WHERE template_id = '{}'"), input_params
)
conn.execute(
text("DELETE FROM notification_history WHERE template_id = '{}'"), input_params
)
conn.execute(text("DELETE FROM templates_history WHERE id = '{}'"), input_params)
conn.execute(text("DELETE FROM templates WHERE id = '{}'"), input_params)