Work in progress, all tests passing and implemented mocks for services_dao.

This commit is contained in:
Nicholas Staples
2016-01-15 17:46:09 +00:00
parent 262bbbac45
commit 4e2019c949
40 changed files with 189 additions and 164 deletions

View File

@@ -8,11 +8,11 @@ from app.main.forms import AddServiceForm
@main.route("/add-service", methods=['GET', 'POST'])
@login_required
def add_service():
# TODO fix up this
# TODO fix up this
form = AddServiceForm(services_dao.find_all_service_names)
if form.validate_on_submit():
user = users_dao.get_user_by_id(session['user_id'])
services_dao.insert_new_service(form.service_name.data, user)
return redirect(url_for('.dashboard', service_id=123))
service_id = services_dao.insert_new_service(form.service_name.data, user)
return redirect(url_for('main.service_dashboard', service_id=service_id))
else:
return render_template('views/add-service.html', form=form)

View File

@@ -8,7 +8,7 @@ from ._jobs import jobs
@main.route("/services/<int:service_id>/dashboard")
@login_required
def dashboard(service_id):
def service_dashboard(service_id):
try:
service = get_service_by_id(service_id)
except HTTPError as e:
@@ -17,7 +17,7 @@ def dashboard(service_id):
else:
raise e
return render_template(
'views/dashboard.html',
'views/service_dashboard.html',
jobs=jobs,
free_text_messages_remaining=560,
spent_this_month='0.00',

View File

@@ -10,31 +10,31 @@ def index():
@main.route("/register-from-invite")
@login_required
def registerfrominvite():
def register_from_invite():
return render_template('views/register-from-invite.html')
@main.route("/verify-mobile")
@login_required
def verifymobile():
def verify_mobile():
return render_template('views/verify-mobile.html')
@main.route("/services/<int:service_id>/send-email")
@login_required
def sendemail(service_id):
def send_email(service_id):
return render_template('views/send-email.html')
@main.route("/services/<int:service_id>/check-email")
@login_required
def checkemail(service_id):
def check_email(service_id):
return render_template('views/check-email.html')
@main.route("/services/<int:service_id>/manage-users")
@login_required
def manageusers(service_id):
def manage_users(service_id):
return render_template('views/manage-users.html', service_id=service_id)

View File

@@ -47,7 +47,7 @@ messages = [
@main.route("/services/<int:service_id>/jobs")
@login_required
def showjobs(service_id):
def view_jobs(service_id):
return render_template(
'views/jobs.html',
jobs=jobs,
@@ -57,7 +57,7 @@ def showjobs(service_id):
@main.route("/services/<int:service_id>/jobs/<job_id>")
@login_required
def showjob(service_id, job_id):
def view_job(service_id, job_id):
# TODO the uploaded file name could be part of job definition
# so won't need to be passed on from last view via session
@@ -86,7 +86,7 @@ def showjob(service_id, job_id):
@main.route("/services/<int:service_id>/jobs/<job_id>/notification/<string:notification_id>")
@login_required
def shownotification(service_id, job_id, notification_id):
def view_notification(service_id, job_id, notification_id):
return render_template(
'views/notification.html',
message=[

View File

@@ -128,4 +128,4 @@ def confirm_delete(service_id):
service_id=service_id
)
elif request.method == 'POST':
return redirect(url_for('.dashboard', service_id=service_id))
return redirect(url_for('.service_dashboard', service_id=service_id))

View File

@@ -43,7 +43,7 @@ message_templates = [
@main.route("/services/<int:service_id>/sms/send", methods=['GET', 'POST'])
@login_required
def sendsms(service_id):
def send_sms(service_id):
form = CsvUploadForm()
if form.validate_on_submit():
try:
@@ -53,7 +53,7 @@ def sendsms(service_id):
filename)
csv_file.save(filepath)
_check_file(csv_file.filename, filepath)
return redirect(url_for('.checksms',
return redirect(url_for('.check_sms',
service_id=service_id,
recipients=filename))
except (IOError, ValueError) as e:
@@ -63,7 +63,7 @@ def sendsms(service_id):
if isinstance(e, ValueError):
flash(str(e))
os.remove(filepath)
return redirect(url_for('.sendsms', service_id=service_id))
return redirect(url_for('.send_sms', service_id=service_id))
return render_template('views/send-sms.html',
message_templates=message_templates,
@@ -73,7 +73,7 @@ def sendsms(service_id):
@main.route("/services/<int:service_id>/sms/check", methods=['GET', 'POST'])
@login_required
def checksms(service_id):
def check_sms(service_id):
if request.method == 'GET':
filename = request.args.get('recipients')
if not filename:
@@ -100,10 +100,10 @@ def checksms(service_id):
# TODO when job is created record filename in job itself
# so downstream pages can get the original filename that way
session[upload_id] = filename
return redirect(url_for('main.showjob', service_id=service_id, job_id=upload_id))
return redirect(url_for('main.view_job', service_id=service_id, job_id=upload_id))
except:
flash('There as a problem saving the file')
return redirect(url_for('.checksms', recipients=filename))
return redirect(url_for('.check_sms', recipients=filename))
def _check_file(filename, filepath):

View File

@@ -8,12 +8,12 @@ from app.main.forms import (
@main.route("/user-profile")
def userprofile():
def user_profile():
return render_template('views/user-profile.html')
@main.route("/user-profile/name", methods=['GET', 'POST'])
def userprofile_name():
def user_profile_name():
form = ChangeNameForm()
@@ -26,11 +26,11 @@ def userprofile_name():
form_field=form.new_name
)
elif request.method == 'POST':
return redirect(url_for('.userprofile'))
return redirect(url_for('.user_profile'))
@main.route("/user-profile/email", methods=['GET', 'POST'])
def userprofile_email():
def user_profile_email():
form = ChangeEmailForm()
@@ -43,11 +43,11 @@ def userprofile_email():
form_field=form.email_address
)
elif request.method == 'POST':
return redirect(url_for('.userprofile_email_authenticate'))
return redirect(url_for('.user_profile_email_authenticate'))
@main.route("/user-profile/email/authenticate", methods=['GET', 'POST'])
def userprofile_email_authenticate():
def user_profile_email_authenticate():
form = ConfirmPasswordForm()
@@ -56,14 +56,14 @@ def userprofile_email_authenticate():
'views/user-profile/authenticate.html',
thing='email address',
form=form,
back_link=url_for('.userprofile_email')
back_link=url_for('.user_profile_email')
)
elif request.method == 'POST':
return redirect(url_for('.userprofile_email_confirm'))
return redirect(url_for('.user_profile_email_confirm'))
@main.route("/user-profile/email/confirm", methods=['GET', 'POST'])
def userprofile_email_confirm():
def user_profile_email_confirm():
form = ConfirmEmailForm()
@@ -74,11 +74,11 @@ def userprofile_email_confirm():
thing='email address'
)
elif request.method == 'POST':
return redirect(url_for('.userprofile'))
return redirect(url_for('.user_profile'))
@main.route("/user-profile/mobile-number", methods=['GET', 'POST'])
def userprofile_mobile_number():
def user_profile_mobile_number():
form = ChangeMobileNumberForm()
@@ -91,11 +91,11 @@ def userprofile_mobile_number():
form_field=form.mobile_number
)
elif request.method == 'POST':
return redirect(url_for('.userprofile_mobile_number_authenticate'))
return redirect(url_for('.user_profile_mobile_number_authenticate'))
@main.route("/user-profile/mobile-number/authenticate", methods=['GET', 'POST'])
def userprofile_mobile_number_authenticate():
def user_profile_mobile_number_authenticate():
form = ConfirmPasswordForm()
@@ -104,14 +104,14 @@ def userprofile_mobile_number_authenticate():
'views/user-profile/authenticate.html',
thing='mobile number',
form=form,
back_link=url_for('.userprofile_mobile_number_confirm')
back_link=url_for('.user_profile_mobile_number_confirm')
)
elif request.method == 'POST':
return redirect(url_for('.userprofile_mobile_number_confirm'))
return redirect(url_for('.user_profile_mobile_number_confirm'))
@main.route("/user-profile/mobile-number/confirm", methods=['GET', 'POST'])
def userprofile_mobile_number_confirm():
def user_profile_mobile_number_confirm():
form = ConfirmMobileNumberForm()
@@ -122,11 +122,11 @@ def userprofile_mobile_number_confirm():
thing='mobile number'
)
elif request.method == 'POST':
return redirect(url_for('.userprofile'))
return redirect(url_for('.user_profile'))
@main.route("/user-profile/password", methods=['GET', 'POST'])
def userprofile_password():
def user_profile_password():
form = ChangePasswordForm()
@@ -136,4 +136,4 @@ def userprofile_password():
form=form
)
elif request.method == 'POST':
return redirect(url_for('.userprofile'))
return redirect(url_for('.user_profile'))

