Merge branch 'master' into platform-admin

Conflicts:
	app/__init__.py
	app/main/views/add_service.py
	app/main/views/jobs.py
	app/templates/main_nav.html
	tests/app/main/views/test_dashboard.py
	tests/conftest.py
This commit is contained in:
Rebecca Law
2016-03-18 16:32:10 +00:00
66 changed files with 1356 additions and 597 deletions

View File

@@ -24,6 +24,10 @@
{% endblock %}
{% block cookie_message %}
<p>
GOV.UK Notify uses cookies to make the site simpler.
<a href="{{ url_for("main.cookies") }}">Find out more about cookies</a>
</p>
{% endblock %}
{% block inside_header %}
@@ -68,6 +72,15 @@
</div>
{% endblock %}
{% block footer_support_links %}
<nav class="footer-nav">
<a href="{{ url_for("main.help") }}">Help</a>
<a href="https://docs.google.com/forms/d/1AL8U-xJX_HAFEiQiJszGQw0PcEaEUnYATSntEghNDGo/viewform">Support and feedback</a>
<a href="{{ url_for("main.cookies") }}">Cookies</a>
Built by the <a href="https://www.gov.uk/government/organisations/government-digital-service">Government Digital Service</a>
</nav>
{% endblock %}
{% block body_end %}
<script type="text/javascript" src="{{ asset_url('javascripts/all.js') }}" /></script>
{% endblock %}

View File

@@ -1,19 +1,9 @@
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None) %}
<div class='banner{% if type %}-{{ type }}{% endif %}{% if with_tick %}-with-tick{% endif %}'>
{% if subhead %}
<div class="grid-row">
<div class="column-one-third">
{{ subhead }}
</div>
<div class="column-two-thirds">
{% endif %}
{% if subhead -%}
{{ subhead }}&ensp;
{%- endif -%}
{{ body }}
{% if subhead %}
</div>
</div>
{% endif %}
{% if delete_button %}
<form method='post'>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />

View File

@@ -4,3 +4,14 @@
<span class="big-number-label">{{ label }}</span>
</div>
{% endmacro %}
{% macro big_number_with_status(number, label, status_number, status_label, percentage_bad=0) %}
<div class="big-number-with-status">
{{ big_number(number, label) }}
<div class="big-number-status">
<div class="big-number-status-error-percentage" style="opacity: {{ percentage_bad / 100 }}"></div>
{{ big_number(status_number, status_label) }}
</div>
</div>
{% endmacro %}

View File

@@ -0,0 +1,22 @@
{% macro previous_next_navigation(previous_page, next_page) %}
<nav class="govuk-previous-and-next-navigation" role="navigation" aria-label="Pagination">
<ul class="group">
{% if previous_page %}
<li class="previous-page">
<a href="{{previous_page['url']}}" rel="previous" >
<span class="pagination-part-title">{{previous_page['title']}}</span>
<span class="pagination-label">{{previous_page['label']}}</span>
</a>
</li>
{% endif %}
{% if next_page %}
<li class="next-page">
<a href="{{next_page['url']}}" rel="next">
<span class="pagination-part-title">{{next_page['title']}}</span>
<span class="pagination-label">{{next_page['label']}}</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endmacro %}

View File

@@ -4,7 +4,7 @@
{% if name %}
<h3 class="sms-message-name">
{% if edit_link %}
<a href="{{ edit_link }}">{{ name }}</a>
<a name="{{ name|linkable_name }}" href="{{ edit_link }}">{{ name }}</a>
{% else %}
{{ name }}
{% endif %}

View File

