Merge pull request #150 from alphagov/send-text-flow-revised

Send text flow revised
This commit is contained in:
NIcholas Staples
2016-02-04 14:57:43 +00:00
31 changed files with 208 additions and 228 deletions

View File

@@ -217,7 +217,7 @@ class ChangePasswordForm(Form):
class CsvUploadForm(Form):
file = FileField('Upload a CSV file to add your recipients details', validators=[DataRequired(
file = FileField('Add recipients', validators=[DataRequired(
message='Please pick a file'), CsvFileValidator()])

View File

@@ -10,8 +10,8 @@ from app.main.forms import AddServiceForm
def add_service():
form = AddServiceForm(services_dao.find_all_service_names)
services = services_dao.get_services(current_user.id)
if len(services) == 0:
heading = 'Set up notifications for your service'
if len(services['data']) == 0:
heading = 'Which service do you want to set up notifications for?'
else:
heading = 'Add a new service'
if form.validate_on_submit():

View File

@@ -4,7 +4,7 @@ from app.main import main
from app.main.dao.services_dao import get_service_by_id
from app.main.dao import templates_dao
from client.errors import HTTPError
from ._jobs import jobs
from app import job_api_client
@main.route("/services/<service_id>/dashboard")
@@ -12,6 +12,7 @@ from ._jobs import jobs
def service_dashboard(service_id):
try:
templates = templates_dao.get_service_templates(service_id)['data']
jobs = job_api_client.get_job(service_id)['data']
except HTTPError as e:
if e.status_code == 404:
abort(404)
@@ -27,8 +28,8 @@ def service_dashboard(service_id):
raise e
return render_template(
'views/service_dashboard.html',
jobs=jobs,
free_text_messages_remaining='25,000',
jobs=list(reversed(jobs)),
free_text_messages_remaining='250,000',
spent_this_month='0.00',
template_count=len(templates),
service_id=str(service_id))

View File

@@ -11,6 +11,7 @@ from client.errors import HTTPError
from app import job_api_client
from app.main import main
from app.main.dao import templates_dao
now = time.strftime('%H:%M')
@@ -37,6 +38,7 @@ def view_jobs(service_id):
def view_job(service_id, job_id):
try:
job = job_api_client.get_job(service_id, job_id)['data']
template = templates_dao.get_service_template(service_id, job['template'])['data']
messages = []
return render_template(
'views/job.html',
@@ -53,8 +55,7 @@ def view_job(service_id, job_id):
cost=u'£0.00',
uploaded_file_name=job['original_file_name'],
uploaded_file_time=job['created_at'],
template_used=job['template'],
flash_message="Weve accepted {} for processing".format(job['original_file_name']),
template=template,
service_id=service_id
)
except HTTPError as e:

View File

@@ -32,13 +32,8 @@ from app.main.utils import (
)
@main.route("/services/<service_id>/sms/send", methods=['GET', 'POST'])
@main.route("/services/<service_id>/sms/send", methods=['GET'])
def choose_sms_template(service_id):
if request.method == 'POST':
return redirect(url_for('.send_sms',
service_id=service_id,
template_id=request.form.get('template')))
try:
templates = templates_dao.get_service_templates(service_id)['data']
except HTTPError as e:
@@ -103,6 +98,7 @@ def check_sms(service_id, upload_id):
'views/check-sms.html',
upload_result=upload_result,
message_template=template['content'],
original_file_name=original_file_name,
template_id=template_id,
service_id=service_id
)

View File

@@ -3,6 +3,7 @@ from flask_login import login_required
from app.main import main
from app.main.forms import TemplateForm
from app import job_api_client
from app.main.dao.services_dao import get_service_by_id
from app.main.dao import templates_dao as tdao
from app.main.dao import services_dao as sdao
@@ -13,6 +14,7 @@ from client.errors import HTTPError
@login_required
def manage_service_templates(service_id):
try:
jobs = job_api_client.get_job(service_id)['data']
templates = tdao.get_service_templates(service_id)['data']
except HTTPError as e:
if e.status_code == 404:
@@ -22,6 +24,7 @@ def manage_service_templates(service_id):
return render_template(
'views/manage-templates.html',
service_id=service_id,
has_jobs=bool(jobs),
templates=[tdao.TemplatesBrowsableItem(x) for x in templates])