aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm30
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm26
-rw-r--r--perllib/FixMyStreet/TestMech.pm2
4 files changed, 43 insertions, 17 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/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 4b738b66c..192e539bd 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -85,11 +85,13 @@ __PACKAGE__->add_columns(
"geocode",
{ data_type => "bytea", is_nullable => 1 },
"send_fail_count",
- { data_type => "integer", is_nullable => 1 },
+ { data_type => "integer", default_value => 0, is_nullable => 0 },
"send_fail_reason",
{ data_type => "text", is_nullable => 1 },
"send_fail_timestamp",
{ data_type => "timestamp", is_nullable => 1 },
+ "send_method_used",
+ { data_type => "text", is_nullable => 1 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(
@@ -112,8 +114,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-16 10:08:56
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VODeZlWk8l/+IzBBlRNV0A
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-05-03 16:05:20
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EvwI91Ot7SioQWqwnXRTBQ
# Add fake relationship to stored procedure table
__PACKAGE__->has_one(
@@ -568,11 +570,25 @@ sub body {
return $body;
}
+# returns true if the external id is the council's ref, i.e., useful to publish it
+# (by way of an example, the barnet send method returns a useful reference when
+# it succeeds, so that is the ref we should show on the problem report page).
+# Future: this is installation-dependent so maybe should be using the contact
+# data to determine if the external id is public on a council-by-council basis.
+# Note: this only makes sense when called on a problem that has been sent!
+sub can_display_external_id {
+ my $self = shift;
+ if ($self->external_id && $self->send_method_used eq 'barnet') {
+ return 1;
+ }
+ return 0;
+}
+
# TODO Some/much of this could be moved to the template
# either:
# "sent to council 3 mins later"
-# "council ref: XYZ"
+# "[Council name] ref: XYZ"
# or
# "sent to council 3 mins later, their ref: XYZ"
#
@@ -584,7 +600,7 @@ sub processed_summary_string {
if ($problem->whensent) {
$duration_clause = $problem->duration_string($c)
}
- if ($problem->external_id) {
+ if ($problem->can_display_external_id) {
if ($duration_clause) {
$external_ref_clause = sprintf(_('their ref: %s'), $problem->external_id);
} else {
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index a8cbc98f2..7daf01f56 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -151,7 +151,7 @@ sub delete_user {
ok( $p->delete, "delete problem " . $p->title );
}
for my $a ( $user->alerts ) {
- $a->alert_sents->delete;
+ $a->alerts_sent->delete;
ok( $a->delete, "delete alert " . $a->alert_type );
}
ok( $_->delete, "delete comment " . $_->text ) for $user->comments;