aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r--perllib/FixMyStreet/DB/Result/Alert.pm10
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm10
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm8
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm143
-rw-r--r--perllib/FixMyStreet/DB/Result/Questionnaire.pm10
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm23
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Nearby.pm9
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm168
9 files changed, 182 insertions, 201 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm
index 4ce72f873..c64cb2ff4 100644
--- a/perllib/FixMyStreet/DB/Result/Alert.pm
+++ b/perllib/FixMyStreet/DB/Result/Alert.pm
@@ -69,24 +69,16 @@ __PACKAGE__->belongs_to(
# You can replace this text with custom code or comments, and it will be preserved on regeneration
-use DateTime::TimeZone;
use Moose;
use namespace::clean -except => [ 'meta' ];
with 'FixMyStreet::Roles::Abuser';
-my $tz = DateTime::TimeZone->new( name => "local" );
-
-my $tz_f;
-$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
- if FixMyStreet->config('TIME_ZONE');
-
my $stz = sub {
my ( $orig, $self ) = ( shift, shift );
my $s = $self->$orig(@_);
return $s unless $s && UNIVERSAL::isa($s, "DateTime");
- $s->set_time_zone($tz);
- $s->set_time_zone($tz_f) if $tz_f;
+ FixMyStreet->set_time_zone($s);
return $s;
};
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 3fae6860a..836462ed5 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -95,25 +95,17 @@ __PACKAGE__->belongs_to(
__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn");
__PACKAGE__->rabx_column('extra');
-use DateTime::TimeZone;
use Image::Size;
use Moose;
use namespace::clean -except => [ 'meta' ];
with 'FixMyStreet::Roles::Abuser';
-my $tz = DateTime::TimeZone->new( name => "local" );
-
-my $tz_f;
-$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
- if FixMyStreet->config('TIME_ZONE');
-
my $stz = sub {
my ( $orig, $self ) = ( shift, shift );
my $s = $self->$orig(@_);
return $s unless $s && UNIVERSAL::isa($s, "DateTime");
- $s->set_time_zone($tz);
- $s->set_time_zone($tz_f) if $tz_f;
+ FixMyStreet->set_time_zone($s);
return $s;
};
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm
index eca028c9b..2fbb0716d 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -63,4 +63,12 @@ __PACKAGE__->belongs_to(
__PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn");
__PACKAGE__->rabx_column('extra');
+use Moose;
+use namespace::clean -except => [ 'meta' ];
+
+with 'FixMyStreet::Roles::Extra';
+
+# we need the inline_constructor bit as we don't inherit from Moose
+__PACKAGE__->meta->make_immutable( inline_constructor => 0 );
+
1;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 34d740912..bed2f160a 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -153,13 +153,13 @@ __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn");
__PACKAGE__->rabx_column('extra');
__PACKAGE__->rabx_column('geocode');
-use DateTime::TimeZone;
use Image::Size;
use Moose;
use namespace::clean -except => [ 'meta' ];
use Utils;
-with 'FixMyStreet::Roles::Abuser';
+with 'FixMyStreet::Roles::Abuser',
+ 'FixMyStreet::Roles::Extra';
=head2
@@ -228,38 +228,6 @@ sub closed_states {
=head2
- @states = FixMyStreet::DB::Problem::visible_states();
-
-Get a list of states that should be visible on the site. If called in
-array context then returns an array of names, otherwise returns a
-HASHREF.
-
-=cut
-
-my $visible_states = {
- 'confirmed' => 1,
- 'investigating' => 1,
- 'in progress' => 1,
- 'planned' => 1,
- 'action scheduled' => 1,
- 'fixed' => 1,
- 'fixed - council' => 1,
- 'fixed - user' => 1,
- 'unable to fix' => 1,
- 'not responsible' => 1,
- 'duplicate' => 1,
- 'closed' => 1,
- 'internal referral' => 1,
-};
-sub visible_states {
- return wantarray ? keys %{$visible_states} : $visible_states;
-}
-sub visible_states_add_unconfirmed {
- $visible_states->{unconfirmed} = 1;
-}
-
-=head2
-
@states = FixMyStreet::DB::Problem::all_states();
Get a list of all states that a problem can have. If called in
@@ -293,6 +261,70 @@ sub all_states {
=head2
+ @visible_states = FixMyStreet::DB::Problem::visible_states();
+ @hidden_states = FixMyStreet::DB::Problem::hidden_states();
+
+Get a list of states that should be visible (or hidden) on the site. If called
+in array context then returns an array of names, otherwise returns a HASHREF.
+
+=cut
+
+my $hidden_states = {
+ 'hidden' => 1,
+ 'partial' => 1,
+ 'unconfirmed' => 1,
+};
+
+my $visible_states = {
+ map {
+ $hidden_states->{$_} ? () : ($_ => 1)
+ } all_states()
+};
+ ## e.g.:
+ # 'confirmed' => 1,
+ # 'investigating' => 1,
+ # 'in progress' => 1,
+ # 'planned' => 1,
+ # 'action scheduled' => 1,
+ # 'fixed' => 1,
+ # 'fixed - council' => 1,
+ # 'fixed - user' => 1,
+ # 'unable to fix' => 1,
+ # 'not responsible' => 1,
+ # 'duplicate' => 1,
+ # 'closed' => 1,
+ # 'internal referral' => 1,
+
+sub hidden_states {
+ return wantarray ? keys %{$hidden_states} : $hidden_states;
+}
+
+sub visible_states {
+ return wantarray ? keys %{$visible_states} : $visible_states;
+}
+
+sub visible_states_add {
+ my ($self, @states) = @_;
+ for my $state (@states) {
+ delete $hidden_states->{$state};
+ $visible_states->{$state} = 1;
+ }
+}
+
+sub visible_states_remove {
+ my ($self, @states) = @_;
+ for my $state (@states) {
+ delete $visible_states->{$state};
+ $hidden_states->{$state} = 1;
+ }
+}
+
+sub visible_states_add_unconfirmed {
+ $_[0]->visible_states_add('unconfirmed')
+}
+
+=head2
+
@states = FixMyStreet::DB::Problem::council_states();
Get a list of states that are availble to council users. If called in
@@ -316,18 +348,11 @@ sub council_states {
return wantarray ? keys %{$states} : $states;
}
-my $tz = DateTime::TimeZone->new( name => "local" );
-
-my $tz_f;
-$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
- if FixMyStreet->config('TIME_ZONE');
-
my $stz = sub {
my ( $orig, $self ) = ( shift, shift );
my $s = $self->$orig(@_);
return $s unless $s && UNIVERSAL::isa($s, "DateTime");
- $s->set_time_zone($tz);
- $s->set_time_zone($tz_f) if $tz_f;
+ FixMyStreet->set_time_zone($s);
return $s;
};
@@ -380,14 +405,6 @@ sub check_for_errors {
if ( !$self->name || $self->name !~ m/\S/ ) {
$errors{name} = _('Please enter your name');
}
- elsif (length( $self->name ) < 5
- || $self->name !~ m/\s/
- || $self->name =~ m/\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i )
- {
- $errors{name} = _(
-'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below'
- ) unless $self->cobrand eq 'emptyhomes';
- }
if ( $self->category
&& $self->category eq _('-- Pick a category --') )
@@ -402,18 +419,6 @@ sub check_for_errors {
$self->category(undef);
}
- if ( $self->bodies_str && $self->detail ) {
- # Custom character limit:
- # Bromley Council
- if ( $self->bodies_str eq '2482' && length($self->detail) > 1750 ) {
- $errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1750 );
- }
- # Oxfordshire
- if ( $self->bodies_str eq '2237' && length($self->detail) > 1700 ) {
- $errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1700 );
- }
- }
-
return \%errors;
}
@@ -662,14 +667,14 @@ sub processed_summary_string {
}
if ($problem->can_display_external_id) {
if ($duration_clause) {
- $external_ref_clause = sprintf(_('council ref:&nbsp;%s'), $problem->external_id);
+ $external_ref_clause = '<strong>' . sprintf(_('Council ref:&nbsp;%s'), $problem->external_id) . '.</strong>';
} else {
- $external_ref_clause = sprintf(_('%s ref:&nbsp;%s'), $problem->external_body, $problem->external_id);
+ $external_ref_clause = '<strong>' . sprintf(_('%s ref:&nbsp;%s'), $problem->external_body, $problem->external_id) . '.</strong>';
}
}
if ($duration_clause and $external_ref_clause) {
- return "$duration_clause, $external_ref_clause"
- } else {
+ return "$duration_clause. $external_ref_clause"
+ } else {
return $duration_clause || $external_ref_clause
}
}
@@ -688,6 +693,10 @@ sub local_coords {
my ($x, $y) = Geo::Coordinates::CH1903::from_latlon($self->latitude, $self->longitude);
return ( int($x+0.5), int($y+0.5) );
}
+ else {
+ # return a dummy value until this function is implemented. useful for testing.
+ return (0, 0);
+ }
}
=head2 update_from_open311_service_request
@@ -745,7 +754,7 @@ sub update_from_open311_service_request {
# of course if local timezone is not the one that went into the data
# base then we're also in trouble
my $lastupdate = $self->lastupdate;
- $lastupdate->set_time_zone( DateTime::TimeZone->new( name => 'local' ) );
+ $lastupdate->set_time_zone( FixMyStreet->local_time_zone );
# update from open311 is older so skip
if ( $req_time < $lastupdate ) {
diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
index 7f9c79d9a..6f2941546 100644
--- a/perllib/FixMyStreet/DB/Result/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm
@@ -43,22 +43,14 @@ __PACKAGE__->belongs_to(
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oL1Hk4/bNG14CY74GA75SA
-use DateTime::TimeZone;
use Moose;
use namespace::clean -except => [ 'meta' ];
-my $tz = DateTime::TimeZone->new( name => "local" );
-
-my $tz_f;
-$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') )
- if FixMyStreet->config('TIME_ZONE');
-
my $stz = sub {
my ( $orig, $self ) = ( shift, shift );
my $s = $self->$orig(@_);
return $s unless $s && UNIVERSAL::isa($s, "DateTime");
- $s->set_time_zone($tz);
- $s->set_time_zone($tz_f) if $tz_f;
+ FixMyStreet->set_time_zone($s);
return $s;
};
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 6a93f97ec..f08b666c8 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -100,7 +100,7 @@ use mySociety::EmailUtil;
=head2 check_for_errors
- $error_hashref = $problem->check_for_errors();
+ $error_hashref = $user->check_for_errors();
Look at all the fields and return a hashref with all errors found, keyed on the
field name. This is intended to be passed back to the form to display the
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index b704fa7dd..0b430008a 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -103,36 +103,25 @@ sub email_alerts ($) {
} );
$data{alert_email} = $user->email;
my $token_obj = FixMyStreet::App->model('DB::Token')->create( {
- scope => 'email_sign_in',
+ scope => 'alert_to_reporter',
data => {
- email => $user->email,
- r => 'report/' . $row->{id},
+ id => $row->{id},
}
} );
- $data{problem_url} = $url . "/M/" . $token_obj->token;
+ $data{problem_url} = $url . "/R/" . $token_obj->token;
} else {
$data{problem_url} = $url . "/report/" . $row->{id};
}
$data{data} .= $row->{item_name} . ' : ' if $row->{item_name} && !$row->{item_anonymous};
if ( $cobrand->include_time_in_update_alerts ) {
- # this is basically recreating the code from the inflate wrapper
- # in the database model.
- my $tz;
- if ( FixMyStreet->config('TIME_ZONE') ) {
- $tz = FixMyStreet->config('TIME_ZONE');
- }
-
my $parser = DateTime::Format::Pg->new();
my $dt = $parser->parse_timestamp( $row->{item_confirmed} );
- my $l_tz = DateTime::TimeZone->new( name => "local" );
# We need to always set this otherwise we end up with the DateTime
# object being in the floating timezone in which case applying a
# subsequent timezone set will have no effect.
- $dt->set_time_zone( $l_tz );
- if ( $tz ) {
- my $tz_obj = DateTime::TimeZone->new( name => $tz );
- $dt->set_time_zone( $tz_obj );
- }
+ # this is basically recreating the code from the inflate wrapper
+ # in the database model.
+ FixMyStreet->set_time_zone($dt);
$data{data} .= $cobrand->prettify_dt( $dt, 'alert' ) . "\n\n";
}
$data{data} .= $row->{item_text} . "\n\n------\n\n";
diff --git a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
index 91c44d5f4..a0ccb8a6d 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Nearby.pm
@@ -5,11 +5,15 @@ use strict;
use warnings;
sub nearby {
- my ( $rs, $c, $dist, $ids, $limit, $mid_lat, $mid_lon, $interval ) = @_;
+ my ( $rs, $c, $dist, $ids, $limit, $mid_lat, $mid_lon, $interval, $category, $states ) = @_;
+
+ unless ( $states ) {
+ $states = FixMyStreet::DB::Result::Problem->visible_states();
+ }
my $params = {
non_public => 0,
- state => [ FixMyStreet::DB::Result::Problem::visible_states() ],
+ state => [ keys %$states ],
};
$params->{'current_timestamp-lastupdate'} = { '<', \"'$interval'::interval" }
if $interval;
@@ -19,6 +23,7 @@ sub nearby {
%{ $c->cobrand->problems_clause },
%$params
} if $c->cobrand->problems_clause;
+ $params->{category} = $category if $category;
my $attrs = {
prefetch => 'problem',
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index a84a309ee..7885c28b3 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -131,20 +131,25 @@ sub _recent {
# Problems around a location
sub around_map {
- my ( $rs, $min_lat, $max_lat, $min_lon, $max_lon, $interval, $limit ) = @_;
+ my ( $rs, $min_lat, $max_lat, $min_lon, $max_lon, $interval, $limit, $category, $states ) = @_;
my $attr = {
order_by => { -desc => 'created' },
};
$attr->{rows} = $limit if $limit;
+ unless ( $states ) {
+ $states = FixMyStreet::DB::Result::Problem->visible_states();
+ }
+
my $q = {
non_public => 0,
- state => [ FixMyStreet::DB::Result::Problem->visible_states() ],
+ state => [ keys %$states ],
latitude => { '>=', $min_lat, '<', $max_lat },
longitude => { '>=', $min_lon, '<', $max_lon },
};
$q->{'current_timestamp - lastupdate'} = { '<', \"'$interval'::interval" }
if $interval;
+ $q->{category} = $category if $category;
my @problems = mySociety::Locale::in_gb_locale { $rs->search( $q, $attr )->all };
return \@problems;
@@ -295,19 +300,6 @@ sub send_reports {
: _('The user could not locate the problem on a map, but to see the area around the location they entered');
$h{closest_address} = '';
- # If we are in the UK include eastings and northings, and nearest stuff
- $h{easting_northing} = '';
- if ( $cobrand->country eq 'GB' ) {
-
- ( $h{easting}, $h{northing} ) = Utils::convert_latlon_to_en( $h{latitude}, $h{longitude} );
-
- # email templates don't have conditionals so we need to farmat this here
- $h{easting_northing} #
- = "Easting: $h{easting}\n\n" #
- . "Northing: $h{northing}\n\n";
-
- }
-
if ( $row->used_map ) {
$h{closest_address} = $cobrand->find_closest( $h{latitude}, $h{longitude}, $row );
}
@@ -315,104 +307,106 @@ sub send_reports {
if ( $cobrand->allow_anonymous_reports &&
$row->user->email eq $cobrand->anonymous_account->{'email'}
) {
- $h{anonymous_report} = 1;
- $h{user_details} = _('This report was submitted anonymously');
- } else {
- $h{user_details} = sprintf(_('Name: %s'), $row->name) . "\n\n";
- $h{user_details} .= sprintf(_('Email: %s'), $row->user->email) . "\n\n";
- }
+ $h{anonymous_report} = 1;
+ $h{user_details} = _('This report was submitted anonymously');
+ } else {
+ $h{user_details} = sprintf(_('Name: %s'), $row->name) . "\n\n";
+ $h{user_details} .= sprintf(_('Email: %s'), $row->user->email) . "\n\n";
+ }
+
+ $h{easting_northing} = '';
if ($cobrand->can('process_additional_metadata_for_email')) {
$cobrand->process_additional_metadata_for_email($row, \%h);
}
+ # XXX Needs locks!
+ # XXX Only copes with at most one missing body
+ my ($bodies, $missing) = $row->bodies_str =~ /^([\d,]+)(?:\|(\d+))?/;
+ my @bodies = split(/,/, $bodies);
+ $bodies = FixMyStreet::App->model("DB::Body")->search(
+ { id => \@bodies },
+ { order_by => 'name' },
+ );
+ $missing = FixMyStreet::App->model("DB::Body")->find($missing) if $missing;
+
+ my @dear;
my %reporters = ();
- my ( $sender_count );
- if ($site eq 'emptyhomes') {
+ while (my $body = $bodies->next) {
+ my $sender_info = $cobrand->get_body_sender( $body, $row->category );
+ my $sender = "FixMyStreet::SendReport::" . $sender_info->{method};
- my $body = $row->bodies_str;
- $body = FixMyStreet::App->model("DB::Body")->find($body);
- my $sender = "FixMyStreet::SendReport::EmptyHomes";
- $reporters{ $sender } = $sender->new() unless $reporters{$sender};
- $reporters{ $sender }->add_body( $body );
- $sender_count = 1;
-
- } else {
-
- # XXX Needs locks!
- # XXX Only copes with at most one missing body
- my ($bodies, $missing) = $row->bodies_str =~ /^([\d,]+)(?:\|(\d+))?/;
- my @bodies = split(/,/, $bodies);
- $bodies = FixMyStreet::App->model("DB::Body")->search(
- { id => \@bodies },
- { order_by => 'name' },
- );
- $missing = FixMyStreet::App->model("DB::Body")->find($missing) if $missing;
- my @dear;
-
- while (my $body = $bodies->next) {
- my $sender_info = $cobrand->get_body_sender( $body, $row->category );
- my $sender = "FixMyStreet::SendReport::" . $sender_info->{method};
-
- if ( ! exists $senders->{ $sender } ) {
- warn "No such sender [ $sender ] for body $body->name ( $body->id )";
- next;
- }
- $reporters{ $sender } ||= $sender->new();
-
- if ( $reporters{ $sender }->should_skip( $row ) ) {
- debug_print("skipped by sender " . $sender_info->{method} . " (might be due to previous failed attempts?)", $row->id) if $debug_mode;
- } else {
- debug_print("OK, adding recipient body " . $body->id . ":" . $body->name . ", " . $body->send_method, $row->id) if $debug_mode;
- push @dear, $body->name;
- $reporters{ $sender }->add_body( $body, $sender_info->{config} );
- }
+ if ( ! exists $senders->{ $sender } ) {
+ warn "No such sender [ $sender ] for body $body->name ( $body->id )";
+ next;
}
+ $reporters{ $sender } ||= $sender->new();
- if ($h{category} eq _('Other')) {
- $h{category_footer} = _('this type of local problem');
- $h{category_line} = '';
+ if ( $reporters{ $sender }->should_skip( $row ) ) {
+ debug_print("skipped by sender " . $sender_info->{method} . " (might be due to previous failed attempts?)", $row->id) if $debug_mode;
} else {
- $h{category_footer} = "'" . $h{category} . "'";
- $h{category_line} = sprintf(_("Category: %s"), $h{category}) . "\n\n";
+ debug_print("OK, adding recipient body " . $body->id . ":" . $body->name . ", " . $body->send_method, $row->id) if $debug_mode;
+ push @dear, $body->name;
+ $reporters{ $sender }->add_body( $body, $sender_info->{config} );
}
- if ( $row->subcategory ) {
- $h{subcategory_line} = sprintf(_("Subcategory: %s"), $row->subcategory) . "\n\n";
- } else {
- $h{subcategory_line} = "\n\n";
- }
+ # If we are in the UK include eastings and northings, and nearest stuff
+ if ( $cobrand->country eq 'GB' && !$h{easting} ) {
+ my $coordsyst = 'G';
+ my $first_area = $body->body_areas->first->area_id;
+ my $area_info = mySociety::MaPit::call('area', $first_area);
+ $coordsyst = 'I' if $area_info->{type} eq 'LGD';
- $h{bodies_name} = join(_(' and '), @dear);
- if ($h{category} eq _('Other')) {
- $h{multiple} = @dear>1 ? "[ " . _("This email has been sent to both councils covering the location of the problem, as the user did not categorise it; please ignore it if you're not the correct council to deal with the issue, or let us know what category of problem this is so we can add it to our system.") . " ]\n\n"
- : '';
- } else {
- $h{multiple} = @dear>1 ? "[ " . _("This email has been sent to several councils covering the location of the problem, as the category selected is provided for all of them; please ignore it if you're not the correct council to deal with the issue.") . " ]\n\n"
- : '';
- }
- $h{missing} = '';
- if ($missing) {
- $h{missing} = '[ '
- . sprintf(_('We realise this problem might be the responsibility of %s; however, we don\'t currently have any contact details for them. If you know of an appropriate contact address, please do get in touch.'), $missing->name)
- . " ]\n\n";
- }
+ ( $h{easting}, $h{northing} ) = Utils::convert_latlon_to_en( $h{latitude}, $h{longitude}, $coordsyst );
- $sender_count = scalar @dear;
+ # email templates don't have conditionals so we need to format this here
+ $h{easting_northing} = "Easting/Northing";
+ $h{easting_northing} .= " (IE)" if $coordsyst eq 'I';
+ $h{easting_northing} .= ": $h{easting}/$h{northing}\n\n";
+ }
}
unless ( keys %reporters ) {
die 'Report not going anywhere for ID ' . $row->id . '!';
}
- if (! $sender_count) {
+ unless (@dear) {
debug_print("can't send because sender count is zero", $row->id) if $debug_mode;
next;
}
+ if ($h{category} eq _('Other')) {
+ $h{category_footer} = _('this type of local problem');
+ $h{category_line} = '';
+ } else {
+ $h{category_footer} = "'" . $h{category} . "'";
+ $h{category_line} = sprintf(_("Category: %s"), $h{category}) . "\n\n";
+ }
+
+ if ( $row->subcategory ) {
+ $h{subcategory_line} = sprintf(_("Subcategory: %s"), $row->subcategory) . "\n\n";
+ } else {
+ $h{subcategory_line} = "\n\n";
+ }
+
+ $h{bodies_name} = join(_(' and '), @dear);
+ if ($h{category} eq _('Other')) {
+ $h{multiple} = @dear>1 ? "[ " . _("This email has been sent to both councils covering the location of the problem, as the user did not categorise it; please ignore it if you're not the correct council to deal with the issue, or let us know what category of problem this is so we can add it to our system.") . " ]\n\n"
+ : '';
+ } else {
+ $h{multiple} = @dear>1 ? "[ " . _("This email has been sent to several councils covering the location of the problem, as the category selected is provided for all of them; please ignore it if you're not the correct council to deal with the issue.") . " ]\n\n"
+ : '';
+ }
+ $h{missing} = '';
+ if ($missing) {
+ $h{missing} = '[ '
+ . sprintf(_('We realise this problem might be the responsibility of %s; however, we don\'t currently have any contact details for them. If you know of an appropriate contact address, please do get in touch.'), $missing->name)
+ . " ]\n\n";
+ }
+
if (mySociety::Config::get('STAGING_SITE') && !mySociety::Config::get('SEND_REPORTS_ON_STAGING')) {
# on a staging server send emails to ourselves rather than the bodies
- %reporters = map { $_ => $reporters{$_} } grep { /FixMyStreet::SendReport::(Email|NI|EmptyHomes)/ } keys %reporters;
+ %reporters = map { $_ => $reporters{$_} } grep { /FixMyStreet::SendReport::(Email|EmptyHomes)/ } keys %reporters;
unless (%reporters) {
%reporters = ( 'FixMyStreet::SendReport::Email' => FixMyStreet::SendReport::Email->new() );
}