mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-06 17:09:00 -04:00
We used to give users the right version of the agreement by guessing their organisation from their email address. Now we do it by looking at the organisation of the service they’re looking at. In other words, users should only be downloading the agreement as part of the go live journey, not outside it. This is because we think that users will get confused if they download the agreement and: - find there’s nowhere to physically sign it - think that accepting the agreement is all they need to do to go live Maintaining two paths to download the agreement also makes the code more complicated, and makes it harder to update the content on these pages.
92 lines
3.1 KiB
Python
92 lines
3.1 KiB
Python
from datetime import datetime
|
|
|
|
from flask import abort, redirect, render_template, request, send_file, url_for
|
|
from flask_login import current_user
|
|
|
|
from app import current_service
|
|
from app.main import main
|
|
from app.main.forms import AcceptAgreementForm
|
|
from app.s3_client.s3_mou_client import get_mou
|
|
from app.utils import user_has_permissions
|
|
|
|
|
|
@main.route('/services/<uuid:service_id>/agreement')
|
|
@user_has_permissions('manage_service')
|
|
def service_agreement(service_id):
|
|
if current_service.organisation.crown is None:
|
|
return render_template('views/agreement/service-agreement-choose.html')
|
|
if current_service.organisation.agreement_signed:
|
|
return render_template('views/agreement/service-agreement-signed.html')
|
|
return render_template('views/agreement/service-agreement.html')
|
|
|
|
|
|
@main.route('/services/<uuid:service_id>/agreement.pdf')
|
|
@user_has_permissions('manage_service')
|
|
def service_download_agreement(service_id):
|
|
return send_file(**get_mou(
|
|
current_service.organisation.crown_status_or_404
|
|
))
|
|
|
|
|
|
@main.route('/services/<uuid:service_id>/agreement/accept', methods=['GET', 'POST'])
|
|
@user_has_permissions('manage_service')
|
|
def service_accept_agreement(service_id):
|
|
|
|
if not current_service.organisation:
|
|
abort(404)
|
|
|
|
form = AcceptAgreementForm.from_organisation(current_service.organisation)
|
|
|
|
if form.validate_on_submit():
|
|
current_service.organisation.update(
|
|
agreement_signed_version=float(form.version.data),
|
|
agreement_signed_on_behalf_of_name=form.on_behalf_of_name.data,
|
|
agreement_signed_on_behalf_of_email_address=form.on_behalf_of_email.data,
|
|
)
|
|
return redirect(url_for('main.service_confirm_agreement', service_id=current_service.id))
|
|
|
|
return render_template(
|
|
'views/agreement/agreement-accept.html',
|
|
form=form,
|
|
)
|
|
|
|
|
|
@main.route('/services/<uuid:service_id>/agreement/confirm', methods=['GET', 'POST'])
|
|
@user_has_permissions('manage_service')
|
|
def service_confirm_agreement(service_id):
|
|
|
|
if (
|
|
not current_service.organisation
|
|
or current_service.organisation.agreement_signed_version is None
|
|
):
|
|
abort(403)
|
|
|
|
if request.method == 'POST':
|
|
current_service.organisation.update(
|
|
agreement_signed=True,
|
|
agreement_signed_at=str(datetime.utcnow()),
|
|
agreement_signed_by_id=current_user.id,
|
|
)
|
|
return redirect(url_for('main.request_to_go_live', service_id=current_service.id))
|
|
|
|
return render_template('views/agreement/agreement-confirm.html')
|
|
|
|
|
|
@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),
|
|
)
|