Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
create separate lookup for pf contractor emails
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbi-hbrown committed Feb 26, 2024
1 parent 67e027b commit a965d9c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
7 changes: 4 additions & 3 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def setup_funds_and_auth(app: Flask) -> None:
:return: None
"""
app.logger.info("Setting up fund configs and auth mappings")
app.logger.info(f"Additional auth details from secret: {str(Config.ADDITIONAL_EMAIL_LOOKUPS)}")
app.logger.info(f"Additional TF auth details from secret: {str(Config.TF_ADDITIONAL_EMAIL_LOOKUPS)}")
app.logger.info(f"Additional PF auth details from secret: {str(Config.PF_ADDITIONAL_EMAIL_LOOKUPS)}")

# funds
towns_fund: FundConfig = TOWNS_FUND_APP_CONFIG
Expand All @@ -97,10 +98,10 @@ def setup_funds_and_auth(app: Flask) -> None:

# auth
tf_auth = TF_AUTH
tf_auth.update(Config.ADDITIONAL_EMAIL_LOOKUPS)
tf_auth.update(Config.TF_ADDITIONAL_EMAIL_LOOKUPS)

pf_auth = PF_AUTH
pf_auth.update(Config.PF_EMAIL_LOOKUPS)
pf_auth.update(Config.PF_ADDITIONAL_EMAIL_LOOKUPS)

app.config["AUTH_MAPPINGS"] = AuthService(
fund_to_auth_mappings={
Expand Down
2 changes: 1 addition & 1 deletion app/main/authorisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class PFAuth(AuthBase):

_local_authorities: tuple[str, ...]

def __init__(self, *local_authorities: tuple[str, ...]):
def __init__(self, local_authorities: tuple[str, ...]):
"""
:param local_authorities: a tuple of local authorities
Expand Down
1 change: 0 additions & 1 deletion app/templates/main/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

{% if days_to_deadline <= 7 %}
{% set notificationHTML %}
{# Do we want to keep only displaying this within 7 days of deadline? #}
{% if days_to_deadline == 0 %}
<p class="govuk-notification-banner__heading">Your data return is due today.</p>
{% elif days_to_deadline == 1 %}
Expand Down
12 changes: 8 additions & 4 deletions config/envs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ class DefaultConfig(object):
if RSA256_PUBLIC_KEY_BASE64:
RSA256_PUBLIC_KEY = base64.b64decode(RSA256_PUBLIC_KEY_BASE64).decode()

ADDITIONAL_EMAIL_LOOKUPS = ast.literal_eval(os.getenv("ADDITIONAL_EMAIL_LOOKUPS", "{}"))
if not isinstance(ADDITIONAL_EMAIL_LOOKUPS, dict):
raise TypeError("ADDITIONAL_EMAIL_LOOKUPS must be a dictionary")
TF_ADDITIONAL_EMAIL_LOOKUPS = ast.literal_eval(os.getenv("TF_ADDITIONAL_EMAIL_LOOKUPS", "{}"))
if not isinstance(TF_ADDITIONAL_EMAIL_LOOKUPS, dict):
raise TypeError("TF_ADDITIONAL_EMAIL_LOOKUPS must be a dictionary")

# TODO find more extendable solution for new fund additional email lookups
PF_ADDITIONAL_EMAIL_LOOKUPS = ast.literal_eval(os.getenv("PF_ADDITIONAL_EMAIL_LOOKUPS", "{}"))
if not isinstance(PF_ADDITIONAL_EMAIL_LOOKUPS, dict):
raise TypeError("PF_ADDITIONAL_EMAIL_LOOKUPS must be a dictionary")

# Gov Notify for confirmation emails
SEND_CONFIRMATION_EMAILS = True
Expand All @@ -54,7 +59,6 @@ class DefaultConfig(object):
)
TF_CONFIRMATION_EMAIL_ADDRESS = os.environ.get("TF_CONFIRMATION_EMAIL_ADDRESS", "fake.email@townsfund.gov.uk")
PF_CONFIRMATION_EMAIL_ADDRESS = os.environ.get("PF_CONFIRMATION_EMAIL_ADDRESS", "fake.email@pathfinders.gov.uk")
# TODO create new email template for Pathfinders
FUND_CONFIRMATION_EMAIL_TEMPLATE_ID = os.environ.get(
"TF_CONFIRMATION_EMAIL_TEMPLATE_ID", "d238cc3e-f46a-4170-87d4-1c5768b80ed5"
)
Expand Down
7 changes: 5 additions & 2 deletions config/envs/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DevelopmentConfig(DefaultConfig):
RSA256_PUBLIC_KEY = public_key_file.read()

# devs can submit for these LAs and places
ADDITIONAL_EMAIL_LOOKUPS = {
TF_ADDITIONAL_EMAIL_LOOKUPS = {
"version1.com": (
(
"Sunderland City Council",
Expand All @@ -41,7 +41,10 @@ class DevelopmentConfig(DefaultConfig):
),
}

PF_EMAIL_LOOKUPS = {domain: las[0] for domain, las in ADDITIONAL_EMAIL_LOOKUPS.items()}
PF_EMAIL_LOOKUPS = {
domain: (("Rotherham Metropolitan Borough Council",),)
for domain in ("version1.com", "communities.gov.uk", "test.communities.gov.uk")
}

# do not attempt to send confirmation email if development and no key is set
SEND_CONFIRMATION_EMAILS = True if DefaultConfig.NOTIFY_API_KEY else False
Expand Down
2 changes: 1 addition & 1 deletion config/envs/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UnitTestConfig(DefaultConfig):
EXAMPLE_INGEST_WRONG_FORMAT = DefaultConfig.FLASK_ROOT + "/tests/resources/wrong_format_test_file.txt"
EXAMPLE_INGEST_DATA_PATH = DefaultConfig.FLASK_ROOT + "/tests/resources/Pre_ingest_EXAMPLE_data.xlsx"
DATA_STORE_API_HOST = "http://data-store"
ADDITIONAL_EMAIL_LOOKUPS = {
TF_ADDITIONAL_EMAIL_LOOKUPS = {
"multiple_orgs@contractor.com": (
(
"Rotherham Metropolitan Borough Council",
Expand Down
5 changes: 3 additions & 2 deletions copilot/submit/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ secrets:
AUTHENTICATOR_HOST: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/AUTHENTICATOR_HOST # The key is the name of the environment variable, the value is the name of the SSM parameter.
SECRET_KEY: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/SECRET_KEY
RSA256_PUBLIC_KEY_BASE64: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/RSA256_PUBLIC_KEY_BASE64
ADDITIONAL_EMAIL_LOOKUPS: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/ADDITIONAL_EMAIL_LOOKUPS
TF_ADDITIONAL_EMAIL_LOOKUPS: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/TF_ADDITIONAL_EMAIL_LOOKUPS
PF_ADDITIONAL_EMAIL_LOOKUPS: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/PF_ADDITIONAL_EMAIL_LOOKUPS
NOTIFY_API_KEY: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/NOTIFY_API_KEY
TF_CONFIRMATION_EMAIL_ADDRESS : /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/TF_CONFIRMATION_EMAIL_ADDRESS

PF_CONFIRMATION_EMAIL_ADDRESS : /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/PF_CONFIRMATION_EMAIL_ADDRESS
# You can override any of the values defined above by environment.
environments:
production:
Expand Down

0 comments on commit a965d9c

Please sign in to comment.