Compare commits

..

6 Commits

Author SHA1 Message Date
jimmoffet
0adc0618b9 comment 2022-08-30 11:05:38 -07:00
jimmoffet
2382846622 fix domain config 2022-08-30 10:58:23 -07:00
jimmoffet
51d31600e5 notify email domain 2022-08-30 09:39:53 -07:00
jimmoffet
a0202dc0ce delete temp template 2022-08-29 19:14:17 -07:00
jimmoffet
02b7a447eb restore purge 2022-08-29 19:13:29 -07:00
jimmoffet
181ae4c60f deukify service and template 2022-08-29 19:10:56 -07:00
5 changed files with 114 additions and 24 deletions

View File

@@ -8,36 +8,30 @@ Contains:
- an internal-only REST API built using Flask to manage services, users, templates, etc (this is what the [admin app](http://github.com/18F/notifications-admin) talks to)
- asynchronous workers built using Celery to put things on queues and read them off to be processed, sent to providers, updated, etc
## QUICKSTART
---
If you are the first on your team to deploy, set up AWS SES/SNS as instructed in the AWS setup section below.
Create .env file as described in the .env section below.
## QUICK START
```
# If you are the first on your team to deploy, set up AWS SES/SNS as instructed below
Install VS Code
Open VS Code and install the Remote-Containers plug-in from Microsoft.
# create .env file as instructed below
Make sure your docker daemon is running (on OS X, this is typically accomplished by opening the Docker Desktop app)
Also make sure there is NOT a Postgres daemon running on port 5432.
# download vscode and install the Remote-Containers plug-in from Microsoft
Create the external docker network:
# make sure your docker daemon is running
`docker network create notify-network`
# create the external docker network
docker network create notify-network
Using the command palette (shift+cmd+p), search and select “Remote Containers: Open Folder in Container...”
When prompted, choose **devcontainer-api** folder (note: this is a *subfolder* of notification-api). This will startup the container in a new window (replacing the current one).
# Using the command pallette (cmd+p), search "Remote Containers: Open folder in project"
# choose devcontainer-api folder, after reload, hit "show logs" in bottom-right
After this page loads, hit "show logs” in bottom-right. The first time this runs it will need to build the Docker image, which will likely take several minutes.
# Check vscode panel > ports, await green dot, open a new terminal and run the web server
make run-flask
Select View->Open View..., then search/select “ports”. Await a green dot on the port view, then open a new terminal and run the web server:
`make run-flask`
# Open another terminal and run the background tasks
make run-celery
```
Open another terminal and run the background tasks:
`make run-celery`
Confirm that everything is working by hitting localhost:6011 and it responds with a 200 OK.
---
## Setting Up
### `.env` file

View File

@@ -116,6 +116,9 @@ class Config(object):
# Prefix to identify queues in SQS
NOTIFICATION_QUEUE_PREFIX = os.environ.get('NOTIFICATION_QUEUE_PREFIX')
# Use notify.sandbox.10x sending domain unless overwritten by environment
NOTIFY_EMAIL_DOMAIN = 'notify.sandbox.10x.gsa.gov'
# URL of redis instance
REDIS_URL = os.environ.get('REDIS_URL')
@@ -434,7 +437,8 @@ class Development(Config):
NOTIFY_ENVIRONMENT = 'development'
NOTIFY_LOG_PATH = 'application.log'
NOTIFY_EMAIL_DOMAIN = "dispostable.com"
NOTIFY_EMAIL_DOMAIN = os.getenv('NOTIFY_EMAIL_DOMAIN', 'notify.sandbox.10x.gsa.gov')
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI', 'postgresql://postgres:chummy@db:5432/notification_api')
REDIS_URL = os.environ.get('REDIS_URL')
@@ -533,7 +537,6 @@ class Staging(Config):
class Live(Config):
NOTIFY_EMAIL_DOMAIN = os.environ.get('NOTIFY_EMAIL_DOMAIN')
NOTIFY_ENVIRONMENT = 'live'
# buckets
CSV_UPLOAD_BUCKET_NAME = 'notifications-prototype-csv-upload' # created in gsa sandbox

View File

@@ -0,0 +1,54 @@
"""empty message
Revision ID: 0374_fix_reg_template_history
Revises: 0373_add_notifications_view
Create Date: 2022-08-22 11:04:15.888017
"""
# revision identifiers, used by Alembic.
from datetime import datetime
revision = '0374_fix_reg_template_history'
down_revision = '0373_add_notifications_view'
from alembic import op
import sqlalchemy as sa
service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
user_id= '6af522d0-2915-4e52-83a3-3690455a5fe6'
def upgrade():
op.get_bind()
# modify subject of verification email in templates
table_name = 'templates'
col = 'subject'
val = 'Confirm US Notify registration'
select_by_col = 'name'
select_by_val = 'Notify email verification code'
op.execute(f"update {table_name} set {col}='{val}' where {select_by_col} = '{select_by_val}'")
# modify subject of verification email in templates_history
table_name = 'templates_history'
op.execute(f"update {table_name} set {col}='{val}' where {select_by_col} = '{select_by_val}'")
# modify content of verification email in templates
table_name = 'templates'
col = 'content'
val = """Hi ((name)),\n\nTo complete your registration for US Notify please click the link below\n\n((url))"""
select_by_col = 'name'
select_by_val = 'Notify email verification code'
op.execute(f"update {table_name} set {col}='{val}' where {select_by_col} = '{select_by_val}'")
# modify content of verification email in templates_history
table_name = 'templates_history'
op.execute(f"update {table_name} set {col}='{val}' where {select_by_col} = '{select_by_val}'")
# TODO: modify other templates as necessary and re-run this migration
def downgrade():
### commands auto generated by Alembic - please adjust! ###
pass
### end Alembic commands ###

View File

@@ -0,0 +1,39 @@
"""empty message
Revision ID: 0375_fix_service_name
Revises: 0374_fix_reg_template_history
Create Date: 2022-08-29 11:04:15.888017
"""
# revision identifiers, used by Alembic.
from datetime import datetime
revision = '0375_fix_service_name'
down_revision = '0374_fix_reg_template_history'
from alembic import op
import sqlalchemy as sa
service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
user_id= '6af522d0-2915-4e52-83a3-3690455a5fe6'
def upgrade():
op.get_bind()
# modify name of default service user in services
table_name = 'services'
col = 'name'
val = 'US Notify'
select_by_col = 'id'
select_by_val = service_id
op.execute(f"update {table_name} set {col}='{val}' where {select_by_col} = '{select_by_val}'")
table_name = 'services_history'
op.execute(f"update {table_name} set {col}='{val}' where {select_by_col} = '{select_by_val}'")
def downgrade():
### commands auto generated by Alembic - please adjust! ###
pass
### end Alembic commands ###

View File

@@ -4,7 +4,7 @@
DEBUG=True
ANTIVIRUS_ENABLED=0
NOTIFY_ENVIRONMENT=development
NOTIFICATION_QUEUE_PREFIX=local_dev_10x
NOTIFICATION_QUEUE_PREFIX=local_dev_YOURNAME_
STATSD_HOST=localhost
SES_STUB_URL=None
NOTIFY_APP_NAME=api