diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Location.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Moderate.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestAppProve.pm | 4 |
9 files changed, 51 insertions, 24 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 719b04cf6..82041a6b1 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -913,7 +913,7 @@ sub report_edit : Path('report_edit') : Args(1) { } $problem->set_inflated_columns(\%columns); - $c->forward( '/admin/report_edit_category', [ $problem ] ); + $c->forward( '/admin/report_edit_category', [ $problem, $problem->state ne $old_state ] ); $c->forward('update_user', [ $problem ]); # Deal with photos @@ -935,6 +935,27 @@ sub report_edit : Path('report_edit') : Args(1) { if ( $problem->state ne $old_state ) { $c->forward( 'log_edit', [ $id, 'problem', 'state_change' ] ); + + my $name = _('an adminstrator'); + my $extra = { is_superuser => 1 }; + if ($c->user->from_body) { + $name = $c->user->from_body->name; + delete $extra->{is_superuser}; + $extra->{is_body_user} = $c->user->from_body->id; + } + my $timestamp = \'current_timestamp'; + $problem->add_to_comments( { + text => $c->stash->{update_text} || '', + created => $timestamp, + confirmed => $timestamp, + user_id => $c->user->id, + name => $name, + mark_fixed => 0, + anonymous => 0, + state => 'confirmed', + problem_state => $problem->state, + extra => $extra + } ); } $c->forward( 'log_edit', [ $id, 'problem', 'edit' ] ); diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 30c023317..6af780c35 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -339,10 +339,8 @@ sub _geocode : Private { } else { if ( ref($suggestions) eq 'ARRAY' ) { foreach (@$suggestions) { - my $address = $_->{address}; - $address = decode_utf8($address) if !utf8::is_utf8($address); - push @addresses, $address; - push @locations, { address => $address, lat => $_->{latitude}, long => $_->{longitude} }; + push @addresses, $_->{address}; + push @locations, { address => $_->{address}, lat => $_->{latitude}, long => $_->{longitude} }; } $response = { suggestions => \@addresses, locations => \@locations }; } else { diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm index c457c8fce..cb2077ede 100644 --- a/perllib/FixMyStreet/App/Controller/Location.pm +++ b/perllib/FixMyStreet/App/Controller/Location.pm @@ -96,7 +96,6 @@ sub determine_location_from_pc : Private { if ( ref($error) eq 'ARRAY' ) { foreach (@$error) { my $a = $_->{address}; - $a = decode_utf8($a) if !utf8::is_utf8($a); $a =~ s/, United Kingdom//; $a =~ s/, UK//; $_->{address} = $a; diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm index 1313b5071..42dc759e5 100644 --- a/perllib/FixMyStreet/App/Controller/Moderate.pm +++ b/perllib/FixMyStreet/App/Controller/Moderate.pm @@ -85,7 +85,7 @@ sub moderate_report : Chained('report') : PathPart('') : Args(0) { sub moderating_user_name { my $user = shift; - return $user->from_body ? $user->from_body->name : 'a FixMyStreet administrator'; + return $user->from_body ? $user->from_body->name : _('an administrator'); } sub report_moderate_audit : Private { diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 1258c8bca..b482d7612 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -7,7 +7,6 @@ use FixMyStreet; use FixMyStreet::DB; use FixMyStreet::Geocode::Bing; use DateTime; -use Encode; use List::MoreUtils 'none'; use URI; use Digest::MD5 qw(md5_hex); @@ -897,9 +896,8 @@ sub _fallback_body_sender { }; sub example_places { - my $e = FixMyStreet->config('EXAMPLE_PLACES') || [ 'High Street', 'Main Street' ]; - $e = [ map { Encode::decode('UTF-8', $_) } @$e ]; - return $e; + # uncoverable branch true + FixMyStreet->config('EXAMPLE_PLACES') || [ 'High Street', 'Main Street' ]; } =head2 title_list diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index de4a5262a..4dc95b178 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -994,7 +994,6 @@ sub _admin_send_email { my $sender = FixMyStreet->config('DO_NOT_REPLY_EMAIL'); my $sender_name = $c->cobrand->contact_name; - utf8::decode($sender_name) unless utf8::is_utf8($sender_name); $c->send_email( $template, { to => [ $to ], diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 409a6e1ab..60fd31510 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -229,13 +229,24 @@ sub meta_line { if ($self->anonymous or !$self->name) { $meta = sprintf( _( 'Posted anonymously at %s' ), Utils::prettify_dt( $self->confirmed ) ) - } elsif ($self->user->from_body) { + } elsif ($self->user->from_body || $self->get_extra_metadata('is_body_user') || $self->get_extra_metadata('is_superuser') ) { my $user_name = FixMyStreet::Template::html_filter($self->user->name); - my $body = $self->user->body; - if ($body eq 'Bromley Council') { - $body = "$body <img src='/cobrands/bromley/favicon.png' alt=''>"; - } elsif ($body eq 'Royal Borough of Greenwich') { - $body = "$body <img src='/cobrands/greenwich/favicon.png' alt=''>"; + my $body; + if ($self->get_extra_metadata('is_superuser')) { + $body = _('an administrator'); + } else { + # use this meta data in preference to the user's from_body setting + # in case they are no longer with the body, or have changed body. + if (my $body_id = $self->get_extra_metadata('is_body_user')) { + $body = FixMyStreet::App->model('DB::Body')->find({id => $body_id})->name; + } else { + $body = $self->user->body; + } + if ($body eq 'Bromley Council') { + $body = "$body <img src='/cobrands/bromley/favicon.png' alt=''>"; + } elsif ($body eq 'Royal Borough of Greenwich') { + $body = "$body <img src='/cobrands/greenwich/favicon.png' alt=''>"; + } } my $can_view_contribute = $c->user_exists && $c->user->has_permission_to('view_body_contribute_details', $self->problem->bodies_str_ids); if ($self->text) { diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index b5bb7249c..dd1adfe71 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -73,18 +73,19 @@ sub cache { my $cache_file = $cache_dir->child(md5_hex($url)); my $js; if (-s $cache_file && -M $cache_file <= 7 && !FixMyStreet->config('STAGING_SITE')) { - $js = $cache_file->slurp; + # uncoverable statement + $js = $cache_file->slurp_utf8; } else { $url .= '&' . $args if $args; $ua->timeout(15); $js = LWP::Simple::get($url); - $js = encode_utf8($js) if utf8::is_utf8($js); $cache_dir->mkpath; if ($js && (!$re || $js !~ $re) && !FixMyStreet->config('STAGING_SITE')) { - $cache_file->spew($js); + # uncoverable statement + $cache_file->spew_utf8($js); } } - $js = JSON->new->utf8->allow_nonref->decode($js) if $js; + $js = JSON->new->allow_nonref->decode($js) if $js; return $js; } diff --git a/perllib/FixMyStreet/TestAppProve.pm b/perllib/FixMyStreet/TestAppProve.pm index 7a387547d..d549b0148 100644 --- a/perllib/FixMyStreet/TestAppProve.pm +++ b/perllib/FixMyStreet/TestAppProve.pm @@ -86,8 +86,8 @@ sub run { $config->{FMS_DB_PASS} = ''; } - my $config_out = "general-test-autogenerated.$$"; - path("conf/$config_out.yml")->spew( YAML::Dump($config) ); + my $config_out = "general-test-autogenerated.$$.yml"; + path("conf/$config_out")->spew( YAML::Dump($config) ); local $ENV{FMS_OVERRIDE_CONFIG} = $config_out; |