mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-27 09:29:22 -04:00
Remove dependence on domains.yml from static pages
This will allow us to remove the `domains.yml` file, by using information about organisations that is now stored in the database instead.
This commit is contained in:
@@ -16,7 +16,7 @@ from app import email_branding_client, letter_branding_client
|
||||
from app.main import main
|
||||
from app.main.forms import FieldWithNoneOption, SearchByNameForm
|
||||
from app.main.views.sub_navigation_dictionaries import features_nav
|
||||
from app.utils import AgreementInfo, get_logo_cdn_domain
|
||||
from app.utils import get_logo_cdn_domain
|
||||
|
||||
|
||||
@main.route('/')
|
||||
@@ -75,7 +75,6 @@ def pricing():
|
||||
for cc, country in INTERNATIONAL_BILLING_RATES.items()
|
||||
], key=lambda x: x[0]),
|
||||
search_form=SearchByNameForm(),
|
||||
agreement_info=AgreementInfo.from_current_user(),
|
||||
)
|
||||
|
||||
|
||||
@@ -249,7 +248,6 @@ def terms():
|
||||
return render_template(
|
||||
'views/terms-of-use.html',
|
||||
navigation_links=features_nav(),
|
||||
agreement_info=AgreementInfo.from_current_user(),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
<h2 class="heading-medium" id="paying">How to pay</h2>
|
||||
<p>You can find details of how to pay for Notify in our data sharing and financial agreement.</p>
|
||||
<p>
|
||||
{{ agreement_info.as_pricing_paragraph(
|
||||
{{ current_user.default_organisation.as_pricing_paragraph(
|
||||
pricing_link=url_for('main.sign_in', next=url_for('main.pricing', _anchor='paying')),
|
||||
download_link=url_for('main.agreement'),
|
||||
support_link=url_for('.feedback', ticket_type='ask-question-give-feedback', body='agreement'),
|
||||
|
||||
@@ -21,7 +21,7 @@ Terms of use
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ agreement_info.as_terms_of_use_paragraph(
|
||||
{{ current_user.default_organisation.as_terms_of_use_paragraph(
|
||||
terms_link=url_for('main.sign_in', next=url_for('main.terms')),
|
||||
download_link=url_for('.agreement'),
|
||||
support_link=url_for('.feedback', ticket_type='ask-question-give-feedback', body='agreement'),
|
||||
|
||||
@@ -184,7 +184,7 @@ def service_json(
|
||||
|
||||
def organisation_json(
|
||||
id_='1234',
|
||||
name='Test Organisation',
|
||||
name=False,
|
||||
users=None,
|
||||
active=True,
|
||||
created_at=None,
|
||||
@@ -192,6 +192,8 @@ def organisation_json(
|
||||
letter_branding_id=None,
|
||||
email_branding_id=None,
|
||||
domains=None,
|
||||
crown=True,
|
||||
agreement_signed=False,
|
||||
):
|
||||
if users is None:
|
||||
users = []
|
||||
@@ -199,7 +201,7 @@ def organisation_json(
|
||||
services = []
|
||||
return {
|
||||
'id': id_,
|
||||
'name': name,
|
||||
'name': 'Test Organisation' if name is False else name,
|
||||
'active': active,
|
||||
'users': users,
|
||||
'services': services,
|
||||
@@ -207,8 +209,8 @@ def organisation_json(
|
||||
'email_branding_id': email_branding_id,
|
||||
'letter_branding_id': letter_branding_id,
|
||||
'organisation_type': '',
|
||||
'crown': True,
|
||||
'agreement_signed': False,
|
||||
'crown': crown,
|
||||
'agreement_signed': agreement_signed,
|
||||
'agreement_signed_at': None,
|
||||
'agreement_signed_by': None,
|
||||
'domains': domains or [],
|
||||
|
||||
@@ -6,7 +6,7 @@ from flask import url_for
|
||||
|
||||
from app.main.forms import FieldWithNoneOption
|
||||
from tests.conftest import (
|
||||
active_user_with_permissions,
|
||||
mock_get_organisation_by_domain,
|
||||
normalize_spaces,
|
||||
sample_uuid,
|
||||
)
|
||||
@@ -69,6 +69,7 @@ def test_robots(client):
|
||||
])
|
||||
def test_static_pages(
|
||||
client_request,
|
||||
mock_get_organisation_by_domain,
|
||||
view,
|
||||
):
|
||||
page = client_request.get('main.{}'.format(view))
|
||||
@@ -166,13 +167,15 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
|
||||
|
||||
|
||||
@pytest.mark.parametrize((
|
||||
'email_address,'
|
||||
'name,'
|
||||
'agreement_signed,'
|
||||
'expected_terms_paragraph,'
|
||||
'expected_terms_link,'
|
||||
'expected_pricing_paragraph'
|
||||
), [
|
||||
(
|
||||
'test@cabinet-office.gov.uk',
|
||||
'Cabinet Office',
|
||||
True,
|
||||
(
|
||||
'Your organisation (Cabinet Office) has already accepted '
|
||||
'the GOV.UK Notify data sharing and financial agreement.'
|
||||
@@ -184,7 +187,8 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
|
||||
),
|
||||
),
|
||||
(
|
||||
'test@aylesburytowncouncil.gov.uk',
|
||||
'Aylesbury Town Council',
|
||||
False,
|
||||
(
|
||||
'Your organisation (Aylesbury Town Council) must also '
|
||||
'accept our data sharing and financial agreement. Download '
|
||||
@@ -200,7 +204,8 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
|
||||
),
|
||||
),
|
||||
(
|
||||
'larry@downing-street.gov.uk',
|
||||
None,
|
||||
None,
|
||||
(
|
||||
'Your organisation must also accept our data sharing and '
|
||||
'financial agreement. Download the agreement or contact us '
|
||||
@@ -217,7 +222,8 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
|
||||
),
|
||||
),
|
||||
(
|
||||
'michael.fish@metoffice.gov.uk',
|
||||
'Met Office',
|
||||
False,
|
||||
(
|
||||
'Your organisation (Met Office) must also accept our data '
|
||||
'sharing and financial agreement. Download a copy.'
|
||||
@@ -236,14 +242,17 @@ def test_terms_tells_logged_in_users_what_we_know_about_their_agreement(
|
||||
mocker,
|
||||
fake_uuid,
|
||||
client_request,
|
||||
email_address,
|
||||
name,
|
||||
agreement_signed,
|
||||
expected_terms_paragraph,
|
||||
expected_terms_link,
|
||||
expected_pricing_paragraph,
|
||||
):
|
||||
user = active_user_with_permissions(fake_uuid)
|
||||
user.email_address = email_address
|
||||
mocker.patch('app.user_api_client.get_user', return_value=user)
|
||||
mock_get_organisation_by_domain(
|
||||
mocker,
|
||||
name=name,
|
||||
agreement_signed=agreement_signed,
|
||||
)
|
||||
terms_page = client_request.get('main.terms')
|
||||
pricing_page = client_request.get('main.pricing')
|
||||
assert normalize_spaces(terms_page.select('main p')[1].text) == expected_terms_paragraph
|
||||
@@ -256,7 +265,7 @@ def test_terms_tells_logged_in_users_what_we_know_about_their_agreement(
|
||||
|
||||
def test_css_is_served_from_correct_path(client_request):
|
||||
|
||||
page = client_request.get('main.pricing') # easy static page
|
||||
page = client_request.get('main.documentation') # easy static page
|
||||
|
||||
for index, link in enumerate(
|
||||
page.select('link[rel=stylesheet]')
|
||||
|
||||
@@ -3125,6 +3125,27 @@ def mock_get_organisation(
|
||||
return mocker.patch('app.organisations_client.get_organisation', side_effect=_get_organisation)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_organisation_by_domain(
|
||||
mocker,
|
||||
name=False,
|
||||
crown=True,
|
||||
agreement_signed=False,
|
||||
):
|
||||
def _get_organisation_by_domain(org_id):
|
||||
return organisation_json(
|
||||
org_id,
|
||||
name,
|
||||
crown=crown,
|
||||
agreement_signed=agreement_signed,
|
||||
)
|
||||
|
||||
return mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
side_effect=_get_organisation_by_domain,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_service_organisation(mocker):
|
||||
def _get_service_organisation(service_id):
|
||||
|
||||
Reference in New Issue
Block a user