mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-11 07:42:20 -05:00
add default template when it does not exist
This commit is contained in:
2
Makefile
2
Makefile
@@ -13,6 +13,7 @@ GIT_COMMIT ?= $(shell git rev-parse HEAD)
|
|||||||
bootstrap: ## Set up everything to run the app
|
bootstrap: ## Set up everything to run the app
|
||||||
make generate-version-file
|
make generate-version-file
|
||||||
poetry install
|
poetry install
|
||||||
|
poetry self add poetry-dotenv-plugin
|
||||||
createdb notification_api || true
|
createdb notification_api || true
|
||||||
(poetry run flask db upgrade) || true
|
(poetry run flask db upgrade) || true
|
||||||
|
|
||||||
@@ -73,7 +74,6 @@ generate-version-file: ## Generates the app version file
|
|||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: export NEW_RELIC_ENVIRONMENT=test
|
test: export NEW_RELIC_ENVIRONMENT=test
|
||||||
test: ## Run tests and create coverage report
|
test: ## Run tests and create coverage report
|
||||||
poetry self add poetry-dotenv-plugin
|
|
||||||
poetry run black .
|
poetry run black .
|
||||||
poetry run flake8 .
|
poetry run flake8 .
|
||||||
poetry run isort --check-only ./app ./tests
|
poetry run isort --check-only ./app ./tests
|
||||||
|
|||||||
@@ -772,12 +772,23 @@ def create_user_jwt(token):
|
|||||||
|
|
||||||
def _update_template(id, name, template_type, content, subject):
|
def _update_template(id, name, template_type, content, subject):
|
||||||
template = Template.query.filter_by(id=id).first()
|
template = Template.query.filter_by(id=id).first()
|
||||||
|
if not template:
|
||||||
|
template = Template(id=id)
|
||||||
|
template.service_id = "d6aa2c68-a2d9-4437-ab19-3ae8eb202553"
|
||||||
|
template.created_by_id = "6af522d0-2915-4e52-83a3-3690455a5fe6"
|
||||||
|
db.session.add(template)
|
||||||
template.name = name
|
template.name = name
|
||||||
template.template_type = template_type
|
template.template_type = template_type
|
||||||
template.content = "\n".join(content)
|
template.content = "\n".join(content)
|
||||||
template.subject = subject
|
template.subject = subject
|
||||||
|
|
||||||
history = TemplateHistory.query.filter_by(id=id).first()
|
history = TemplateHistory.query.filter_by(id=id).first()
|
||||||
|
if not history:
|
||||||
|
history = TemplateHistory(id=id)
|
||||||
|
history.service_id = "d6aa2c68-a2d9-4437-ab19-3ae8eb202553"
|
||||||
|
history.created_by_id = "6af522d0-2915-4e52-83a3-3690455a5fe6"
|
||||||
|
history.version = 1
|
||||||
|
db.session.add(history)
|
||||||
history.name = name
|
history.name = name
|
||||||
history.template_type = template_type
|
history.template_type = template_type
|
||||||
history.content = "\n".join(content)
|
history.content = "\n".join(content)
|
||||||
|
|||||||
Reference in New Issue
Block a user