mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-30 19:29:43 -04:00
Merge pull request #508 from alphagov/request-to-go-live-form
Put a form on the request to go live page
This commit is contained in:
@@ -24,5 +24,6 @@ from app.main.views import (
|
||||
manage_users,
|
||||
invites,
|
||||
all_services,
|
||||
tour
|
||||
tour,
|
||||
feedback
|
||||
)
|
||||
|
||||
@@ -313,3 +313,10 @@ class Feedback(Form):
|
||||
name = StringField('Name')
|
||||
email_address = StringField('Email address')
|
||||
feedback = TextAreaField(u'', validators=[DataRequired(message="Can’t be empty")])
|
||||
|
||||
|
||||
class RequestToGoLiveForm(Form):
|
||||
usage = TextAreaField(
|
||||
'',
|
||||
validators=[DataRequired(message="Can’t be empty")]
|
||||
)
|
||||
|
||||
42
app/main/views/feedback.py
Normal file
42
app/main/views/feedback.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import markdown
|
||||
import requests
|
||||
from flask import render_template, url_for, redirect, flash, current_app, abort
|
||||
from app.main import main
|
||||
from flask_login import login_required
|
||||
from app.main.forms import Feedback
|
||||
|
||||
from flask.ext.login import current_user
|
||||
|
||||
|
||||
@main.route('/feedback', methods=['GET', 'POST'])
|
||||
def feedback():
|
||||
form = Feedback()
|
||||
if form.validate_on_submit():
|
||||
data = {
|
||||
'person_email': current_app.config.get('DESKPRO_PERSON_EMAIL'),
|
||||
'department_id': current_app.config.get('DESKPRO_TEAM_ID'),
|
||||
'subject': 'Notify feedback',
|
||||
'message': '{}\n{}\n{}'.format(
|
||||
form.name.data,
|
||||
form.email_address.data,
|
||||
form.feedback.data)
|
||||
}
|
||||
headers = {
|
||||
"X-DeskPRO-API-Key": current_app.config.get('DESKPRO_API_KEY'),
|
||||
'Content-Type': "application/x-www-form-urlencoded"
|
||||
}
|
||||
resp = requests.post(
|
||||
current_app.config.get('DESKPRO_API_HOST') + '/api/tickets',
|
||||
data=data,
|
||||
headers=headers)
|
||||
if resp.status_code != 201:
|
||||
current_app.logger.error(
|
||||
"Deskpro create ticket request failed with {} '{}'".format(
|
||||
resp.status_code,
|
||||
resp.json())
|
||||
)
|
||||
abort(500, "Feedback submission failed")
|
||||
flash("Your feedback has been submitted")
|
||||
return redirect(url_for('.feedback'))
|
||||
|
||||
return render_template('views/feedback.html', form=form)
|
||||
@@ -1,11 +1,8 @@
|
||||
import markdown
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from flask import (render_template, url_for, redirect, Markup, flash, current_app, abort)
|
||||
from flask import (render_template, url_for, redirect, Markup, current_app, abort)
|
||||
from app.main import main
|
||||
from flask_login import login_required
|
||||
from app.main.forms import Feedback
|
||||
|
||||
from flask.ext.login import current_user
|
||||
from mdx_gfm import GithubFlavoredMarkdownExtension
|
||||
@@ -44,40 +41,6 @@ def terms():
|
||||
return render_template('views/terms-of-use.html')
|
||||
|
||||
|
||||
@main.route('/feedback', methods=['GET', 'POST'])
|
||||
def feedback():
|
||||
form = Feedback()
|
||||
if form.validate_on_submit():
|
||||
data = {
|
||||
'person_email': current_app.config.get('DESKPRO_PERSON_EMAIL'),
|
||||
'department_id': current_app.config.get('DESKPRO_TEAM_ID'),
|
||||
'subject': 'Notify feedback',
|
||||
'message': '{}\n{}\n{}'.format(
|
||||
form.name.data,
|
||||
form.email_address.data,
|
||||
form.feedback.data)
|
||||
}
|
||||
headers = {
|
||||
"X-DeskPRO-API-Key": current_app.config.get('DESKPRO_API_KEY'),
|
||||
'Content-Type': "application/x-www-form-urlencoded"
|
||||
}
|
||||
resp = requests.post(
|
||||
current_app.config.get('DESKPRO_API_HOST') + '/api/tickets',
|
||||
data=data,
|
||||
headers=headers)
|
||||
if resp.status_code != 201:
|
||||
current_app.logger.error(
|
||||
"Deskpro create ticket request failed with {} '{}'".format(
|
||||
resp.status_code,
|
||||
resp.json())
|
||||
)
|
||||
abort(500, "Feedback submission failed")
|
||||
flash("Your feedback has been submitted")
|
||||
return redirect(url_for('.feedback'))
|
||||
|
||||
return render_template('views/feedback.html', form=form)
|
||||
|
||||
|
||||
@main.route('/documentation')
|
||||
def documentation():
|
||||
curr_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import requests
|
||||
from flask import (
|
||||
render_template,
|
||||
redirect,
|
||||
request,
|
||||
url_for,
|
||||
session,
|
||||
flash
|
||||
flash,
|
||||
abort,
|
||||
current_app
|
||||
)
|
||||
|
||||
from flask_login import (
|
||||
@@ -16,7 +19,7 @@ from notifications_python_client.errors import HTTPError
|
||||
from app import service_api_client
|
||||
from app.main import main
|
||||
from app.utils import user_has_permissions, email_safe
|
||||
from app.main.forms import ConfirmPasswordForm, ServiceNameForm
|
||||
from app.main.forms import ConfirmPasswordForm, ServiceNameForm, RequestToGoLiveForm
|
||||
from app import user_api_client
|
||||
from app import current_service
|
||||
|
||||
@@ -86,15 +89,45 @@ def service_name_change_confirm(service_id):
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
def service_request_to_go_live(service_id):
|
||||
if request.method == 'GET':
|
||||
return render_template(
|
||||
'views/service-settings/request-to-go-live.html'
|
||||
|
||||
form = RequestToGoLiveForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
|
||||
data = {
|
||||
'person_email': current_app.config.get('DESKPRO_PERSON_EMAIL'),
|
||||
'department_id': current_app.config.get('DESKPRO_TEAM_ID'),
|
||||
'subject': 'Request to go live',
|
||||
'message': "From {} <{}> on behalf of {} ({})\n\nUsage estimate\n---\n\n{}".format(
|
||||
current_user.name,
|
||||
current_user.email_address,
|
||||
current_service['name'],
|
||||
current_service['id'],
|
||||
form.usage.data
|
||||
)
|
||||
}
|
||||
headers = {
|
||||
"X-DeskPRO-API-Key": current_app.config.get('DESKPRO_API_KEY'),
|
||||
'Content-Type': "application/x-www-form-urlencoded"
|
||||
}
|
||||
resp = requests.post(
|
||||
current_app.config.get('DESKPRO_API_HOST') + '/api/tickets',
|
||||
data=data,
|
||||
headers=headers
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
flash('Thanks your request to go live is being processed', 'default')
|
||||
# TODO implement whatever this action would do in the real world
|
||||
if resp.status_code != 201:
|
||||
current_app.logger.error(
|
||||
"Deskpro create ticket request failed with {} '{}'".format(
|
||||
resp.status_code,
|
||||
resp.json())
|
||||
)
|
||||
abort(500, "Request to go live submission failed")
|
||||
|
||||
flash('We’ve received your request to go live', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
return render_template('views/service-settings/request-to-go-live.html', form=form)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/switch-live")
|
||||
@login_required
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{% macro textbox(
|
||||
field,
|
||||
label=None,
|
||||
hint=False,
|
||||
highlight_tags=False,
|
||||
autofocus=False,
|
||||
@@ -12,7 +13,11 @@
|
||||
) %}
|
||||
<div class="form-group{% if field.errors %} error{% endif %}" {% if autofocus %}data-module="autofocus"{% endif %}>
|
||||
<label class="form-label" for="{{ field.name }}">
|
||||
{{ field.label }}
|
||||
{% if label %}
|
||||
{{ label }}
|
||||
{% else %}
|
||||
{{ field.label }}
|
||||
{% endif %}
|
||||
{% if hint %}
|
||||
<span class="form-hint">
|
||||
{{ hint }}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
'link': url_for('.service_name_change', service_id=current_service.id)
|
||||
},
|
||||
{
|
||||
'title': 'Request to go live and turn off sending restrictions',
|
||||
'title': 'Request to go live and turn off trial mode',
|
||||
'link': url_for('.service_request_to_go_live', service_id=current_service.id),
|
||||
'hint': 'A live service can send notifications to any phone number or email address',
|
||||
} if current_service.restricted else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block page_title %}
|
||||
@@ -10,17 +11,54 @@
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
|
||||
<h1 class="heading-large">Request to go live</h1>
|
||||
<h1 class="heading-large">Request to go live</h1>
|
||||
|
||||
<p>GOV.UK Notify is invite-only during the beta.</p>
|
||||
<p>
|
||||
You’ll need to:
|
||||
</p>
|
||||
<ul class="list list-bullet">
|
||||
<li>
|
||||
agree to our <a href="{{ url_for('.terms') }}">terms of use</a>
|
||||
</li>
|
||||
<li>
|
||||
agree to pay for what you use if you send more than 250,000 text messages per year
|
||||
(<a href="{{ url_for("main.pricing") }}">see our pricing</a>)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p><a href="{{ url_for('main.feedback') }}">Contact us</a> to request an invite:</p>
|
||||
<form method="post">
|
||||
|
||||
<ul class="list list-bullet">
|
||||
<li>You’ll need to agree to our terms of use</li>
|
||||
<li>If you plan to send more than 250,000 text messages per year, you’ll need to agree to pay for what you use – take a look at our <a href="{{ url_for("main.pricing") }}">pricing</a></li>
|
||||
<li>We’ll check your templates to make sure they’re consistent with our design patterns, style guide and information security principles</li>
|
||||
</ul>
|
||||
{{ textbox(
|
||||
form.usage,
|
||||
label='Estimate how many emails and/or text messages you’ll send each month',
|
||||
hint='If your estimate is likely to change, tell us how ',
|
||||
width='1-1',
|
||||
rows=5
|
||||
) }}
|
||||
|
||||
<p>
|
||||
We will:
|
||||
</p>
|
||||
<ul class="list list-bullet">
|
||||
<li>
|
||||
check that your templates follow our
|
||||
<a href="https://designpatterns.hackpad.com/Notifications-5vuitmNqIjZ" rel="external">design patterns</a>,
|
||||
<a href="https://www.gov.uk/topic/government-digital-guidance/content-publishing" rel="external">style guide</a>
|
||||
and
|
||||
<a href="https://docs.google.com/document/d/15-OjaEqDBy31uDU7nLZCpYIQOnzSCJR63-cp3cQI9G8" rel="external">information security guidelines</a>
|
||||
</li>
|
||||
<li>
|
||||
check that you have more than one
|
||||
<a href="{{ url_for('main.manage_users', service_id=current_service.id) }}">team member</a>
|
||||
in case you go on holiday
|
||||
</li>
|
||||
<li>
|
||||
make your service live or get back to you within one working day
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{{ page_footer('Request to go live') }}
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user