move financial deets to an environment variable

lets us keep cabinet office financials safe in the credentials repo

the dict in the creds repo will either be an empty dict or a full dict,
so the env var on paas will always contain some parseable json. But
locally it might not, so if it's not set at all then default to the
string `null` so the json parsing doesn't throw a wobbly.
This commit is contained in:
Leo Hemsted
2021-08-13 18:35:18 +01:00
parent 2b8289a5d8
commit 86c413557c
4 changed files with 25 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
import json
import os
if os.environ.get('VCAP_APPLICATION'):
@@ -78,6 +79,19 @@ class Config(object):
NOTIFY_SERVICE_ID = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
NOTIFY_BILLING_DETAILS = json.loads(
os.environ.get('NOTIFY_BILLING_DETAILS') or 'null'
) or {
'account_number': '98765432',
'sort_code': '01-23-45',
'IBAN': 'GB33BUKB20201555555555',
'swift': 'ABCDEF12',
'notify_billing_email_addresses': [
'generic@digital.cabinet-office.gov.uk',
'first.last@digital.cabinet-office.gov.uk',
]
}
class Development(Config):
NOTIFY_LOG_PATH = 'application.log'

View File

@@ -1,5 +1,6 @@
from flask import (
abort,
current_app,
make_response,
redirect,
render_template,
@@ -86,6 +87,7 @@ def billing_details():
if current_user.is_authenticated:
return render_template(
'views/pricing/billing-details.html',
billing_details=current_app.config['NOTIFY_BILLING_DETAILS'],
navigation_links=pricing_nav(),
)
return render_template(

View File

@@ -39,12 +39,11 @@
</h3>
<ul class="govuk-list govuk-list--bullet">
{% for email in billing_details['notify_billing_email_addresses'] %}
<li>
generic@digital.cabinet-office.gov.uk
</li>
<li>
first.last@digital.cabinet-office.gov.uk
{{ email }}
</li>
{% endfor %}
</ul>
<h3 class="heading-small">
@@ -82,7 +81,7 @@
<div class="govuk-!-margin-bottom-4">
{{ copy_to_clipboard(
'98765432',
billing_details['account_number'],
name='Account number',
thing='account number',
) }}
@@ -90,7 +89,7 @@
<div class="govuk-!-margin-bottom-4">
{{ copy_to_clipboard(
'01-23-45',
billing_details['sort_code'],
name='Sort code',
thing='sort code',
) }}
@@ -98,7 +97,7 @@
<div class="govuk-!-margin-bottom-4">
{{ copy_to_clipboard(
'GB33BUKB20201555555555',
billing_details['IBAN'],
name='IBAN',
thing='IBAN',
) }}
@@ -106,7 +105,7 @@
<div class="govuk-!-margin-bottom-4">
{{ copy_to_clipboard(
'ABCDEF12',
billing_details['swift'],
name='Swift code',
thing='Swift code',
) }}

View File

@@ -59,3 +59,5 @@ applications:
REDIS_ENABLED: '{{ REDIS_ENABLED }}'
REDIS_URL: '{{ REDIS_URL }}'
NOTIFY_BILLING_DETAILS: '{{ NOTIFY_BILLING_DETAILS | tojson }}'