diff options
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 63 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 19 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Static.pm | 4 |
3 files changed, 66 insertions, 20 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 83f77f401..acdaf7c04 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -6,6 +6,7 @@ BEGIN { extends 'Catalyst::Controller'; } use POSIX qw(strftime strcoll); use Digest::MD5 qw(md5_hex); +use mySociety::EmailUtil qw(is_valid_email); =head1 NAME @@ -473,17 +474,29 @@ sub search_reports : Path('search_reports') { $c->model('DB')->schema->storage->sql_maker->quote_char( '"' ); $c->model('DB')->schema->storage->sql_maker->name_sep( '.' ); + my $query; + if (is_valid_email($search)) { + $query = [ + 'user.email' => { ilike => $like_search }, + ]; + } elsif ($search =~ /^id:(\d+)$/) { + $query = [ + 'me.id' => int($1), + ]; + } else { + $query = [ + 'me.id' => $search_n, + 'user.email' => { ilike => $like_search }, + 'me.name' => { ilike => $like_search }, + title => { ilike => $like_search }, + detail => { ilike => $like_search }, + council => { like => $like_search }, + cobrand_data => { like => $like_search }, + ]; + } my $problems = $c->cobrand->problems->search( { - -or => [ - 'me.id' => $search_n, - 'user.email' => { ilike => $like_search }, - 'me.name' => { ilike => $like_search }, - title => { ilike => $like_search }, - detail => { ilike => $like_search }, - council => { like => $like_search }, - cobrand_data => { like => $like_search }, - ] + -or => $query, }, { prefetch => 'user', @@ -499,17 +512,31 @@ sub search_reports : Path('search_reports') { $c->stash->{edit_council_contacts} = 1 if ( grep {$_ eq 'councilcontacts'} keys %{$c->stash->{allowed_pages}}); + if (is_valid_email($search)) { + $query = [ + 'user.email' => { ilike => $like_search }, + %{ $site_restriction }, + ]; + } elsif ($search =~ /^id:(\d+)$/) { + $query = [ + 'me.id' => int($1), + 'problem.id' => int($1), + %{ $site_restriction }, + ]; + } else { + $query = [ + 'me.id' => $search_n, + 'problem.id' => $search_n, + 'user.email' => { ilike => $like_search }, + 'me.name' => { ilike => $like_search }, + text => { ilike => $like_search }, + 'me.cobrand_data' => { ilike => $like_search }, + %{ $site_restriction }, + ]; + } my $updates = $c->model('DB::Comment')->search( { - -or => [ - 'me.id' => $search_n, - 'problem.id' => $search_n, - 'user.email' => { ilike => $like_search }, - 'me.name' => { ilike => $like_search }, - text => { ilike => $like_search }, - 'me.cobrand_data' => { ilike => $like_search }, - %{ $site_restriction }, - ] + -or => $query, }, { -select => [ 'me.*', qw/problem.council problem.state/ ], diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index af4cdd5aa..6d22a0556 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -78,6 +78,8 @@ partial =cut +use constant COUNCIL_ID_BARNET => 2489; + sub report_new : Path : Args(0) { my ( $self, $c ) = @_; @@ -545,9 +547,15 @@ sub setup_categories_and_councils : Private { } elsif ($first_council->{type} eq 'LBO') { $area_ids_to_list{ $first_council->{id} } = 1; + my @local_categories; + if ($first_council->{id} == COUNCIL_ID_BARNET) { + @local_categories = sort(keys %{ Utils::barnet_categories() }); # removed 'Other' option + } else { + @local_categories = sort keys %{ Utils::london_categories() } + } @category_options = ( _('-- Pick a category --'), - sort keys %{ Utils::london_categories() } + @local_categories ); $category_label = _('Category:'); @@ -733,8 +741,15 @@ sub process_report : Private { $councils = join( ',', @{ $c->stash->{area_ids_to_list} } ) || -1; $report->council( $councils ); - } elsif ( $first_council->{type} eq 'LBO') { + } elsif ( $first_council->{id} == COUNCIL_ID_BARNET ) { + unless ( exists Utils::barnet_categories()->{ $report->category } or $report->category eq 'Other') { + $c->stash->{field_errors}->{category} = _('Please choose a category'); + } + $report->council( $first_council->{id} ); + + } elsif ( $first_council->{type} eq 'LBO') { + unless ( Utils::london_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); } diff --git a/perllib/FixMyStreet/App/Controller/Static.pm b/perllib/FixMyStreet/App/Controller/Static.pm index 52b230c27..d4b7a1b83 100755 --- a/perllib/FixMyStreet/App/Controller/Static.pm +++ b/perllib/FixMyStreet/App/Controller/Static.pm @@ -29,6 +29,10 @@ sub for_councils_faq : Path('/for-councils/faq') : Args(0) { my ( $self, $c ) = @_; } +sub privacy : Global : Args(0) { + my ( $self, $c ) = @_; +} + sub faq : Global : Args(0) { my ( $self, $c ) = @_; |