aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-01-17 15:54:56 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-01-23 10:10:30 +0000
commit2f02c377f44bd2b7cc16f3fdbefb85ed5fa25fdb (patch)
treef42e906998ed0d1789b023f98cc3ec138501ea9e /perllib/FixMyStreet
parentf44ad2f067346cb3b03d3711fd658a5516e9fd0c (diff)
[Buckinghamshire] Question for on-road flytipping.
This adds a question to check whether a flytipping report concerns flytipping on a road or not. Client-side, it is asked when a road is selected and destination adjusted according to the answer; server side it uses the answer to direct any both-tier submissions (from e.g. non-JavaScript or phone app).
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm52
1 files changed, 52 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index c8432c4d7..75564fddd 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -109,6 +109,58 @@ sub open311_config_updates {
$params->{mark_reopen} = 1;
}
+sub open311_contact_meta_override {
+ my ($self, $service, $contact, $meta) = @_;
+
+ push @$meta, {
+ code => 'road-placement',
+ datatype => 'singlevaluelist',
+ description => 'Is the fly-tip located on',
+ order => 100,
+ required => 'true',
+ variable => 'true',
+ values => [
+ { key => 'road', name => 'The road' },
+ { key => 'off-road', name => 'Off the road/on a verge' },
+ ],
+ } if $service->{service_name} eq 'Flytipping';
+}
+
+sub process_open311_extras {
+ my ($self, $c, $body, $extra) = @_;
+
+ $self->flytipping_body_fix(
+ $c->stash->{report},
+ $c->get_param('road-placement'),
+ $c->stash->{field_errors},
+ );
+}
+
+sub flytipping_body_fix {
+ my ($self, $report, $road_placement, $errors) = @_;
+
+ return unless $report->category eq 'Flytipping';
+
+ if ($report->bodies_str =~ /,/) {
+ # Sent to both councils in the area
+ my @bodies = values %{$report->bodies};
+ my $county = (grep { $_->name =~ /^Buckinghamshire/ } @bodies)[0];
+ my $district = (grep { $_->name !~ /^Buckinghamshire/ } @bodies)[0];
+ # Decide which to send to based upon the answer to the extra question:
+ if ($road_placement eq 'road') {
+ $report->bodies_str($county->id);
+ } elsif ($road_placement eq 'off-road') {
+ $report->bodies_str($district->id);
+ }
+ } else {
+ # If the report is only being sent to the district, we do
+ # not care about the road question, if it is missing
+ if (!$report->to_body_named('Buckinghamshire')) {
+ delete $errors->{'road-placement'};
+ }
+ }
+}
+
sub filter_report_description {
my ($self, $description) = @_;