Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fs1352 req new link #51

Merged
merged 8 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions config/envs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,6 @@ class DefaultConfig(object):
# Notification Service
NOTIFICATION_SERVICE_HOST = environ.get("NOTIFICATION_SERVICE_HOST")
SEND_ENDPOINT = "/send"
NOTIFY_TEMPLATE_MAGIC_LINK = "MAGIC_LINK"
NOTIFICATION_MAGIC_LINK_CONTACT_HELP_EMAIL = (
CommonConfig.NOTIFICATION_MAGIC_LINK_CONTACT_HELP_EMAIL
)
NOTIFICATION_MAGIC_LINK_MAGIC_LINK_URL = (
CommonConfig.NOTIFICATION_MAGIC_LINK_MAGIC_LINK_URL
)
NOTIFICATION_MAGIC_LINK_REQUEST_NEW_EMAIL_URL = (
CommonConfig.NOTIFICATION_MAGIC_LINK_REQUEST_NEW_EMAIL_URL
)
NOTIFICATION_MAGIC_LINK_FUND_NAME = (
CommonConfig.NOTIFICATION_MAGIC_LINK_FUND_NAME
)

# Applicant Frontend
APPLICANT_FRONTEND_HOST = environ.get(
Expand Down
13 changes: 7 additions & 6 deletions models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from config import Config
from flask import current_app
from fsd_utils.config.notify_constants import NotifyConstants
from models.application import Application
from models.application import ApplicationMethods
from models.data import get_data
Expand Down Expand Up @@ -112,10 +113,10 @@ def get_magic_link(
fund = FundMethods.get_fund(fund_id)

notification_content = {
Config.NOTIFICATION_MAGIC_LINK_REQUEST_NEW_EMAIL_URL: Config.AUTHENTICATOR_HOST # noqa
NotifyConstants.FIELD_REQUEST_NEW_LINK_URL: Config.AUTHENTICATOR_HOST # noqa
+ Config.NEW_LINK_ENDPOINT,
Config.NOTIFICATION_MAGIC_LINK_CONTACT_HELP_EMAIL: fund.contact_help, # noqa
Config.NOTIFICATION_MAGIC_LINK_FUND_NAME: fund.name,
NotifyConstants.FIELD_CONTACT_HELP_EMAIL: fund.contact_help, # noqa
NotifyConstants.FIELD_FUND_NAME: fund.name,
}
if fund_id and round_id and new_account:
# Create an application if none exists
Expand All @@ -125,15 +126,15 @@ def get_magic_link(
if new_application:
notification_content.update(
{
Config.NOTIFICATION_MAGIC_LINK_FUND_NAME: new_application.fund_name # noqa
NotifyConstants.FIELD_FUND_NAME: new_application.fund_name # noqa
}
)

# Create a fresh link
new_link_json = MagicLinkMethods().create_magic_link(account)
notification_content.update(
{
Config.NOTIFICATION_MAGIC_LINK_MAGIC_LINK_URL: new_link_json.get( # noqa
NotifyConstants.FIELD_MAGIC_LINK_URL: new_link_json.get( # noqa
"link"
)
}
Expand All @@ -144,7 +145,7 @@ def get_magic_link(
)
# Send notification
Notification.send(
Config.NOTIFY_TEMPLATE_MAGIC_LINK,
NotifyConstants.TEMPLATE_TYPE_MAGIC_LINK,
account.email,
notification_content,
)
Expand Down
7 changes: 6 additions & 1 deletion models/notification.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from config import Config
from fsd_utils.config.notify_constants import NotifyConstants
from models.data import post_data


Expand All @@ -21,7 +22,11 @@ def send(template_type: str, to_email: str, content: dict):
fill out the notification template
"""
url = Config.NOTIFICATION_SERVICE_HOST + Config.SEND_ENDPOINT
params = {"type": template_type, "to": to_email, "content": content}
params = {
NotifyConstants.FIELD_TYPE: template_type,
NotifyConstants.FIELD_TO: to_email,
NotifyConstants.FIELD_CONTENT: content,
}
response = post_data(url, params)
if response:
return True
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ flask-talisman==0.8.1
# via -r requirements.txt
flask-wtf==1.0.0
# via -r requirements.txt
funding-service-design-utils @ https://github.com/communitiesuk/funding-service-design-utils/archive/refs/tags/0.0.19.tar.gz
funding-service-design-utils @ git+https://github.com/communitiesuk/funding-service-design-utils@bau-notify-fields
# via -r requirements.txt
gitdb==4.0.9
# via gitpython
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# FSD Utils
#-----------------------------------

https://github.com/communitiesuk/funding-service-design-utils/archive/refs/tags/0.0.19.tar.gz
git+https://github.com/communitiesuk/funding-service-design-utils@bau-notify-fields

requests

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ flask-talisman==0.8.1
# via -r requirements.in
flask-wtf==1.0.0
# via -r requirements.in
funding-service-design-utils @ https://github.com/communitiesuk/funding-service-design-utils/archive/refs/tags/0.0.19.tar.gz
funding-service-design-utils @ git+https://github.com/communitiesuk/funding-service-design-utils@bau-notify-fields
srh-sloan marked this conversation as resolved.
Show resolved Hide resolved
# via -r requirements.in
govuk-frontend-jinja==2.0.0
# via -r requirements.in
Expand Down