Use Flask for routing

This commit:
- replaces links that look like buttons with forms and submit buttons
- splits the view code for SMS into its own file
- moves the routing into the Python by adding handling for `post` requests
- uses Flask’s `url_for` to generate URLs, rather than hard coding them (so that
  it’s easier to change the URLs)
- chages the URLs for sending text messages
This commit is contained in:
Chris Hill-Scott
2015-12-10 21:15:20 +00:00
parent dbc55e76b0
commit 8a34fa7e0a
6 changed files with 105 additions and 90 deletions

View File

@@ -17,7 +17,10 @@
{{ sms_message(message_template) }}
<p>
<a class="button" href="/jobs/job" role="button">Send {{recipients|length}} text messages</a>
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="button" value="Send {{recipients|length}} text messages" />
</form>
</p>
</div>
</div>

View File

@@ -11,14 +11,14 @@ GOV.UK Notify | Dashboard
<h1 class="heading-xlarge">Dashboard</h1>
<ul>
<li><a href="send-sms">Send text messages</a></li>
<li><a href="send-email">Send email messages</a></li>
<li><a href="jobs">View notifications activity</a></li>
<li><a href="user-profile">User profile</a></li>
<li><a href="manage-users">Manage users</a></li>
<li><a href="manage-templates">Manage templates</a></li>
<li><a href="service-settings">Service settings</a></li>
<li><a href="api-keys">API keys and documentation</a></li>
<li><a href="{{ url_for('.sendsms') }}">Send text messages</a></li>
<li><a href="{{ url_for('.sendemail') }}">Send email messages</a></li>
<li><a href="{{ url_for('.showjobs') }}">View notifications activity</a></li>
<li><a href="{{ url_for('.userprofile') }}">User profile</a></li>
<li><a href="{{ url_for('.manageusers') }}">Manage users</a></li>
<li><a href="{{ url_for('.managetemplates')}}">Manage templates</a></li>
<li><a href="{{ url_for('.servicesettings') }}">Service settings</a></li>
<li><a href="{{ url_for('.apikeys') }}">API keys and documentation</a></li>
</ul>
</div>
</div>

View File

@@ -6,48 +6,50 @@
{% endblock %}
{% block content %}
<form method="POST" enctype="multipart/form-data">
<div class="grid-row">
<div class="column-two-thirds">
<div class="grid-row">
<div class="column-two-thirds">
<h1 class="heading-xlarge">Send text messages</h1>
<h1 class="heading-xlarge">Send text messages</h1>
<h2 class="heading-medium">1. Choose text message template</h2>
{% for template in message_templates %}
<div class="template-picker-option">
<label>
<span class="template-picker-name">{{ template.name }}</span>
<input type="radio" name="template" value="{{ template.name }}" />
{{ sms_message(template.body) }}
</label>
</div>
{% endfor %}
<h2 class="heading-medium">1. Choose text message template</h2>
{% for template in message_templates %}
<div class="template-picker-option">
<label>
<span class="template-picker-name">{{ template.name }}</span>
<input type="radio" name="template" value="{{ template.name }}" />
{{ sms_message(template.body) }}
</label>
<p>
<a href="{{ url_for(".managetemplates") }}">Create a new template</a>
</p>
<h2 class="heading-medium">2. Add recipients</h2>
<p>
Add recipients by uploading a CSV
</p>
<p>
Format the cells as text in your spreadsheet app this stores the mobile
numbers correctly
</p>
<p>
You can also <a href="#">download an example</a>
</p>
<p>
<input type="file" />
</p>
<p>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="button" value="Continue" />
</p>
</div>
{% endfor %}
<p>
<a href="#">Create a new template</a>
</p>
<h2 class="heading-medium">2. Add recipients</h2>
<p>
Add recipients by uploading a CSV
</p>
<p>
Format the cells as text in your spreadsheet app this stores the mobile
numbers correctly
</p>
<p>
You can also <a href="#">download an example</a>
</p>
<p>
<input type="file" />
</p>
<p>
<a class="button" href="/check-sms" role="button">Continue</a>
</p>
</div>
</div>
</div>
</form>
{% endblock %}