diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Waste.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 22 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UK.pm | 6 |
3 files changed, 29 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Waste.pm b/perllib/FixMyStreet/App/Controller/Waste.pm index e606b1d8c..7556781cf 100644 --- a/perllib/FixMyStreet/App/Controller/Waste.pm +++ b/perllib/FixMyStreet/App/Controller/Waste.pm @@ -217,7 +217,7 @@ sub construct_bin_report_form { my $field_list = []; foreach (@{$c->stash->{service_data}}) { - next unless $_->{last}; + next unless $_->{last} && $_->{report_allowed}; my $id = $_->{service_id}; my $name = $_->{service_name}; push @$field_list, "service-$id" => { diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index ed96eb1bb..176762323 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -10,6 +10,7 @@ use Integrations::Echo; use Sort::Key::Natural qw(natkeysort_inplace); use Try::Tiny; use FixMyStreet::DateRange; +use FixMyStreet::WorkingDays; sub council_area_id { return 2482; } sub council_area { return 'Bromley'; } @@ -507,6 +508,7 @@ sub bin_services_for_address { id => $_->{Id}, service_id => $_->{ServiceId}, service_name => $service_name_override{$_->{ServiceId}} || $_->{ServiceName}, + report_allowed => within_working_days($schedules->{last}{date}, 2), request_allowed => $request_allowed{$_->{ServiceId}}, request_containers => $containers, request_max => $quantity_max{$_->{ServiceId}}, @@ -590,4 +592,24 @@ sub bin_future_collections { return $events; } +=over + +=item within_working_days + +Given a DateTime object and a number, return true if today is less than or +equal to that number of working days (excluding weekends and bank holidays) +after the date. + +=back + +=cut + +sub within_working_days { + my ($dt, $days) = @_; + my $wd = FixMyStreet::WorkingDays->new(public_holidays => FixMyStreet::Cobrand::UK::public_holidays()); + $dt = $wd->add_days($dt, $days)->ymd; + my $today = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->ymd; + return $today le $dt; +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm index 3ede055b9..988458e0f 100644 --- a/perllib/FixMyStreet/Cobrand/UK.pm +++ b/perllib/FixMyStreet/Cobrand/UK.pm @@ -452,6 +452,12 @@ sub check_recaptcha { unless $res->{success}; } +sub public_holidays { + my $nation = shift || 'england-and-wales'; + my $json = _get_bank_holiday_json(); + return [ map { $_->{date} } @{$json->{$nation}{events}} ]; +} + sub is_public_holiday { my %args = @_; $args{date} ||= localtime; |