Add URLs to download the agreement without login

So that we can share these URLs in an email we’re sending out.
This commit is contained in:
Chris Hill-Scott
2018-05-08 14:06:26 +01:00
parent e47a459757
commit 771f916630
4 changed files with 82 additions and 1 deletions

View File

@@ -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 app.main import main
@@ -28,3 +28,24 @@ def download_agreement():
return send_file(**get_mou(
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),
)