View File

@@ -42,7 +42,7 @@
{% if not current_user.is_authenticated() %}
{% set homepage_url = url_for('main.index') %}
{% else %}
{% set homepage_url = url_for('main.dashboard', service_id=123) %}
{% set homepage_url = url_for('main.choose_service') %}
{% endif %}
{% block content %}
@@ -60,7 +60,7 @@
</div>
</div>
<div class="column-half management-navigation-account">
<a href="{{ url_for('main.userprofile') }}">{{ current_user.name }}</a>
<a href="{{ url_for('main.user_profile') }}">{{ current_user.name }}</a>
<a href="{{ url_for('main.sign_out')}}">Sign out</a>
</div>
</div>

View File

@@ -1,17 +1,17 @@
<nav class="navigation">
<ul>
<li><a href="{{ url_for('.dashboard', service_id=123) }}">Dashboard</a></li>
<li><a href="{{ url_for('.service_dashboard', service_id=123) }}">Dashboard</a></li>
</ul>
<ul>
<li><a href="{{ url_for('.sendsms', service_id=123) }}">Send text messages</a></li>
<li><a href="{{ url_for('.sendemail', service_id=123) }}">Send emails</a></li>
<li><a href="{{ url_for('.showjobs', service_id=123) }}">Activity</a></li>
<li><a href="{{ url_for('.send_sms', service_id=123) }}">Send text messages</a></li>
<li><a href="{{ url_for('.send_email', service_id=123) }}">Send emails</a></li>
<li><a href="{{ url_for('.view_jobs', service_id=123) }}">Activity</a></li>
</ul>
<ul>
<li><a href="{{ url_for('.apikeys', service_id=123) }}">API keys and documentation</a></li>
</ul>
<ul>
<li><a href="{{ url_for('.manageusers', service_id=123) }}">Manage users</a></li>
<li><a href="{{ url_for('.manage_users', service_id=123) }}">Manage users</a></li>
<li><a href="{{ url_for('.service_settings', service_id=123) }}">Service settings</a></li>
</ul>
</nav>

