mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Merge branch 'master' into remove-initial-update-sms-sender
This commit is contained in:
42
migrations/versions/0133_set_services_sms_prefix.py
Normal file
42
migrations/versions/0133_set_services_sms_prefix.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import os
|
||||
from app import config
|
||||
"""
|
||||
|
||||
Revision ID: 0133_set_services_sms_prefix
|
||||
Revises: 0132_add_sms_prefix_setting
|
||||
Create Date: 2017-11-03 15:55:35.657488
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0133_set_services_sms_prefix'
|
||||
down_revision = '0132_add_sms_prefix_setting'
|
||||
|
||||
|
||||
config = config.configs[os.environ['NOTIFY_ENVIRONMENT']]
|
||||
default_sms_sender = config.FROM_NUMBER
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
update services set prefix_sms = True
|
||||
where id in (
|
||||
select service_id from service_sms_senders
|
||||
where is_default = True and sms_sender = '{}'
|
||||
)
|
||||
""".format(default_sms_sender))
|
||||
op.execute("""
|
||||
update services set prefix_sms = False
|
||||
where id in (
|
||||
select service_id from service_sms_senders
|
||||
where is_default = True and sms_sender != '{}'
|
||||
)
|
||||
""".format(default_sms_sender))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("""
|
||||
UPDATE services set prefix_sms = null
|
||||
""")
|
||||
71
migrations/versions/0134_add_email_2fa_template_.py
Normal file
71
migrations/versions/0134_add_email_2fa_template_.py
Normal file
@@ -0,0 +1,71 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0134_add_email_2fa_template
|
||||
Revises: 0133_set_services_sms_prefix
|
||||
Create Date: 2017-11-03 13:52:59.715203
|
||||
|
||||
"""
|
||||
from datetime import datetime
|
||||
|
||||
from alembic import op
|
||||
from flask import current_app
|
||||
|
||||
|
||||
revision = '0134_add_email_2fa_template'
|
||||
down_revision = '0133_set_services_sms_prefix'
|
||||
|
||||
template_id = '299726d2-dba6-42b8-8209-30e1d66ea164'
|
||||
|
||||
|
||||
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 ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}')
|
||||
"""
|
||||
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 ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}')
|
||||
"""
|
||||
|
||||
template_content = '\n'.join([
|
||||
'Hi ((name)),',
|
||||
'',
|
||||
'To sign in to GOV.UK Notify please open this link:',
|
||||
'((url))',
|
||||
])
|
||||
|
||||
template_name = "Notify email verify code"
|
||||
template_subject = 'Sign in to GOV.UK Notify'
|
||||
|
||||
op.execute(
|
||||
template_history_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
)
|
||||
|
||||
op.execute(
|
||||
template_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 2054e740350f
|
||||
Revises: 0132_add_sms_prefix_setting
|
||||
Revision ID: 0135_sms_sender_nullable
|
||||
Revises: 0134_add_email_2fa_template
|
||||
Create Date: 2017-11-06 15:44:59.471977
|
||||
|
||||
"""
|
||||
@@ -9,8 +9,8 @@ from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0133_sms_sender_nullable'
|
||||
down_revision = '0132_add_sms_prefix_setting'
|
||||
revision = '0135_sms_sender_nullable'
|
||||
down_revision = '0134_add_email_2fa_template'
|
||||
|
||||
|
||||
def upgrade():
|
||||
Reference in New Issue
Block a user