aboutsummaryrefslogtreecommitdiffstats
path: root/templates/web/base
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-08-23 17:28:11 +0100
committerDave Arter <davea@mysociety.org>2016-09-08 09:45:58 +0100
commit1444841970096122c9aeb5e86c82bede01b1bee6 (patch)
tree79b96fda21ce35037d05065644a1043077bf1717 /templates/web/base
parent80a01c11f656f19d6df4c2e4294f613db14689b1 (diff)
Extend response templates to work across all cobrands
This builds on the response templates in the Zürich cobrand: - Allow response templates to be assigned to categories - Also adds a auto_response flag, which will be used to automatically create updates when reports are made. - Include response templates select box on update form For mysociety/fixmystreetforcouncils#31
Diffstat (limited to 'templates/web/base')
-rw-r--r--templates/web/base/admin/response_templates_select.html8
-rw-r--r--templates/web/base/admin/template_edit.html50
-rw-r--r--templates/web/base/admin/templates.html30
-rw-r--r--templates/web/base/admin/templates_index.html11
-rw-r--r--templates/web/base/report/update/form_update.html3
5 files changed, 102 insertions, 0 deletions
diff --git a/templates/web/base/admin/response_templates_select.html b/templates/web/base/admin/response_templates_select.html
new file mode 100644
index 000000000..664d1d20a
--- /dev/null
+++ b/templates/web/base/admin/response_templates_select.html
@@ -0,0 +1,8 @@
+<div class="response_templates_select">
+ <select id="templates_for_[% for %]" class="js-template-name" data-for="[% for %]">
+ <option value="">[% loc('--Choose a template--') %]</option>
+ [% FOR t IN problem.response_templates %]
+ <option value="[% t.text | html %]"> [% t.title | html %] </option>
+ [% END %]
+ </select>
+</div>
diff --git a/templates/web/base/admin/template_edit.html b/templates/web/base/admin/template_edit.html
new file mode 100644
index 000000000..54058a04c
--- /dev/null
+++ b/templates/web/base/admin/template_edit.html
@@ -0,0 +1,50 @@
+[% INCLUDE 'admin/header.html' title=tprintf(loc('Response Template for %s'), body.name) -%]
+[% rt = response_template %]
+
+[% UNLESS rt.id %]<h3>[% loc('New template') %]</h3>[% END %]
+
+<form method="post"
+ action="[% c.uri_for('templates', body.id, rt.id || 'new' ) %]"
+ enctype="application/x-www-form-urlencoded"
+ accept-charset="utf-8"
+ class="validate">
+
+ <p>
+ <strong>[% loc('Title:') %] </strong>
+ <input type="text" name="title" class="required" size="30" value="[% rt.title| html %]">
+ </p>
+ <p>
+ <strong>[% loc('Text:') %] </strong>
+ <textarea name="text" class="required">[% rt.text |html %]</textarea>
+ </p>
+ <p>
+ <label>
+ <strong>[% loc('Auto-response:') %]</strong>
+ <input type="checkbox" name="auto_response" [% 'checked' IF rt.auto_response %] />
+ </label>
+ </p>
+ <p>
+ <strong>[% loc('Categories:') %]</strong>
+ <ul>
+ [% FOR contact IN contacts %]
+ <li>
+ <label>
+ <input type="checkbox" name="contacts[[% contact.id %]]" [% 'checked' IF contact.active %]/>
+ [% contact.category %]
+ </label>
+ </li>
+ [% END %]
+ </ul>
+ </p>
+ <p>
+ <input type="hidden" name="token" value="[% csrf_token %]" >
+ <input type="submit" name="Edit templates" value="[% rt.id ? loc('Save changes') : loc('Create template') %]" >
+ </p>
+ [% IF rt.id %]
+ <p>
+ <input class="delete" type="submit" name="delete_template" value="[% loc('Delete template') %]">
+ </p>
+ [% END %]
+</form>
+
+[% INCLUDE 'admin/footer.html' %]
diff --git a/templates/web/base/admin/templates.html b/templates/web/base/admin/templates.html
new file mode 100644
index 000000000..25cd181aa
--- /dev/null
+++ b/templates/web/base/admin/templates.html
@@ -0,0 +1,30 @@
+[% INCLUDE 'admin/header.html' title=tprintf(loc('Response Templates for %s'), body.name) -%]
+
+[% IF c.cobrand.moniker == 'zurich' %]
+ <h2> [% tprintf(loc('Response Templates for %s'), body.name) %] </h2>
+[% END %]
+
+<table>
+ <thead>
+ <tr>
+ <th> [% loc('Title') %] </th>
+ <th> [% loc('Text') %] </th>
+ <th> [% loc('Created') %] </th>
+ <th> &nbsp; </th>
+ </tr>
+ </thead>
+ <tbody>
+[% FOR t IN response_templates %]
+ <tr>
+ <td> [% t.title %] </td>
+ <td> [% t.text %] </td>
+ <td> [% t.created %] </td>
+ <td> <a href="/admin/templates/[% body.id %]/[% t.id %]" class="btn">[% loc('Edit') %]</a> </td>
+ </tr>
+[% END %]
+ </tbody>
+</table>
+
+<a href="[% c.uri_for('templates', body.id, 'new') %]" class="btn">[% loc('New template') %]</a>
+
+[% INCLUDE 'admin/footer.html' %]
diff --git a/templates/web/base/admin/templates_index.html b/templates/web/base/admin/templates_index.html
new file mode 100644
index 000000000..1f45b84de
--- /dev/null
+++ b/templates/web/base/admin/templates_index.html
@@ -0,0 +1,11 @@
+[% INCLUDE 'admin/header.html' title=loc('Response Templates') -%]
+
+<ul>
+ [% FOR body IN bodies %]
+ <li>
+ <a href="/admin/templates/[% body.id %]">[% body.name %]</a>
+ </li>
+ [% END %]
+</ul>
+
+[% INCLUDE 'admin/footer.html' %]
diff --git a/templates/web/base/report/update/form_update.html b/templates/web/base/report/update/form_update.html
index 007bd68d8..ef87d9de0 100644
--- a/templates/web/base/report/update/form_update.html
+++ b/templates/web/base/report/update/form_update.html
@@ -25,6 +25,9 @@
[% END %]
<label for="form_update">[% loc( 'Update' ) %]</label>
+[% IF c.user && c.user.belongs_to_body( problem.bodies_str ) %]
+ [% INCLUDE 'admin/response_templates_select.html' for='form_update' %]
+[% END %]
[% IF field_errors.update %]
<div class='form-error'>[% field_errors.update %]</div>
[% END %]