mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 00:53:13 -04:00
Merge branch 'master' into replay-letters-in-error
This commit is contained in:
@@ -622,3 +622,47 @@ def migrate_data_to_ft_notification_status(start_date, end_date):
|
|||||||
|
|
||||||
total_updated += result.rowcount
|
total_updated += result.rowcount
|
||||||
print('Total inserted/updated records = {}'.format(total_updated))
|
print('Total inserted/updated records = {}'.format(total_updated))
|
||||||
|
|
||||||
|
|
||||||
|
@notify_command(name='bulk-invite-user-to-service')
|
||||||
|
@click.option('-f', '--file_name', required=True,
|
||||||
|
help="Full path of the file containing a list of email address for people to invite to a service")
|
||||||
|
@click.option('-s', '--service_id', required=True, help='The id of the service that the invite is for')
|
||||||
|
@click.option('-u', '--user_id', required=True, help='The id of the user that the invite is from')
|
||||||
|
@click.option('-a', '--auth_type', required=False,
|
||||||
|
help='The authentication type for the user, sms_auth or email_auth. Defaults to sms_auth if not provided')
|
||||||
|
@click.option('-p', '--permissions', required=True, help='Comma separated list of permissions.')
|
||||||
|
def bulk_invite_user_to_service(file_name, service_id, user_id, auth_type, permissions):
|
||||||
|
# permissions
|
||||||
|
# manage_users | manage_templates | manage_settings
|
||||||
|
# send messages ==> send_texts | send_emails | send_letters
|
||||||
|
# Access API keys manage_api_keys
|
||||||
|
# platform_admin
|
||||||
|
# view_activity
|
||||||
|
# "send_texts,send_emails,send_letters,view_activity"
|
||||||
|
from app.invite.rest import create_invited_user
|
||||||
|
file = open(file_name)
|
||||||
|
for email_address in file:
|
||||||
|
data = {
|
||||||
|
'service': service_id,
|
||||||
|
'email_address': email_address.strip(),
|
||||||
|
'from_user': user_id,
|
||||||
|
'permissions': permissions,
|
||||||
|
'auth_type': auth_type,
|
||||||
|
'invite_link_host': current_app.config['ADMIN_BASE_URL']
|
||||||
|
}
|
||||||
|
with current_app.test_request_context(
|
||||||
|
path='/service/{}/invite/'.format(service_id),
|
||||||
|
method='POST',
|
||||||
|
data=json.dumps(data),
|
||||||
|
headers={"Content-Type": "application/json"}
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
response = create_invited_user(service_id)
|
||||||
|
if response[1] != 201:
|
||||||
|
print("*** ERROR occurred for email address: {}".format(email_address.strip()))
|
||||||
|
print(response[0].get_data(as_text=True))
|
||||||
|
except Exception as e:
|
||||||
|
print("*** ERROR occurred for email address: {}. \n{}".format(email_address.strip(), e))
|
||||||
|
|
||||||
|
file.close()
|
||||||
|
|||||||
36
migrations/versions/0200_another_letter_org.py
Normal file
36
migrations/versions/0200_another_letter_org.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 0200_another_letter_org
|
||||||
|
Revises: 0199_another_letter_org
|
||||||
|
Create Date: 2017-06-29 12:44:16.815039
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '0200_another_letter_org'
|
||||||
|
down_revision = '0199_another_letter_org'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
|
NEW_ORGANISATIONS = [
|
||||||
|
('508', 'Ofgem'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
for numeric_id, name in NEW_ORGANISATIONS:
|
||||||
|
op.execute("""
|
||||||
|
INSERT
|
||||||
|
INTO dvla_organisation
|
||||||
|
VALUES ('{}', '{}')
|
||||||
|
""".format(numeric_id, name))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||||
|
op.execute("""
|
||||||
|
DELETE
|
||||||
|
FROM dvla_organisation
|
||||||
|
WHERE id = '{}'
|
||||||
|
""".format(numeric_id))
|
||||||
@@ -97,6 +97,12 @@ function start_aws_logs_agent {
|
|||||||
echo "AWS logs agent pid: ${AWSLOGS_AGENT_PID}"
|
echo "AWS logs agent pid: ${AWSLOGS_AGENT_PID}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function start_logs_tail {
|
||||||
|
exec tail -n0 -f ${LOGS_DIR}/app.log.json &
|
||||||
|
LOGS_TAIL_PID=$!
|
||||||
|
echo "tail pid: ${LOGS_TAIL_PID}"
|
||||||
|
}
|
||||||
|
|
||||||
function run {
|
function run {
|
||||||
while true; do
|
while true; do
|
||||||
get_celery_pids
|
get_celery_pids
|
||||||
@@ -104,6 +110,7 @@ function run {
|
|||||||
kill -0 ${APP_PID} 2&>/dev/null || return 1
|
kill -0 ${APP_PID} 2&>/dev/null || return 1
|
||||||
done
|
done
|
||||||
kill -0 ${AWSLOGS_AGENT_PID} 2&>/dev/null || start_aws_logs_agent
|
kill -0 ${AWSLOGS_AGENT_PID} 2&>/dev/null || start_aws_logs_agent
|
||||||
|
kill -0 ${LOGS_TAIL_PID} 2&>/dev/null || start_logs_tail
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -120,5 +127,6 @@ configure_aws_logs
|
|||||||
start_application "$@"
|
start_application "$@"
|
||||||
|
|
||||||
start_aws_logs_agent
|
start_aws_logs_agent
|
||||||
|
start_logs_tail
|
||||||
|
|
||||||
run
|
run
|
||||||
|
|||||||
Reference in New Issue
Block a user