aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-05-09 09:49:31 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-05-09 09:49:31 +0100
commitd6c53df54914479e7a8a3e6b1a20e0a7548a57df (patch)
treee163dfabea50e48b7bdda45827bd7c856337342e /perllib/FixMyStreet/App/Controller/Admin.pm
parentc25332f3c0a6201726882c9d5b69bf314b5d061d (diff)
parent0236d3a37da94e06e9e6208f50f6c0b9388feb7c (diff)
Merge branch 'template-same-name-spot'
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 103f4d473..6167a16f5 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -782,6 +782,15 @@ sub template_edit : Path('templates') : Args(2) {
}
$template->title( $c->get_param('title') );
+ my $query = { title => $template->title };
+ if ($template->in_storage) {
+ $query->{id} = { '!=', $template->id };
+ }
+ if ($c->stash->{body}->response_templates->search($query)->count) {
+ $c->stash->{errors} ||= {};
+ $c->stash->{errors}->{title} = _("There is already a template with that title.");
+ }
+
$template->text( $c->get_param('text') );
$template->state( $c->get_param('state') );
$template->external_status_code( $c->get_param('external_status_code') );