Files
notifications-admin/app/main/views/feedback.py
Chris Hill-Scott 45241d6232 Put a form on the request to go live page
This commit:
- moves things around a bit on the request to go live page
- sticks a textbox in there

So when someone click the big green button, we will get a support ticket
that looks something like:
```
From Test User <test@user.gov.uk> on behalf of Test Service
(6ce466d0-fd6a-11e5-82f5-e0accb9d11a6)

---

We’ll send about 1000 text messages in the first month, and then 10,000
text messages per month after that. Usage of our service is about 50%
higher in March, at the end of the tax year.
```
2016-04-26 14:45:50 +01:00

43 lines
1.5 KiB
Python

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)