diff options
author | Struan Donald <struan@exo.org.uk> | 2011-06-10 16:10:14 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-08-09 18:32:04 +0100 |
commit | 68461d28992628ff394e05d56ab3ab962d048db0 (patch) | |
tree | 94e85687003872d346d62f256ba1907b105dc0be | |
parent | 6b36242db723267716552efee5a8e1ba88ed0e1c (diff) |
abuse table search
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 21 | ||||
-rw-r--r-- | t/app/controller/admin.t | 6 | ||||
-rw-r--r-- | templates/web/default/admin/search_abuse.html | 21 |
3 files changed, 48 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 191782d82..e1ced4a25 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -695,6 +695,26 @@ sub update_edit : Path('update_edit') : Args(1) { return 1; } +sub search_abuse : Path('search_abuse') : Args(0) { + my ( $self, $c ) = @_; + + $c->forward('set_allowed_pages'); + + 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; +} + =head2 set_allowed_pages Sets up the allowed_pages stash entry for checking if the current page is @@ -714,6 +734,7 @@ sub set_allowed_pages : Private { 'search_reports' => [_('Search Reports'), 2], 'timeline' => [_('Timeline'), 3], 'questionnaire' => [_('Survey Results'), 4], + 'search_abuse' => [_('Search Abuse'), 5], 'council_contacts' => [undef, undef], 'council_edit' => [undef, undef], 'report_edit' => [undef, undef], diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 0acaffc8d..acbe17c1b 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -766,6 +766,12 @@ subtest 'report search' => sub { $mech->content_like( qr{<tr [^>]*hidden[^>]*> \s* <td> \s* $r_id \s* </td>}xs ); }; +subtest 'search abuse' => sub { + $mech->get_ok( '/admin/search_abuse?search=example' ); + + $mech->content_contains('test4@example.com'); +}; + $mech->delete_user( $user ); $mech->delete_user( $user2 ); $mech->delete_user( $user3 ); diff --git a/templates/web/default/admin/search_abuse.html b/templates/web/default/admin/search_abuse.html new file mode 100644 index 000000000..0984e85cf --- /dev/null +++ b/templates/web/default/admin/search_abuse.html @@ -0,0 +1,21 @@ +[% 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' %] |