View File

@@ -12,7 +12,7 @@ GOV.UK Notify | API keys and documentation
<p>Here's where developers can access information about the API and access keys</p>
{{ page_footer(
back_link=url_for('.dashboard', service_id=service_id),
back_link=url_for('.service_dashboard', service_id=service_id),
back_link_text='Back to dashboard'
) }}

View File

@@ -17,7 +17,7 @@
{% for rejected in upload_result.rejects %}
<p>Line {{rejected.line_number}}: {{rejected.phone }}</a>
{% endfor %}
<p><a href="{{url_for('.sendsms', service_id=service_id)}}" class="button">Go back and resolve errors</a></p>
<p><a href="{{url_for('.send_sms', service_id=service_id)}}" class="button">Go back and resolve errors</a></p>
{% else %}
@@ -26,7 +26,7 @@
{{ page_footer(
button_text = "Send {} text messages".format(upload_result.valid|count),
back_link = url_for(".sendsms", service_id=service_id)
back_link = url_for(".send_sms", service_id=service_id)
)}}
{% if upload_result.valid | count > 6 %}
@@ -56,7 +56,7 @@
{{ page_footer(
button_text = "Send {} text messages".format(upload_result.valid|count),
back_link = url_for(".sendsms", service_id=service_id)
back_link = url_for(".send_sms", service_id=service_id)
)}}
<input type='hidden' name='recipients' value='{{filename}}'>

View File

