From 90d23fc7b21f4391aeb92418e212195a18d72d5e Mon Sep 17 00:00:00 2001 From: M Somerville Date: Tue, 11 Aug 2020 15:46:06 +0100 Subject: [Oxfordshire] Extra questions for raising defect. --- perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 14 ++++ t/app/controller/report_inspect.t | 2 + t/cobrand/oxfordshire.t | 5 ++ .../oxfordshire/report/inspect/_raise_defect.html | 74 +++++++++++++++++++++- 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index 34e21ddfc..ab0bfe563 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -181,6 +181,10 @@ sub open311_munge_update_params { $params->{'attribute[raise_defect]'} = 1; $params->{'attribute[easting]'} = $e; $params->{'attribute[northing]'} = $n; + + foreach (qw(defect_item_category defect_item_type defect_item_detail defect_location_description)) { + $params->{"attribute[$_]"} = $p->get_extra_metadata($_); + } } } @@ -197,6 +201,16 @@ sub should_skip_sending_update { return 0; } + +sub report_inspect_update_extra { + my ( $self, $problem ) = @_; + + foreach (qw(defect_item_category defect_item_type defect_item_detail defect_location_description)) { + my $value = $self->{c}->get_param($_); + $problem->set_extra_metadata($_ => $value) if $value; + } +} + sub on_map_default_status { return 'open'; } sub admin_user_domain { 'oxfordshire.gov.uk' } diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 367327c16..d5eaed2c1 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -920,10 +920,12 @@ FixMyStreet::override_config { $mech->submit_form_ok({ button => 'save', with_fields => { public_update => "This is a public update.", include_update => "1", state => 'action scheduled', raise_defect => 1, + defect_item_category => 'Kerbing', } }); $report2->discard_changes; is $report2->get_extra_metadata('inspected'), 1, 'report marked as inspected'; $mech->get_ok("/report/$report2_id"); + $mech->content_like(qr/Defect category<\/dt>\s*
Kerbing/); my $meta = $mech->extract_update_metas; like $meta->[0], qr/State changed to: Action scheduled/, 'First update mentions action scheduled'; like $meta->[1], qr/Posted by .*defect raised/, 'Update mentions defect raised'; diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index b5e51e808..8a1ad1429 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -184,6 +184,10 @@ FixMyStreet::override_config { $comment->set_extra_metadata(defect_raised => 1); $comment->update; $comment->problem->external_id('hey'); + $comment->problem->set_extra_metadata(defect_location_description => 'Location'); + $comment->problem->set_extra_metadata(defect_item_category => 'Kerbing'); + $comment->problem->set_extra_metadata(defect_item_type => 'Damaged'); + $comment->problem->set_extra_metadata(defect_item_detail => '1 kerb unit or 1 linear m'); $comment->problem->update; my $cbr = Test::MockModule->new('FixMyStreet::Cobrand::Oxfordshire'); @@ -210,6 +214,7 @@ FixMyStreet::override_config { my $cgi = CGI::Simple->new($o->test_req_used->content); is $cgi->param('attribute[usrn]'), 13579, 'USRN sent with update'; is $cgi->param('attribute[raise_defect]'), 1, 'Defect flag sent with update'; + is $cgi->param('attribute[defect_item_category]'), 'Kerbing'; # Now set a USRN on the problem (found at submission) $comment->problem->push_extra_fields({ name => 'usrn', value => '12345' }); diff --git a/templates/web/oxfordshire/report/inspect/_raise_defect.html b/templates/web/oxfordshire/report/inspect/_raise_defect.html index 5783def48..b2cdf7487 100644 --- a/templates/web/oxfordshire/report/inspect/_raise_defect.html +++ b/templates/web/oxfordshire/report/inspect/_raise_defect.html @@ -1,11 +1,79 @@ -[% IF permissions.report_instruct AND NOT problem.get_extra_metadata('inspected') %] +[% IF permissions.report_instruct %] + +[% IF problem.get_extra_metadata('inspected') AND NOT errors %] + +
+
Defect category
+
[% problem.get_extra_metadata('defect_item_category') %]
+ +
Defect type
+
[% problem.get_extra_metadata('defect_item_type') %]
+ +
Defect detail
+
[% problem.get_extra_metadata('defect_item_detail') %]
+ +
Location description
+
[% problem.get_extra_metadata('defect_location_description') %]
+
+ +[% ELSE %] +
+

[% loc('Do you want to automatically raise a defect?') %]

- + - +

+ +
+ +

Please fill in the below:

+ + + + + + + + + + + + + +
+
+ +[% END %] + [% END %] -- cgit v1.2.3