aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm34
-rw-r--r--t/app/controller/admin.t39
-rw-r--r--templates/web/default/admin/report_blocks.html4
-rw-r--r--templates/web/default/admin/report_edit.html2
-rw-r--r--templates/web/default/admin/update_edit.html2
5 files changed, 79 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index f0a7e94b6..ed7fc7ce8 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -518,6 +518,9 @@ sub report_edit : Path('report_edit') : Args(1) {
$c->forward( 'log_edit', [ $id, 'problem', 'resend' ] );
}
+ elsif ( $c->req->param('flaguser') ) {
+ $c->forward('flag_user');
+ }
elsif ( $c->req->param('banuser') ) {
$c->forward('ban_user');
}
@@ -632,6 +635,9 @@ sub update_edit : Path('update_edit') : Args(1) {
if ( $c->req->param('banuser') ) {
$c->forward('ban_user');
}
+ elsif ( $c->req->param('flaguser') ) {
+ $c->forward('flag_user');
+ }
elsif ( $c->req->param('submit') ) {
$c->forward('check_token');
@@ -863,6 +869,34 @@ sub ban_user : Private {
return 1;
}
+=head2 flag_user
+
+Sets the flag on a user with the give email
+
+=cut
+
+sub flag_user : Private {
+ my ( $self, $c ) = @_;
+
+ my $email = $c->req->param('email');
+
+ return unless $email;
+
+ my $user = $c->model('DB::User')->find({ email => $email });
+
+ if ( !$user ) {
+ $c->stash->{status_message} = _('Could not find user');
+ } else {
+ $user->flagged(1);
+ $user->update;
+ $c->stash->{status_message} = _('User flagged');
+ }
+
+ $c->stash->{user_flagged} = 1;
+
+ return 1;
+}
+
=head2 check_email_for_abuse
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 0c9f03fa6..2ccb2ea73 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -540,6 +540,25 @@ subtest 'adding email to abuse list from report page' => sub {
$mech->content_contains('<small>(Email in abuse table)</small>');
};
+subtest 'flagging user from report page' => sub {
+ $report->user->flagged(0);
+ $report->user->update;
+
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_contains('Flag user');
+
+ $mech->click_ok('flaguser');
+
+ $mech->content_contains('User flagged');
+ $mech->content_contains('<small>(Flagged)</small>');
+
+ $report->discard_changes;
+ ok $report->user->flagged, 'user flagged';
+
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_contains('<small>(Flagged)</small>');
+};
+
$log_entries->delete;
my $update = FixMyStreet::App->model('DB::Comment')->create(
@@ -741,6 +760,26 @@ subtest 'adding email to abuse list from update page' => sub {
$mech->content_contains('<small>(Email in abuse table)</small>');
};
+subtest 'flagging user from update page' => sub {
+ $update->user->flagged(0);
+ $update->user->update;
+
+ $mech->get_ok( '/admin/update_edit/' . $update->id );
+ $mech->content_contains('Flag user');
+
+ $mech->click_ok('flaguser');
+
+ $mech->content_contains('User flagged');
+ $mech->content_contains('<small>(Flagged)</small>');
+
+ $update->discard_changes;
+ ok $update->user->flagged, 'user flagged';
+
+ $mech->get_ok( '/admin/update_edit/' . $update->id );
+ $mech->content_contains('<small>(Flagged)</small>');
+};
+
+
subtest 'hiding comment marked as fixed reopens report' => sub {
$update->mark_fixed( 1 );
$update->update;
diff --git a/templates/web/default/admin/report_blocks.html b/templates/web/default/admin/report_blocks.html
index a6e58ee01..fa610b597 100644
--- a/templates/web/default/admin/report_blocks.html
+++ b/templates/web/default/admin/report_blocks.html
@@ -11,3 +11,7 @@
[% IF email_in_abuse %]<small>[% loc('(Email in abuse table)') %]</small>[% ELSE %]<input type="submit" name="banuser" value="[% loc('Ban email address') %]" />[% END %]
[%- END %]
[%- END %]
+
+[% BLOCK flag_button -%]
+[% IF user.flagged || user_flagged %]<small>([% loc('Flagged') %])</small>[% ELSE %]<input type="submit" name="flaguser" value="[% loc('Flag user') %]" />[% END %]
+[%- END %]
diff --git a/templates/web/default/admin/report_edit.html b/templates/web/default/admin/report_edit.html
index 2f025ec64..69d5d0b11 100644
--- a/templates/web/default/admin/report_edit.html
+++ b/templates/web/default/admin/report_edit.html
@@ -25,7 +25,7 @@
</select></li>
<li>[% loc('Category:') %] [% problem.category | html %] </li>
<li>[% loc('Name:') %] <input type='text' name='name' id='name' value='[% problem.name | html %]'></li>
-<li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% problem.user.email | html %]'> [% PROCESS abuse_button %]</li>
+<li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% problem.user.email | html %]'> [% PROCESS abuse_button %] [% PROCESS flag_button user=problem.user %]</li>
<li>[% loc('Phone:') %] [% problem.user.phone | html %]</li>
<li>[% loc('Created:') %] [% PROCESS format_time time=problem.created %]</li>
<li>[% loc('Confirmed:') %] [% PROCESS format_time time=problem.confirmed no_time='-' %]</li>
diff --git a/templates/web/default/admin/update_edit.html b/templates/web/default/admin/update_edit.html
index 8e1ee935b..d4ac1b440 100644
--- a/templates/web/default/admin/update_edit.html
+++ b/templates/web/default/admin/update_edit.html
@@ -21,7 +21,7 @@
[% END %]
</select></li>
<li>[% loc('Name:') %] <input type='text' name='name' id='name' value='[% update.name | html %]'></li>
-<li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% update.user.email | html %]'> [% PROCESS abuse_button %]</li>
+<li>[% loc('Email:') %] <input type='text' id='email' name='email' value='[% update.user.email | html %]'> [% PROCESS abuse_button %] [% PROCESS flag_button user=update.user %]</li>
<li>[% loc('Cobrand:') %] [% update.cobrand %]</li>
<li>[% loc('Cobrand data:') %] [% update.cobrand_data %]</li>
<li>[% loc('Created:') %] [% PROCESS format_time time=update.created %]</li>