aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm91
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm19
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Static.pm4
4 files changed, 86 insertions, 30 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index d6f613fd3..bbfa8170f 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);
use FixMyStreet::SendReport;
@@ -486,17 +487,33 @@ 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),
+ ];
+ } elsif ($search =~ /^area:(\d+)$/) {
+ $query = [
+ 'me.areas' => { like => "%,$1,%" }
+ ];
+ } else {
+ $query = [
+ 'me.id' => $search_n,
+ 'user.email' => { ilike => $like_search },
+ 'me.name' => { ilike => $like_search },
+ 'me.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 },
- 'me.title' => { ilike => $like_search },
- detail => { ilike => $like_search },
- council => { like => $like_search },
- cobrand_data => { like => $like_search },
- ]
+ -or => $query,
},
{
prefetch => 'user',
@@ -512,26 +529,44 @@ sub search_reports : Path('search_reports') {
$c->stash->{edit_council_contacts} = 1
if ( grep {$_ eq 'councilcontacts'} keys %{$c->stash->{allowed_pages}});
- 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 },
- ]
- },
- {
- -select => [ 'me.*', qw/problem.council problem.state/ ],
- prefetch => [qw/user problem/],
- order_by => [\"(me.state='hidden')",\"(problem.state='hidden')",'me.created']
- }
- );
+ 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 },
+ ];
+ } elsif ($search =~ /^area:(\d+)$/) {
+ $query = [];
+ } 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 },
+ ];
+ }
- $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 e7468986b..4dac4d30f 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 ) = @_;
@@ -556,9 +558,15 @@ sub setup_categories_and_councils : Private {
} elsif ($first_council->{id} != 2482 && $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');
@@ -747,8 +755,15 @@ sub process_report : Private {
$councils = join( ',', @{ $c->stash->{area_ids_to_list} } ) || -1;
$report->council( $councils );
- } elsif ( $first_council->{id} != 2482 && $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->{id} != 2482 && $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 ) = @_;