@@ -14,11 +14,11 @@
{{ browse_list([
{
'title': 'MOT Reminders',
'link': url_for('.dashboard', service_id=123)
'link': url_for('.service_dashboard', service_id=123)
},
{
'title': 'Vehicle Tax',
'link': url_for('.dashboard', service_id=123)
'link': url_for('.service_dashboard', service_id=123)
},
]) }}
{{ browse_list([

View File

@@ -15,7 +15,7 @@ GOV.UK Notify | Edit template
{{ textbox(form.template_body, highlight_tags=True) }}
{{ page_footer(
'Save and continue',
back_link=url_for('.dashboard', service_id=service_id),
back_link=url_for('.service_dashboard', service_id=service_id),
back_link_text='Back to manage templates'
) }}
</form>

View File

@@ -52,10 +52,10 @@ GOV.UK Notify | Notifications activity
]
) %}
{% call field() %}
<a href="{{ url_for('.shownotification', service_id=service_id, job_id=456, notification_id=item.id) }}">{{item.phone}}</a>
<a href="{{ url_for('.view_notification', service_id=service_id, job_id=456, notification_id=item.id) }}">{{item.phone}}</a>
{% endcall %}
{% call field() %}
<a href="{{ url_for('.shownotification', service_id=service_id, job_id=456, notification_id=item.id) }}">{{item.message[:50]}}…</a>
<a href="{{ url_for('.view_notification', service_id=service_id, job_id=456, notification_id=item.id) }}">{{item.message[:50]}}…</a>
{% endcall %}
{% call field(
align='right',

View File

@@ -16,10 +16,10 @@ GOV.UK Notify | Notifications activity
field_headings=['Job', 'File', 'Time', 'Status']
) %}
{% call field() %}
<a href="{{ url_for('.showjob', service_id=service_id, job_id=456) }}">{{ item.file }}</a>
<a href="{{ url_for('.view_job', service_id=service_id, job_id=456) }}">{{ item.file }}</a>
{% endcall %}
{% call field() %}
<a href="{{ url_for('.showjob', service_id=service_id, job_id=456) }}">{{ item.job }}</a>
<a href="{{ url_for('.view_job', service_id=service_id, job_id=456) }}">{{ item.job }}</a>
{% endcall %}
{% call field() %}
{{ item.time }}

View File

@@ -12,7 +12,7 @@ GOV.UK Notify | Manage users
<p>Here's where you can add or remove users of a service.</p>
{{ page_footer(
back_link = url_for('.dashboard', service_id=service_id),
back_link = url_for('.service_dashboard', service_id=service_id),
back_link_text = 'Back to dashboard'
) }}

View File

@@ -26,7 +26,7 @@ GOV.UK Notify | Notifications activity
</div>
{{ page_footer(
back_link = url_for('.showjob', service_id=service_id, job_id=job_id),
back_link = url_for('.view_job', service_id=service_id, job_id=job_id),
back_link_text = 'View other messages in this job'
) }}

View File

@@ -30,10 +30,10 @@
field_headings=['Job', 'File', 'Time', 'Status']
) %}
{% call field() %}
<a href="{{ url_for('.showjob', service_id=service_id, job_id=456) }}">{{ item.file }}</a>
<a href="{{ url_for('.view_job', service_id=service_id, job_id=456) }}">{{ item.file }}</a>
{% endcall %}
{% call field() %}
<a href="{{ url_for('.showjob', service_id=service_id, job_id=456) }}">{{ item.job }}</a>
<a href="{{ url_for('.view_job', service_id=service_id, job_id=456) }}">{{ item.job }}</a>
{% endcall %}
{% call field() %}
{{ item.time }}
@@ -43,7 +43,7 @@
{% endcall %}
{% endcall %}
<p>
<a href={{ url_for('.showjobs', service_id=service_id) }}>See all notifications activity</a>
<a href={{ url_for('.view_jobs', service_id=service_id) }}>See all notifications activity</a>
</p>

View File

@@ -11,10 +11,10 @@
{% call(item) list_table(
[
{'label': 'Name', 'value': current_user.name, 'url': url_for('.userprofile_name')},
{'label': 'Email address', 'value': current_user.email_address, 'url': url_for('.userprofile_email')},
{'label': 'Mobile number', 'value': current_user.mobile_number, 'url': url_for('.userprofile_mobile_number')},
{'label': 'Password', 'value': 'Last changed 1 January 2016, 10:00AM', 'url': url_for('.userprofile_password')},
{'label': 'Name', 'value': current_user.name, 'url': url_for('.user_profile_name')},
{'label': 'Email address', 'value': current_user.email_address, 'url': url_for('.user_profile_email')},
{'label': 'Mobile number', 'value': current_user.mobile_number, 'url': url_for('.user_profile_mobile_number')},
{'label': 'Password', 'value': 'Last changed 1 January 2016, 10:00AM', 'url': url_for('.user_profile_password')},
],
caption='Account settings',
field_headings=['Setting', 'Value', 'Link to change'],

View File

@@ -17,7 +17,7 @@ GOV.UK Notify | Service settings
{{ textbox(form.new_password) }}
{{ page_footer(
'Save',
back_link=url_for('.userprofile'),
back_link=url_for('.user_profile'),
back_link_text="Back to your profile"
) }}
</form>

View File

@@ -21,7 +21,7 @@ GOV.UK Notify | Service settings
{{ textbox(form_field) }}
{{ page_footer(
'Save',
back_link=url_for('.userprofile'),
back_link=url_for('.user_profile'),
back_link_text="Back to your profile"
) }}
</form>

View File

@@ -20,7 +20,7 @@ GOV.UK Notify | Service settings
{{ page_footer(
'Confirm',
destructive=destructive,
back_link=url_for('.userprofile')
back_link=url_for('.user_profile')
) }}
</form>
</div>