aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm4
-rw-r--r--perllib/FixMyStreet/App/Controller/Root.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Bexley.pm43
-rw-r--r--perllib/FixMyStreet/Cobrand/Rutland.pm4
-rw-r--r--perllib/Open311.pm11
5 files changed, 55 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index f2f411635..9b90da161 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -1,5 +1,6 @@
package FixMyStreet::App::Controller::Report;
+use utf8;
use Moose;
use namespace::autoclean;
use JSON::MaybeXS;
@@ -156,9 +157,10 @@ sub load_problem_or_display_error : Private {
my $permissions = $c->stash->{_permissions} = $c->forward( 'check_has_permission_to',
[ qw/report_inspect report_edit_category report_edit_priority report_mark_private / ] );
if ( !$c->user || ($c->user->id != $problem->user->id && !($permissions->{report_inspect} || $permissions->{report_mark_private})) ) {
+ my $url = '/auth?r=report/' . $problem->id;
$c->detach(
'/page_error_403_access_denied',
- [ sprintf(_('That report cannot be viewed on %s.'), $c->stash->{site_name}) ]
+ [ sprintf(_('Sorry, you don’t have permission to do that. If you are the problem reporter, or a member of staff, please <a href="%s">sign in</a> to view this report.'), $url) ]
);
}
}
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index 340c930c2..2c7e28e5f 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -122,7 +122,9 @@ sub page_error_410_gone : Private {
sub page_error_403_access_denied : Private {
my ( $self, $c, $error_msg ) = @_;
- $c->detach('page_error', [ $error_msg || _("Sorry, you don't have permission to do that."), 403 ]);
+ $c->stash->{title} = _('Access denied');
+ $error_msg ||= _("Sorry, you don't have permission to do that.");
+ $c->detach('page_error', [ $error_msg, 403 ]);
}
sub page_error_400_bad_request : Private {
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm
index d398bb670..d3787ef67 100644
--- a/perllib/FixMyStreet/Cobrand/Bexley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bexley.pm
@@ -85,17 +85,44 @@ sub open311_post_send {
# Check Open311 was successful
return unless $row->external_id;
- return unless $row->category eq 'Abandoned and untaxed vehicles'
- || $row->category eq 'Dead animal';
+ if ($row->category eq 'Abandoned and untaxed vehicles') {
+ my $burnt = $row->get_extra_field_value('burnt') || '';
+ return unless $burnt eq 'Yes';
+ }
- my $mb = FixMyStreet->config('STAGING_SITE') ? 'digital-team' : 'P1sfromContactCentre';
- my $e = join('@', $mb, $self->admin_user_domain);
- my $sender = FixMyStreet::SendReport::Email->new( to => [ [ $e, 'Bexley P1 email' ] ] );
+ my @lighting = (
+ 'Lamp post',
+ 'Light in multi-storey car park',
+ 'Light in outside car park',
+ 'Light in park or open space',
+ 'Traffic bollard',
+ 'Traffic sign light',
+ 'Underpass light',
+ 'Zebra crossing light',
+ );
+ my %lighting = map { $_ => 1 } @lighting;
+
+ my $emails = $self->feature('open311_email') || return;
+ my $dangerous = $row->get_extra_field_value('dangerous') || '';
+ my $reportType = $row->get_extra_field_value('reportType') || '';
+
+ my $p1_email = 0;
+ if ($row->category eq 'Parks and open spaces') {
+ $p1_email = 1 if $reportType =~ /locked in a park|Wild animal/;
+ $p1_email = 1 if $dangerous eq 'Yes' && $reportType =~ /Playgrounds|park furniture|gates are broken|Vandalism|Other/;
+ } else {
+ $p1_email = 1 if $dangerous eq 'Yes';
+ }
- if ($row->category eq 'Abandoned and untaxed vehicles') {
- my ($burnt) = grep { $_->{name} eq 'burnt' } @{$row->get_extra_fields};
- return unless $burnt && $burnt->{value} eq 'Yes';
+ my @to;
+ if ($row->category eq 'Abandoned and untaxed vehicles' || $row->category eq 'Dead animal' || $p1_email) {
+ push @to, [ $emails->{p1}, 'Bexley P1 email' ] if $emails->{p1};
+ }
+ if ($lighting{$row->category}) {
+ push @to, [ $emails->{lighting}, 'FixMyStreet Bexley Street Lighting' ] if $emails->{lighting};
}
+ return unless @to;
+ my $sender = FixMyStreet::SendReport::Email->new( to => \@to );
$self->open311_config($row); # Populate NSGRef again if needed
diff --git a/perllib/FixMyStreet/Cobrand/Rutland.pm b/perllib/FixMyStreet/Cobrand/Rutland.pm
index 407d43d14..97bcfe637 100644
--- a/perllib/FixMyStreet/Cobrand/Rutland.pm
+++ b/perllib/FixMyStreet/Cobrand/Rutland.pm
@@ -12,6 +12,10 @@ sub council_url { return 'rutland'; }
sub report_validation {
my ($self, $report, $errors) = @_;
+ if ( length( $report->title ) > 254 ) {
+ $errors->{title} = sprintf( _('Summaries are limited to %s characters in length. Please shorten your summary'), 254 );
+ }
+
if ( length( $report->name ) > 40 ) {
$errors->{name} = sprintf( _('Names are limited to %d characters in length.'), 40 );
}
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index a902a7213..ebf3ee987 100644
--- a/perllib/Open311.pm
+++ b/perllib/Open311.pm
@@ -8,6 +8,7 @@ use XML::Simple;
use LWP::Simple;
use LWP::UserAgent;
use DateTime::Format::W3CDTF;
+use Encode;
use HTTP::Request::Common qw(GET POST);
use FixMyStreet::Cobrand;
use FixMyStreet::DB;
@@ -495,11 +496,19 @@ sub _request {
my $debug_request = $method . ' ' . $uri->as_string . "\n\n";
my $req = do {
+ $params = {
+ map {
+ my $value = $params->{$_};
+ $_ => ref $value eq 'ARRAY'
+ ? [ map { encode('UTF-8', $_) } @$value ]
+ : encode('UTF-8', $value)
+ } keys %$params
+ };
if ($method eq 'GET') {
$uri->query_form( $params );
GET $uri->as_string;
} elsif ($method eq 'POST') {
- if ($uploads) {
+ if ($uploads && %$uploads) {
# HTTP::Request::Common needs to be constructed slightly
# differently if there are files to upload.