mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-17 21:20:32 -04:00
Usually the service’s organisation and the user’s current organisation will be the same. But this won’t be the case when: - someone with a non-government email address is looking at the page - someone from our team, as a platform admin user, is looking at the page (it will show Cabinet Office instead) This commit fixes these problems by explicitly looking at the service’s organisation. We couldn’t do this previously because when this page wasn’t service-specific `current_service` was not guaranteed to be set.
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
from flask import abort, render_template, request, send_file, url_for
|
|
from flask_login import current_user, login_required
|
|
|
|
from app import current_service
|
|
from app.main import main
|
|
from app.main.views.sub_navigation_dictionaries import features_nav
|
|
from app.s3_client.s3_mou_client import get_mou
|
|
|
|
|
|
@main.route('/agreement')
|
|
@login_required
|
|
def agreement():
|
|
return render_template(
|
|
'views/agreement/{}.html'.format(current_user.default_organisation.as_jinja_template),
|
|
owner=current_user.default_organisation.name,
|
|
navigation_links=features_nav(),
|
|
)
|
|
|
|
|
|
@main.route('/services/<uuid:service_id>/agreement')
|
|
@login_required
|
|
def service_agreement(service_id):
|
|
return render_template(
|
|
'views/agreement/service-{}.html'.format(current_service.organisation.as_jinja_template),
|
|
owner=current_service.organisation.name,
|
|
)
|
|
|
|
|
|
@main.route('/agreement.pdf')
|
|
@login_required
|
|
def download_agreement():
|
|
return send_file(**get_mou(
|
|
current_user.default_organisation.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')
|
|
))
|
|
|
|
return render_template(
|
|
'views/agreement/agreement-public.html',
|
|
owner=current_user.default_organisation.name,
|
|
download_link=url_for('.public_download_agreement', variant=variant),
|
|
)
|