diff options
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 30 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Photo.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 19 |
3 files changed, 38 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index acdaf7c04..198acade6 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -483,6 +483,10 @@ sub search_reports : Path('search_reports') { $query = [ 'me.id' => int($1), ]; + } elsif ($search =~ /^area:(\d+)$/) { + $query = [ + 'me.areas' => { like => "%,$1,%" } + ]; } else { $query = [ 'me.id' => $search_n, @@ -523,6 +527,8 @@ sub search_reports : Path('search_reports') { 'problem.id' => int($1), %{ $site_restriction }, ]; + } elsif ($search =~ /^area:(\d+)$/) { + $query = []; } else { $query = [ 'me.id' => $search_n, @@ -534,18 +540,20 @@ sub search_reports : Path('search_reports') { %{ $site_restriction }, ]; } - my $updates = $c->model('DB::Comment')->search( - { - -or => $query, - }, - { - -select => [ 'me.*', qw/problem.council problem.state/ ], - prefetch => [qw/user problem/], - order_by => [\"(me.state='hidden')",\"(problem.state='hidden')",'me.created'] - } - ); - $c->stash->{updates} = [ $updates->all ]; + if (@$query) { + my $updates = $c->model('DB::Comment')->search( + { + -or => $query, + }, + { + -select => [ 'me.*', qw/problem.council problem.state/ ], + prefetch => [qw/user problem/], + order_by => [\"(me.state='hidden')",\"(problem.state='hidden')",'me.created'] + } + ); + $c->stash->{updates} = [ $updates->all ]; + } # Switch quoting back off. See above for explanation of this. $c->model('DB')->schema->storage->sql_maker->quote_char( '' ); diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index c54bad238..5d5832b08 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -114,6 +114,7 @@ sub _shrink { $image->BlobToImage($photo); my $err = $image->Scale(geometry => "$size>"); throw Error::Simple("resize failed: $err") if "$err"; + $image->Strip(); my @blobs = $image->ImageToBlob(); undef $image; return $blobs[0]; @@ -129,6 +130,7 @@ sub _crop { throw Error::Simple("resize failed: $err") if "$err"; $err = $image->Extent( geometry => '90x60', gravity => 'Center' ); throw Error::Simple("resize failed: $err") if "$err"; + $image->Strip(); my @blobs = $image->ImageToBlob(); undef $image; return $blobs[0]; 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'); } |