aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm49
-rw-r--r--t/app/controller/admin.t5
-rw-r--r--templates/web/default/admin/search_abuse.html21
-rw-r--r--templates/web/default/admin/search_users.html4
4 files changed, 26 insertions, 53 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index b53b6ab06..4999d16f2 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -739,8 +739,24 @@ sub search_users: Path('search_users') : Args(0) {
]
}
);
+ my @users = $users->all;
+ my %email2user = map { $_->email => $_ } @users;
+ $c->stash->{users} = [ @users ];
+
+ my $emails = $c->model('DB::Abuse')->search(
+ {
+ email => { ilike => $isearch }
+ }
+ );
+ foreach my $email ($emails->all) {
+ # Slight abuse of the boolean flagged value
+ if ($email2user{$email->email}) {
+ $email2user{$email->email}->flagged( 2 );
+ } else {
+ push @{$c->stash->{users}}, { email => $email->email, flagged => 2 };
+ }
+ }
- $c->stash->{users} = [ $users->all ];
}
return 1;
@@ -847,26 +863,6 @@ sub update_edit : Path('update_edit') : Args(1) {
return 1;
}
-sub search_abuse : Path('search_abuse') : Args(0) {
- my ( $self, $c ) = @_;
-
- $c->forward('check_page_allowed');
-
- my $search = $c->req->param('search');
-
- if ($search) {
- my $emails = $c->model('DB::Abuse')->search(
- {
- email => { ilike => "\%$search\%" }
- }
- );
-
- $c->stash->{emails} = [ $emails->all ];
- }
-
- return 1;
-}
-
sub user_edit : Path('user_edit') : Args(1) {
my ( $self, $c, $id ) = @_;
@@ -1033,13 +1029,12 @@ sub set_allowed_pages : Private {
if( !$pages ) {
$pages = {
'summary' => [_('Summary'), 0],
- 'council_list' => [_('Council contacts'), 1],
- 'search_reports' => [_('Search Reports'), 2],
+ 'council_list' => [_('Bodies'), 1],
+ 'search_reports' => [_('Reports'), 2],
'timeline' => [_('Timeline'), 3],
- 'questionnaire' => [_('Survey Results'), 4],
- 'search_users' => [_('Search Users'), 5],
- 'search_abuse' => [_('Search Abuse'), 5],
- 'list_flagged' => [_('List Flagged'), 6],
+ 'questionnaire' => [_('Survey'), 4],
+ 'search_users' => [_('Users'), 5],
+ 'list_flagged' => [_('Flagged'), 6],
'stats' => [_('Stats'), 6],
'user_edit' => [undef, undef],
'council_contacts' => [undef, undef],
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 839bfd6b9..9ec15ec21 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -1066,9 +1066,8 @@ subtest 'report search' => sub {
};
subtest 'search abuse' => sub {
- $mech->get_ok( '/admin/search_abuse?search=example' );
-
- $mech->content_contains('test4@example.com');
+ $mech->get_ok( '/admin/search_users?search=example' );
+ $mech->content_like(qr/test4\@example.com.*\n.*\n.*Email in abuse table/);
};
subtest 'show flagged entries' => sub {
diff --git a/templates/web/default/admin/search_abuse.html b/templates/web/default/admin/search_abuse.html
deleted file mode 100644
index 0984e85cf..000000000
--- a/templates/web/default/admin/search_abuse.html
+++ /dev/null
@@ -1,21 +0,0 @@
-[% INCLUDE 'admin/header.html' title=loc('Search Abuse Table') %]
-
-<form method="get" action="[% c.uri_for('search_abuse') %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8">
- <label for="search">[% loc('Search:') %]</label> <input type="text" name="search" size="30" id="search">
-</form>
-
-
-[% IF emails.size > 0 %]
-<table cellspacing="0" cellpadding="2" border="1">
- <tr>
- <th>[% loc('Email') %]</th>
- </tr>
-[%- FOREACH foo IN emails %]
- <tr>
- <td>[%- foo.email | html -%]</td>
- </tr>
-[%- END -%]
-</table>
-[% END %]
-
-[% INCLUDE 'admin/footer.html' %]
diff --git a/templates/web/default/admin/search_users.html b/templates/web/default/admin/search_users.html
index 18c964dfe..0b4ba88e7 100644
--- a/templates/web/default/admin/search_users.html
+++ b/templates/web/default/admin/search_users.html
@@ -20,8 +20,8 @@
<td>[% PROCESS value_or_nbsp value=user.name %]</td>
<td><a href="[% c.uri_for( 'search_reports', search => user.email ) %]">[% PROCESS value_or_nbsp value=user.email %]</a></td>
<td>[% PROCESS value_or_nbsp value=user.from_council %]</td>
- <td>[% user.flagged ? loc('Yes') : '&nbsp;' %]</td>
- <td><a href="[% c.uri_for( 'user_edit', user.id ) %]">[% loc('Edit') %]</a></td>
+ <td>[% user.flagged == 2 ? loc('(Email in abuse table)') : user.flagged ? loc('Yes') : '&nbsp;' %]</td>
+ <td>[% IF user.id %]<a href="[% c.uri_for( 'user_edit', user.id ) %]">[% loc('Edit') %]</a>[% END %]</td>
</tr>
[%- END -%]
</table>