aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-06-22 14:45:49 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-06-22 15:14:28 +0100
commit0c69e124a57891aa84aaf7c25773738db2a108c2 (patch)
tree98f710a5b4ea7c3298b4c33c715ed5ffd82cebfa
parent3aa1096003e9a0413f6d8e8f961ec55554856ed1 (diff)
Allow admin to edit user's phone number.
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm3
-rw-r--r--t/app/controller/admin.t5
-rw-r--r--templates/web/base/admin/user-form.html8
3 files changed, 14 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index e68eb00a5..2fda70ad9 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -1066,6 +1066,7 @@ sub user_add : Path('user_edit') : Args(0) {
my $user = $c->model('DB::User')->find_or_create( {
name => $c->get_param('name'),
email => $c->get_param('email'),
+ phone => $c->get_param('phone') || undef,
from_body => $c->get_param('body') || undef,
flagged => $c->get_param('flagged') || 0,
}, {
@@ -1098,6 +1099,7 @@ sub user_edit : Path('user_edit') : Args(1) {
if ( $user->email ne $c->get_param('email') ||
$user->name ne $c->get_param('name') ||
+ $user->phone ne $c->get_param('phone') ||
($user->from_body && $user->from_body->id ne $c->get_param('body')) ||
(!$user->from_body && $c->get_param('body'))
) {
@@ -1106,6 +1108,7 @@ sub user_edit : Path('user_edit') : Args(1) {
$user->name( $c->get_param('name') );
$user->email( $c->get_param('email') );
+ $user->phone( $c->get_param('phone') ) if $c->get_param('phone');
$user->from_body( $c->get_param('body') || undef );
$user->flagged( $c->get_param('flagged') || 0 );
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 1dcb768dc..dc7aed341 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -1136,6 +1136,7 @@ for my $test (
name => 'Test User',
email => 'test@example.com',
body => $haringey->id,
+ phone => '',
flagged => undef,
},
changes => {
@@ -1150,6 +1151,7 @@ for my $test (
name => 'Changed User',
email => 'test@example.com',
body => $haringey->id,
+ phone => '',
flagged => undef,
},
changes => {
@@ -1164,6 +1166,7 @@ for my $test (
name => 'Changed User',
email => 'changed@example.com',
body => $haringey->id,
+ phone => '',
flagged => undef,
},
changes => {
@@ -1178,6 +1181,7 @@ for my $test (
name => 'Changed User',
email => 'changed@example.com',
body => $southend->id,
+ phone => '',
flagged => undef,
},
changes => {
@@ -1192,6 +1196,7 @@ for my $test (
name => 'Changed User',
email => 'changed@example.com',
body => $southend->id,
+ phone => '',
flagged => 'on',
},
changes => {
diff --git a/templates/web/base/admin/user-form.html b/templates/web/base/admin/user-form.html
index b863bf96a..d6456f3d9 100644
--- a/templates/web/base/admin/user-form.html
+++ b/templates/web/base/admin/user-form.html
@@ -15,9 +15,13 @@
%]
</p>
</div>
- [% loc('Name:') %] <input type='text' name='name' id='name' value='[% user.name | html %]'>
+ <label for="name">[% loc('Name:') %]</label>
+ <input type='text' name='name' id='name' value='[% user.name | html %]'>
</li>
- <li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% user.email | html %]'></li>
+ <li><label for="email">[% loc('Email:') %]</label>
+ <input type='text' id='email' name='email' value='[% user.email | html %]'></li>
+ <li><label for="phone">[% loc('Phone:') %]</label>
+ <input type='text' id='phone' name='phone' value='[% user.phone | html %]'></li>
<li>
<div class="admin-hint">
<p>