aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-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
-rw-r--r--perllib/FixMyStreet/DB.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Abuse.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/AdminLog.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Alert.pm22
-rw-r--r--perllib/FixMyStreet/DB/Result/AlertSent.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/AlertType.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm8
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm7
-rw-r--r--perllib/FixMyStreet/DB/Result/ContactsHistory.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm63
-rw-r--r--perllib/FixMyStreet/DB/Result/Questionnaire.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Secret.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Session.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Token.pm6
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm9
-rw-r--r--perllib/FixMyStreet/Geocode/Google.pm9
-rw-r--r--perllib/FixMyStreet/TestMech.pm2
21 files changed, 207 insertions, 89 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 ) = @_;
diff --git a/perllib/FixMyStreet/DB.pm b/perllib/FixMyStreet/DB.pm
index 18c8cc2ca..a1767abe9 100644
--- a/perllib/FixMyStreet/DB.pm
+++ b/perllib/FixMyStreet/DB.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB;
# Created by DBIx::Class::Schema::Loader
@@ -10,8 +11,9 @@ use base 'DBIx::Class::Schema';
__PACKAGE__->load_namespaces;
-# Created by DBIx::Class::Schema::Loader v0.07009 @ 2011-03-01 15:43:43
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tJZ+CpaAfZVPrctDXTZTuQ
+
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CjFpUvon7KggFM7OF7VK/w
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
diff --git a/perllib/FixMyStreet/DB/Result/Abuse.pm b/perllib/FixMyStreet/DB/Result/Abuse.pm
index b1cf9c1ed..e8e554afa 100644
--- a/perllib/FixMyStreet/DB/Result/Abuse.pm
+++ b/perllib/FixMyStreet/DB/Result/Abuse.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Abuse;
# Created by DBIx::Class::Schema::Loader
@@ -7,15 +8,14 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("abuse");
__PACKAGE__->add_columns("email", { data_type => "text", is_nullable => 0 });
__PACKAGE__->set_primary_key("email");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IuTLiJSDZGLF/WX8q3iKIQ
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PnQhGMx+ktK++3gWOMJBpQ
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
diff --git a/perllib/FixMyStreet/DB/Result/AdminLog.pm b/perllib/FixMyStreet/DB/Result/AdminLog.pm
index da97950a0..ede786871 100644
--- a/perllib/FixMyStreet/DB/Result/AdminLog.pm
+++ b/perllib/FixMyStreet/DB/Result/AdminLog.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::AdminLog;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("admin_log");
__PACKAGE__->add_columns(
@@ -36,8 +36,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7427CuN3/6IL2GxiQDoWUA
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+NlSH8U+beRjBZl8CpqK9A
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm
index eddd98f37..ca9ad45c2 100644
--- a/perllib/FixMyStreet/DB/Result/Alert.pm
+++ b/perllib/FixMyStreet/DB/Result/Alert.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Alert;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("alert");
__PACKAGE__->add_columns(
@@ -24,6 +24,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"parameter2",
{ data_type => "text", is_nullable => 1 },
+ "user_id",
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"confirmed",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
"lang",
@@ -40,8 +42,6 @@ __PACKAGE__->add_columns(
},
"whendisabled",
{ data_type => "timestamp", is_nullable => 1 },
- "user_id",
- { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to(
@@ -50,22 +50,22 @@ __PACKAGE__->belongs_to(
{ ref => "alert_type" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
+__PACKAGE__->has_many(
+ "alerts_sent",
+ "FixMyStreet::DB::Result::AlertSent",
+ { "foreign.alert_id" => "self.id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
__PACKAGE__->belongs_to(
"user",
"FixMyStreet::DB::Result::User",
{ id => "user_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
-__PACKAGE__->has_many(
- "alert_sents",
- "FixMyStreet::DB::Result::AlertSent",
- { "foreign.alert_id" => "self.id" },
- { cascade_copy => 0, cascade_delete => 0 },
-);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d2TrE9UIZdXu3eXYJH0Zmw
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vump36YxUO4FQi5Do6DwvA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/AlertSent.pm b/perllib/FixMyStreet/DB/Result/AlertSent.pm
index a901c2fde..a537c95cd 100644
--- a/perllib/FixMyStreet/DB/Result/AlertSent.pm
+++ b/perllib/FixMyStreet/DB/Result/AlertSent.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::AlertSent;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("alert_sent");
__PACKAGE__->add_columns(
@@ -30,8 +30,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fTiWIoriQUvHpWc9PpFLvA
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oN+36hDWJuc0hqkCW9BHOw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/AlertType.pm b/perllib/FixMyStreet/DB/Result/AlertType.pm
index d23a2983d..3aa9677e0 100644
--- a/perllib/FixMyStreet/DB/Result/AlertType.pm
+++ b/perllib/FixMyStreet/DB/Result/AlertType.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::AlertType;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("alert_type");
__PACKAGE__->add_columns(
@@ -47,8 +47,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+PKqo7IZ4MlM9ur4V2P9tA
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KDBYzNEAM5lPvZjb9cv22g
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index d31bf5510..91695d7d0 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -20,6 +20,10 @@ __PACKAGE__->add_columns(
},
"problem_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+ "user_id",
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+ "anonymous",
+ { data_type => "boolean", is_nullable => 0 },
"name",
{ data_type => "text", is_nullable => 1 },
"website",
@@ -48,10 +52,6 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", is_nullable => 0 },
"mark_open",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
- "user_id",
- { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
- "anonymous",
- { data_type => "boolean", is_nullable => 0 },
"problem_state",
{ data_type => "text", is_nullable => 1 },
"external_id",
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm
index 941e4e1bb..c32b75d0c 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Contact;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("contacts");
__PACKAGE__->add_columns(
@@ -40,8 +40,9 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("contacts_area_id_category_idx", ["area_id", "category"]);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-08-01 10:07:59
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4y6yRz4rMN66pBpkzfJJhg
+
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hyvU0bMWSFxEPAJT7wqM/Q
__PACKAGE__->filter_column(
extra => {
diff --git a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
index 811a06b44..deb00fb95 100644
--- a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
+++ b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::ContactsHistory;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("contacts_history");
__PACKAGE__->add_columns(
@@ -40,8 +40,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("contacts_history_id");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9APvBwAOebG5g4MGxJuVKQ
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dN2ueIDoP3d/+Mg1UDqsMw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 854d3bd91..b8aea8697 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Problem;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("problem");
__PACKAGE__->add_columns(
@@ -90,6 +90,8 @@ __PACKAGE__->add_columns(
{ 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(
@@ -98,22 +100,22 @@ __PACKAGE__->has_many(
{ "foreign.problem_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
-__PACKAGE__->belongs_to(
- "user",
- "FixMyStreet::DB::Result::User",
- { id => "user_id" },
- { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
-);
__PACKAGE__->has_many(
"questionnaires",
"FixMyStreet::DB::Result::Questionnaire",
{ "foreign.problem_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
+__PACKAGE__->belongs_to(
+ "user",
+ "FixMyStreet::DB::Result::User",
+ { id => "user_id" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
-# 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,7 +570,50 @@ 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 name] ref: XYZ"
+# or
+# "sent to council 3 mins later, their ref: XYZ"
+#
+# Note: some silliness with pronouns and the adjacent comma mean this is
+# being presented as a single string rather than two
+sub processed_summary_string {
+ my ( $problem, $c ) = @_;
+ my ($duration_clause, $external_ref_clause);
+ if ($problem->whensent) {
+ $duration_clause = $problem->duration_string($c)
+ }
+ if ($problem->can_display_external_id) {
+ if ($duration_clause) {
+ $external_ref_clause = sprintf(_('their ref: %s'), $problem->external_id);
+ } else {
+ $external_ref_clause = sprintf(_('%s ref: %s'), $problem->external_body, $problem->external_id);
+ }
+ }
+ if ($duration_clause and $external_ref_clause) {
+ return "$duration_clause, $external_ref_clause"
+ } else {
+ return $duration_clause || $external_ref_clause
+ }
+}
+
sub duration_string {
my ( $problem, $c ) = @_;
my $body = $problem->body( $c );
diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
index cc4ec300b..b6791603a 100644
--- a/perllib/FixMyStreet/DB/Result/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Questionnaire;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("questionnaire");
__PACKAGE__->add_columns(
@@ -40,8 +40,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QNFqqCg6J4SFlg4zwm7TWw
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NGlSRjoBpDoIvK3EueqN6Q
use DateTime::TimeZone;
diff --git a/perllib/FixMyStreet/DB/Result/Secret.pm b/perllib/FixMyStreet/DB/Result/Secret.pm
index 8a1fa671d..449dfec0e 100644
--- a/perllib/FixMyStreet/DB/Result/Secret.pm
+++ b/perllib/FixMyStreet/DB/Result/Secret.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Secret;
# Created by DBIx::Class::Schema::Loader
@@ -7,14 +8,13 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("secret");
__PACKAGE__->add_columns("secret", { data_type => "text", is_nullable => 0 });
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:MfqW1K0aFtwpa/1c/UwHjg
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9XiWSKJ1PD3LSYjrSA3drw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/FixMyStreet/DB/Result/Session.pm b/perllib/FixMyStreet/DB/Result/Session.pm
index 9d5d509dc..4713c99eb 100644
--- a/perllib/FixMyStreet/DB/Result/Session.pm
+++ b/perllib/FixMyStreet/DB/Result/Session.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Session;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("sessions");
__PACKAGE__->add_columns(
@@ -21,8 +21,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TagSQOXnDttkwfJ7oDH8Yw
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:MVmCn4gLQWXTDIIaDHiVmA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
diff --git a/perllib/FixMyStreet/DB/Result/Token.pm b/perllib/FixMyStreet/DB/Result/Token.pm
index 3a900858d..b223ada3a 100644
--- a/perllib/FixMyStreet/DB/Result/Token.pm
+++ b/perllib/FixMyStreet/DB/Result/Token.pm
@@ -1,3 +1,4 @@
+use utf8;
package FixMyStreet::DB::Result::Token;
# Created by DBIx::Class::Schema::Loader
@@ -7,7 +8,6 @@ use strict;
use warnings;
use base 'DBIx::Class::Core';
-
__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
__PACKAGE__->table("token");
__PACKAGE__->add_columns(
@@ -27,8 +27,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("scope", "token");
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:frl+na3HrIzGw9D1t891nA
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+LLZ8P5GXqPetuGyrra2vw
# Trying not to use this
# use mySociety::DBHandle qw(dbh);
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 0a7fc38dc..3bbb9dcdc 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -71,7 +71,14 @@ sub string {
);
( $latitude, $longitude ) = @{ $_->{point}->{coordinates} };
- push (@$error, { address => $address, latitude => $latitude, longitude => $longitude });
+ # These co-ordinates are output as query parameters in a URL, make sure they have a "."
+ mySociety::Locale::in_gb_locale {
+ push (@$error, {
+ address => $address,
+ latitude => sprintf('%0.6f', $latitude),
+ longitude => sprintf('%0.6f', $longitude)
+ });
+ };
push (@valid_locations, $_);
}
diff --git a/perllib/FixMyStreet/Geocode/Google.pm b/perllib/FixMyStreet/Geocode/Google.pm
index 83b36dbcd..1ab347066 100644
--- a/perllib/FixMyStreet/Geocode/Google.pm
+++ b/perllib/FixMyStreet/Geocode/Google.pm
@@ -75,7 +75,14 @@ sub string {
my $address = $_->{address};
next unless $c->cobrand->geocoded_string_check( $address );
( $longitude, $latitude ) = @{ $_->{Point}->{coordinates} };
- push (@$error, { address => $address, latitude => $latitude, longitude => $longitude });
+ # These co-ordinates are output as query parameters in a URL, make sure they have a "."
+ mySociety::Locale::in_gb_locale {
+ push (@$error, {
+ address => $address,
+ latitude => sprintf('%0.6f', $latitude),
+ longitude => sprintf('%0.6f', $longitude)
+ });
+ };
push (@valid_locations, $_);
}
return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1;
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;