diff options
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Bexley.pm')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bexley.pm | 81 |
1 files changed, 12 insertions, 69 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm index 481926e72..063a225b7 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley.pm @@ -3,10 +3,6 @@ use parent 'FixMyStreet::Cobrand::Whitelabel'; use strict; use warnings; -use Encode; -use JSON::MaybeXS; -use LWP::Simple qw($ua); -use Path::Tiny; use Time::Piece; sub council_area_id { 2494 } @@ -54,7 +50,7 @@ sub open311_munge_update_params { $params->{service_request_id_ext} = $comment->problem->id; - my $contact = $comment->problem->category_row; + my $contact = $comment->problem->contact; $params->{service_code} = $contact->email; } @@ -88,8 +84,8 @@ sub open311_config { $params->{multi_photos} = 1; } -sub open311_extra_data { - my ($self, $row, $h, $extra, $contact) = @_; +sub open311_extra_data_include { + my ($self, $row, $h, $contact) = @_; my $open311_only; if ($contact->email =~ /^Confirm/) { @@ -103,7 +99,7 @@ sub open311_extra_data { if (!$row->get_extra_field_value('site_code')) { if (my $ref = $self->lookup_site_code($row, 'NSG_REF')) { - push @$extra, { name => 'site_code', value => $ref, description => 'Site code' }; + $row->update_extra_field({ name => 'site_code', value => $ref, description => 'Site code' }); } } } elsif ($contact->email =~ /^Uniform/) { @@ -112,7 +108,7 @@ sub open311_extra_data { # WFS service at the point we're sending the report over Open311. if (!$row->get_extra_field_value('uprn')) { if (my $ref = $self->lookup_site_code($row, 'UPRN')) { - push @$extra, { name => 'uprn', description => 'UPRN', value => $ref }; + $row->update_extra_field({ name => 'uprn', description => 'UPRN', value => $ref }); } } } else { # Symology @@ -121,7 +117,7 @@ sub open311_extra_data { # WFS service at the point we're sending the report over Open311. if (!$row->get_extra_field_value('NSGRef')) { if (my $ref = $self->lookup_site_code($row, 'NSG_REF')) { - push @$extra, { name => 'NSGRef', description => 'NSG Ref', value => $ref }; + $row->update_extra_field({ name => 'NSGRef', description => 'NSG Ref', value => $ref }); } } } @@ -202,9 +198,6 @@ sub open311_post_send { $self->open311_config($row, $h, {}, $contact); # Populate NSGRef again if needed - my $extra_data = join "; ", map { "$_->{description}: $_->{value}" } @{$row->get_extra_fields}; - $h->{additional_information} = $extra_data; - $sender->send($row, $h); } @@ -216,71 +209,21 @@ sub email_list { return @to; } -sub dashboard_export_problems_add_columns { - my $self = shift; - my $c = $self->{c}; - - my %groups; - if ($c->stash->{body}) { - %groups = FixMyStreet::DB->resultset('Contact')->search({ - body_id => $c->stash->{body}->id, - })->group_lookup; - } - - splice @{$c->stash->{csv}->{headers}}, 5, 0, 'Subcategory'; - splice @{$c->stash->{csv}->{columns}}, 5, 0, 'subcategory'; - - $c->stash->{csv}->{extra_data} = sub { - my $report = shift; - - if ($groups{$report->category}) { - return { - category => $groups{$report->category}, - subcategory => $report->category, - }; - } - return {}; - }; -} - sub _is_out_of_hours { my $time = localtime; return 1 if $time->hour > 16 || ($time->hour == 16 && $time->min >= 45); return 1 if $time->hour < 8; return 1 if $time->wday == 1 || $time->wday == 7; - return 1 if _is_bank_holiday(); + return 1 if FixMyStreet::Cobrand::UK::is_public_holiday(); return 0; } -sub _is_bank_holiday { - my $json = _get_bank_holiday_json(); - my $today = localtime->date; - for my $event (@{$json->{'england-and-wales'}{events}}) { - if ($event->{date} eq $today) { - return 1; - } - } -} +sub update_anonymous_message { + my ($self, $update) = @_; + my $t = Utils::prettify_dt( $update->confirmed ); -sub _get_bank_holiday_json { - my $file = 'bank-holidays.json'; - my $cache_file = path(FixMyStreet->path_to("../data/$file")); - my $js; - if (-s $cache_file && -M $cache_file <= 7 && !FixMyStreet->config('STAGING_SITE')) { - # uncoverable statement - $js = $cache_file->slurp_utf8; - } else { - $ua->timeout(5); - $js = LWP::Simple::get("https://www.gov.uk/$file"); - # uncoverable branch false - $js = decode_utf8($js) if !utf8::is_utf8($js); - if ($js && !FixMyStreet->config('STAGING_SITE')) { - # uncoverable statement - $cache_file->spew_utf8($js); - } - } - $js = JSON->new->decode($js) if $js; - return $js; + my $staff = $update->user->from_body || $update->get_extra_metadata('is_body_user') || $update->get_extra_metadata('is_superuser'); + return sprintf('Posted anonymously by a non-staff user at %s', $t) if !$staff; } 1; |