@@ -2,29 +2,34 @@
<h2 class="navigation-service-name">
<a href="{{ url_for('.service_dashboard', service_id=service_id) }}">{{ session.get('service_name', 'Service') }}</a>
</h2>
{% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %}
{% if current_user.has_permissions(['send_texts', 'send_emails', 'send_letters']) %}
<ul>
<li><a href="{{ url_for('.choose_template', service_id=service_id, template_type='sms') }}">Send text messages</a></li>
<li><a href="{{ url_for('.choose_template', service_id=service_id, template_type='email') }}">Send emails</a></li>
</ul>
{% elif current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %}
{% elif current_user.has_permissions(['manage_templates']) %}
<ul>
<li><a href="{{ url_for('.choose_template', service_id=service_id, template_type='sms') }}">Text message templates</a></li>
<li><a href="{{ url_for('.choose_template', service_id=service_id, template_type='email') }}">Email templates</a></li>
</ul>
{% endif %}
{% if current_user.has_permissions(permissions=['manage_users', 'manage_settings'], admin_override=True) %}
{% if current_user.has_permissions(['manage_users', 'manage_settings']) %}
<ul>
<li><a href="{{ url_for('.manage_users', service_id=service_id) }}">Manage team</a></li>
<li><a href="{{ url_for('.service_settings', service_id=service_id) }}">Manage settings</a></li>
</ul>
{% endif %}
{% if current_user.has_permissions(permissions=['manage_api_keys', 'access_developer_docs']) %}
{% if current_user.has_permissions(['manage_api_keys', 'access_developer_docs']) %}
<ul>
<li><a href="{{ url_for('.api_keys', service_id=service_id) }}">API keys</a></li>
<li><a href="{{ url_for('.documentation', service_id=service_id) }}">Developer documentation</a></li>
</ul>
{% endif %}
<ul>
<li><a href="{{ url_for('.view_notifications', service_id=service_id) }}">Notification history</a></li>
<li><a href="{{ url_for('.view_jobs', service_id=service_id) }}">Job history</a><li>
</ul>
{% if current_user.has_permissions(admin_override=True) %}
<ul>
<li><a href="{{ url_for('.show_all_services') }}"> List all services </a></li>

View File

