mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Merge pull request #2071 from alphagov/public-agreement
Add URLs to download the agreement without login
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from flask import render_template, send_file
|
from flask import abort, render_template, request, send_file, url_for
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
from app.main import main
|
from app.main import main
|
||||||
@@ -28,3 +28,24 @@ def download_agreement():
|
|||||||
return send_file(**get_mou(
|
return send_file(**get_mou(
|
||||||
AgreementInfo.from_current_user().crown_status_or_404
|
AgreementInfo.from_current_user().crown_status_or_404
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
@main.route('/agreement/<variant>', endpoint='public_agreement')
|
||||||
|
@main.route('/agreement/<variant>.pdf', endpoint='public_download_agreement')
|
||||||
|
def public_agreement(variant):
|
||||||
|
|
||||||
|
if variant not in {'crown', 'non-crown'}:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
if request.endpoint == 'main.public_download_agreement':
|
||||||
|
return send_file(**get_mou(
|
||||||
|
organisation_is_crown=(variant == 'crown')
|
||||||
|
))
|
||||||
|
|
||||||
|
agreement_info = AgreementInfo.from_current_user()
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
'views/agreement-public.html',
|
||||||
|
owner=agreement_info.owner,
|
||||||
|
download_link=url_for('.public_download_agreement', variant=variant),
|
||||||
|
)
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ class HeaderNavigation(Navigation):
|
|||||||
'old_using_notify',
|
'old_using_notify',
|
||||||
'organisation_dashboard',
|
'organisation_dashboard',
|
||||||
'organisation_settings',
|
'organisation_settings',
|
||||||
|
'public_agreement',
|
||||||
|
'public_download_agreement',
|
||||||
'received_text_messages_callback',
|
'received_text_messages_callback',
|
||||||
'redact_template',
|
'redact_template',
|
||||||
'register',
|
'register',
|
||||||
@@ -414,6 +416,8 @@ class MainNavigation(Navigation):
|
|||||||
'organisations',
|
'organisations',
|
||||||
'platform_admin',
|
'platform_admin',
|
||||||
'pricing',
|
'pricing',
|
||||||
|
'public_agreement',
|
||||||
|
'public_download_agreement',
|
||||||
'redact_template',
|
'redact_template',
|
||||||
'register',
|
'register',
|
||||||
'register_from_invite',
|
'register_from_invite',
|
||||||
@@ -578,6 +582,8 @@ class OrgNavigation(Navigation):
|
|||||||
'organisations',
|
'organisations',
|
||||||
'platform_admin',
|
'platform_admin',
|
||||||
'pricing',
|
'pricing',
|
||||||
|
'public_agreement',
|
||||||
|
'public_download_agreement',
|
||||||
'received_text_messages_callback',
|
'received_text_messages_callback',
|
||||||
'redact_template',
|
'redact_template',
|
||||||
'register',
|
'register',
|
||||||
|
|||||||
27
app/templates/views/agreement-public.html
Normal file
27
app/templates/views/agreement-public.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{% extends "withoutnav_template.html" %}
|
||||||
|
{% from "components/sub-navigation.html" import sub_navigation %}
|
||||||
|
|
||||||
|
{% block per_page_title %}
|
||||||
|
Download the GOV.UK Notify data sharing and financial agreement
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
|
<div class="grid-row">
|
||||||
|
<div class="column-two-thirds">
|
||||||
|
|
||||||
|
<h1 class="heading-large">
|
||||||
|
Download the GOV.UK Notify data sharing and financial agreement
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="{{ download_link }}">Download the agreement</a>{% if owner %} for {{ owner }}{% endif %}.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The agreement contains commercially sensitive information, so don’t share it more widely than you need to.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -102,3 +102,30 @@ def test_agreement_requires_login(
|
|||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert response.location == 'http://localhost/sign-in?next=%2Fagreement.pdf'
|
assert response.location == 'http://localhost/sign-in?next=%2Fagreement.pdf'
|
||||||
assert mock_get_s3_object.call_args_list == []
|
assert mock_get_s3_object.call_args_list == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('endpoint', (
|
||||||
|
'main.public_agreement',
|
||||||
|
'main.public_download_agreement',
|
||||||
|
))
|
||||||
|
@pytest.mark.parametrize('variant, expected_status', (
|
||||||
|
('crown', 200),
|
||||||
|
('non-crown', 200),
|
||||||
|
('foo', 404),
|
||||||
|
))
|
||||||
|
def test_show_public_agreement_page(
|
||||||
|
client,
|
||||||
|
mocker,
|
||||||
|
endpoint,
|
||||||
|
variant,
|
||||||
|
expected_status,
|
||||||
|
):
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.s3_client.get_s3_object',
|
||||||
|
return_value=_MockS3Object()
|
||||||
|
)
|
||||||
|
response = client.get(url_for(
|
||||||
|
endpoint,
|
||||||
|
variant=variant,
|
||||||
|
))
|
||||||
|
assert response.status_code == expected_status
|
||||||
|
|||||||
Reference in New Issue
Block a user