@@ -37,9 +37,9 @@
{% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters'], or_=True) %}
{{ banner(
"""
Send yourself a test message
Send yourself a test
""",
subhead='Next step',
subhead='Next step:',
type="tip"
)}}
{% endif %}

View File

@@ -0,0 +1,81 @@
{% extends "withoutnav_template.html" %}
{% block page_title %}
Cookies GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-two-thirds">
<h1 class="heading-xlarge">Cookies</h1>
<p class="summary">
GOV.UK Notify puts small files (known as cookies)
on to your computer.
</p>
<p>These cookies are used to remember you once youve logged in</p>
<p>
Find out <a href="http://www.aboutcookies.org/">how to manage cookies</a>.
</p>
<h2 class="heading-medium">Session cookies</h2>
<p>
We store session cookies on your computer to help keep your information
secure while you use the service.
</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Purpose</th>
<th>Expires</th>
</tr>
</thead>
<tbody>
<tr>
<td>
notify_admin_session
</td>
<td width="50%">
Used to keep you logged in
</td>
<td>
1 hour
</td>
</tr>
</tbody>
</table>
<h2 class="heading-medium">Introductory message cookie</h2>
<p>
When you first use the service, you may see a pop-up welcome message.
Once youve seen the message, we store a cookie on your computer so it
knows not to show it again.
</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Purpose</th>
<th>Expires</th>
</tr>
</thead>
<tbody>
<tr>
<td>
seen_cookie_message
</td>
<td width="50%">
Saves a message to let us know that you have seen our cookie
message
</td>
<td>
1 month
</td>
</tr>
</tbody>
</table>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,20 @@
{% extends "withnav_template.html" %}
{% block page_title %}
{{ session.get('service_name', 'Dashboard') }} GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
{% if service.restricted %}
{% include 'views/dashboard/trial-mode-banner.html' %}
{% endif %}
{% if not jobs %}
{% include 'views/dashboard/get-started.html' %}
{% else %}
{% include 'views/dashboard/today.html' %}
{% include 'views/dashboard/jobs.html' %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,19 @@
{% from "components/banner.html" import banner_wrapper %}
<h2 class="heading-medium">Get started</h2>
<ol class="grid-row">
{% if current_user.has_permissions(['manage_templates']) %}
<li class="column-half">
{% call banner_wrapper(type="tip", subhead='1.' if not templates else None, with_tick=templates|length) %}
<a href='{{ url_for(".add_service_template", service_id=service_id, template_type="sms") }}'>Add a template</a>
{% endcall %}
</li>
{% endif %}
{% if current_user.has_permissions(['send_texts', 'send_emails', 'send_letters']) %}
<li class="column-half">
{% call banner_wrapper(type="tip", subhead='2.') %}
<a href='{{ url_for(".choose_template", service_id=service_id, template_type="sms") }}'>Send yourself a message</a>
{% endcall %}
</li>
{% endif %}
</ol>

View File

@@ -0,0 +1,28 @@
{% from "components/table.html" import list_table, field, right_aligned_field_heading, hidden_field_heading %}
{% call(item) list_table(
jobs,
caption="Recent batch jobs",
empty_message='You havent sent any text messages yet',
field_headings=['File', 'Started', right_aligned_field_heading('Rows'), right_aligned_field_heading('Sent')]
) %}
{% call field() %}
<a href="{{ url_for('.view_job', service_id=service_id, job_id=item.id) }}">{{ item.original_file_name }}</a>
{% endcall %}
{% call field() %}
{{ item.created_at|format_datetime }}
{% endcall %}
{% call field(align='right') %}
{{ item.notification_count }}
{% endcall %}
{% call field(align='right') %}
{{ item.notifications_sent }}
{% endcall %}
{% endcall %}
{% if more_jobs_to_show %}
{% if current_user.has_permissions(['send_texts', 'send_emails', 'send_letters']) %}
<p class="table-show-more-link">
<a href="{{ url_for('.view_jobs', service_id=service_id) }}">See all sent text messages</a>
</p>
{% endif %}
{% endif %}

View File

@@ -0,0 +1,25 @@
{% from "components/big-number.html" import big_number_with_status %}
<h2 class="heading-medium">
Sent today
</h2>
<div class="grid-row">
<div class="column-half">
{{ big_number_with_status(
statistics.get('emails_requested', 0),
'email' if statistics.get('emails_requested') == 1 else 'emails',
'{}%'.format(statistics.get('emails_failure_rate', 0)),
'failed',
statistics.get('emails_percentage_of_danger_zone', 0)
) }}
</div>
<div class="column-half">
{{ big_number_with_status(
statistics.get('sms_requested', 0),
'text message' if statistics.get('sms_requested') == 1 else 'text messages',
'{}%'.format(statistics.get('sms_failure_rate', 0)),
'failed',
statistics.get('sms_percentage_of_danger_zone', 0)
) }}
</div>
</div>

View File

@@ -0,0 +1,25 @@
{% from "components/banner.html" import banner_wrapper %}
{% from "components/big-number.html" import big_number %}
{% call banner_wrapper(type="mode") %}
<h2 class="heading-medium">Trial mode</h2>
<div class="grid-row">
<div class="column-one-half">
<p>
Well only deliver messages to you and members of your team
<br>
<a href="{{ url_for(".help", _anchor="trial-mode") }}">Find out more</a>
</p>
</div>
<div class="column-one-sixth">
&nbsp;
</div>
<div class="column-one-third">
{{ big_number(
service.limit - statistics.get('emails_requested', 0) - statistics.get('sms_requested', 0),
'messages left today'
) }}
</div>
</div>
{% endcall %}

View File

@@ -1,24 +0,0 @@
{% extends "withoutnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}
{% block page_title %}
Check your email address GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-two-thirds">
<h1 class="heading-large">Check your email address</h1>
<p>Check your email address is correct and then resend the confirmation code.</p>
<form autocomplete="off" method="post">
{{ textbox(form.email_address, hint='Your email address must end in .gov.uk') }}
{{ page_footer('Resend confirmation code') }}
</form>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,79 @@
{% extends "withoutnav_template.html" %}
{% block page_title %}
Cookies GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-two-thirds">
<h1 class="heading-xlarge">Help</h1>
<h2 class="heading-large" id="trial-mode">Trial mode</h2>
<p>
When you create a service on GOV.UK&nbsp;Notify, you start off in trial
mode. This means:
</p>
<ul class="list list-bullet">
<li>
you can only send messages to yourself and your team members
</li>
<li>
you can only send 50 messages per day
</li>
</ul>
<p>
Anyone working in central government can create an account on
GOV.UK&nbsp;Notify and try it out. So its important that you start off
with some restrictions in place.
</p>
<h3 class="heading-medium">To remove these restrictions</h3>
<p>
You need to request to go live:
</p>
<ul class="list list-bullet">
<li>
Youll need to agree to our terms of use
</li>
<li>
If you plan to send more than 250,000 text messages per year, youll
need to agree to pay for what you use take a look at our pricing
</li>
<li>
Well check your templates to make sure theyre consistent with our
design patterns, style guide and information security principles
</li>
</ul>
<h3 class="heading-medium">
All other aspects of GOV.UK&nbsp;Notify are exactly the same
</h2>
<p>
You can still:
</p>
<ul class="list list-bullet">
<li>
upload a batch of recipients
</li>
<li>
do an API integration
</li>
</ul>
<p>
Well send the messages you have permission to send. The messages you
dont have permission to send will still be listed on your
GOV.UK&nbsp;Notify dashboard but wont actually get sent. This means you
can check that everything is fully working without accidentally sending
hundreds of text messages or emails.
</p>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,42 @@
{% extends "withnav_template.html" %}
{% from "components/table.html" import list_table, field, right_aligned_field_heading %}
{% from "components/previous-next-navigation.html" import previous_next_navigation %}
{% block page_title %}
Notifications activity GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Notifications activity</h1>
{% call(item) list_table(
notifications,
caption="Recent activity",
caption_visible=False,
empty_message='You havent sent any notifications yet',
field_headings=['Recipient', 'Template', 'Type', 'Job', 'Status', 'Time'])
%}
{% call field() %}
{{ item.to }}
{% endcall %}
{% call field() %}
<a href="{{ url_for(".choose_template", service_id=service_id, template_type=item.template.template_type, _anchor=item.template.name|linkable_name) }}">{{ item.template.name }}</a>
{% endcall %}
{% call field() %}
{{ item.template.template_type }}
{% endcall %}
{% call field() %}
{% if item.job %}
<a href="{{ url_for(".view_job", service_id=service_id, job_id=item.job.id) }}">{{ item.job.original_file_name }}</a>
{% endif %}
{% endcall %}
{% call field() %}
{{ item.status }}
{% endcall %}
{% call field() %}
{{ item.created_at | format_datetime}}
{% endcall %}
{% endcall %}
{{ previous_next_navigation(prev_page, next_page) }}
{% endblock %}

View File

@@ -0,0 +1,16 @@
{% extends "withoutnav_template.html" %}
{% block page_title %}
Check your email GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-two-thirds">
<h1 class="heading-large">Now check your email</h1>
<p>Click the link in the email weve sent you to continue your registration</p>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,18 @@
{% extends "withoutnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}
{% block page_title %}
Check your email GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-two-thirds">
<h1 class="heading-large">Check your email</h1>
<p>In order to verify your email address we've sent a new confirmation link to {{email}}</p>
</div>
</div>
{% endblock %}

View File

@@ -65,7 +65,7 @@
{% if more_jobs_to_show %}
{% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %}
<p class="table-show-more-link">
<a href="{{ url_for('.view_jobs', service_id=service_id) }}">See all sent text messages</a>
<a href="{{ url_for('.view_notifications', service_id=service_id) }}">See all sent text messages</a>
</p>
{% endif %}
{% endif %}

View File

@@ -1,53 +0,0 @@
{% extends "withoutnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}
{% block page_title %}
{% if form.email_code %}
Enter the codes weve sent you GOV.UK Notify
{% else %}
Enter the code weve sent you GOV.UK Notify
{% endif %}
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-two-thirds">
{% if form.email_code %}
<h1 class="heading-large">Enter the codes weve sent you</h1>
{% else %}
<h1 class="heading-large">Enter the code weve sent you</h1>
{% endif %}
{% if form.email_code %}
<p>
Weve sent you confirmation codes by email and text message.
</p>
{% else %}
<p>
Weve sent you a confirmation code by text message.
</p>
{% endif %}
<form autocomplete="off" method="post">
{% if form.sms_code %}
{{ textbox(
form.sms_code,
width='5em',
help_link=url_for('.check_and_resend_text_code'),
help_link_text='I havent received a text message'
) }}
{% endif %}
{% if form.email_code %}
{{ textbox(
form.email_code,
width='5em',
help_link=url_for('.check_and_resend_email_code'),
help_link_text='I havent received an email'
) }}
{% endif %}
{{ page_footer("Continue") }}
</form>
</div>
</div>
{% endblock %}