diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 60 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 11 |
5 files changed, 64 insertions, 31 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 98c4aba17..1e5751588 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -467,7 +467,7 @@ sub inspect : Private { } } - if ( $c->get_param('include_update') ) { + if ( $c->get_param('include_update') or $c->get_param('raise_defect') ) { $update_text = Utils::cleanup_text( $c->get_param('public_update'), { allow_multiline => 1 } ); if (!$update_text) { $valid = 0; @@ -512,6 +512,14 @@ sub inspect : Private { }; $c->user->create_alert($problem->id, $options); } + + # If the state has been changed to action scheduled and they've said + # they want to raise a defect, consider the report to be inspected. + if ($problem->state eq 'action scheduled' && $c->get_param('raise_defect') && !$problem->get_extra_metadata('inspected')) { + $update_params{extra} = { 'defect_raised' => 1 }; + $problem->set_extra_metadata( inspected => 1 ); + $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'inspected' ] ); + } } $problem->non_public($c->get_param('non_public') ? 1 : 0); diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 2dfb0d7b1..e58bceb2a 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -1286,14 +1286,6 @@ sub category_extra_hidden { return 0; } -sub traffic_management_options { - return [ - _("Yes"), - _("No"), - ]; -} - - =item display_days_ago_threshold Used to control whether a relative 'n days ago' or absolute date is shown diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index 0f34ff09f..97174e1ce 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -155,6 +155,48 @@ sub open311_post_send { $row->detail($self->{ox_original_detail}); } +sub open311_munge_update_params { + my ($self, $params, $comment, $body) = @_; + + if ($comment->get_extra_metadata('defect_raised')) { + my $p = $comment->problem; + my ($e, $n) = $p->local_coords; + my $usrn = $p->get_extra_field_value('usrn'); + if (!$usrn) { + my $cfg = { + url => 'https://tilma.mysociety.org/mapserver/oxfordshire', + typename => "OCCRoads", + srsname => 'urn:ogc:def:crs:EPSG::27700', + accept_feature => sub { 1 }, + filter => "<Filter xmlns:gml=\"http://www.opengis.net/gml\"><DWithin><PropertyName>SHAPE_GEOMETRY</PropertyName><gml:Point><gml:coordinates>$e,$n</gml:coordinates></gml:Point><Distance units='m'>20</Distance></DWithin></Filter>", + }; + my $features = $self->_fetch_features($cfg); + my $feature = $self->_nearest_feature($cfg, $e, $n, $features); + if ($feature) { + my $props = $feature->{properties}; + $usrn = Utils::trim_text($props->{TYPE1_2_USRN}); + } + } + $params->{'attribute[usrn]'} = $usrn; + $params->{'attribute[raise_defect]'} = 1; + $params->{'attribute[easting]'} = $e; + $params->{'attribute[northing]'} = $n; + my $details = $comment->user->email . ' '; + if (my $traffic = $p->get_extra_metadata('traffic_information')) { + $details .= 'TM1 ' if $traffic eq 'Signs and Cones'; + $details .= 'TM2 ' if $traffic eq 'Stop and Go Boards'; + } + (my $type = $p->get_extra_metadata('defect_item_type')) =~ s/ .*//; + $details .= $type eq 'Sweep' ? 'S&F' : $type; + $details .= ' ' . ($p->get_extra_metadata('detailed_information') || ''); + $params->{'attribute[extra_details]'} = $details; + + foreach (qw(defect_item_category defect_item_type defect_item_detail defect_location_description)) { + $params->{"attribute[$_]"} = $p->get_extra_metadata($_); + } + } +} + sub should_skip_sending_update { my ($self, $update ) = @_; @@ -168,18 +210,20 @@ sub should_skip_sending_update { return 0; } -sub on_map_default_status { return 'open'; } -sub admin_user_domain { 'oxfordshire.gov.uk' } +sub report_inspect_update_extra { + my ( $self, $problem ) = @_; -sub traffic_management_options { - return [ - "Signs and Cones", - "Stop and Go Boards", - "High Speed Roads", - ]; + 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' } + sub admin_pages { my $self = shift; diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index f472876ef..0e8341d57 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -425,7 +425,7 @@ sub _nearest_feature { # We have a list of features, and we want to find the one closest to the # report location. - my $site_code = ''; + my $chosen = ''; my $nearest; # We shouldn't receive anything aside from these geometry types, but belt and braces. @@ -452,14 +452,14 @@ sub _nearest_feature { for (my $i=0; $i<@$coordinates-1; $i++) { my $distance = $self->_distanceToLine($x, $y, $coordinates->[$i], $coordinates->[$i+1]); if ( !defined $nearest || $distance < $nearest ) { - $site_code = $feature->{properties}->{$cfg->{property}}; + $chosen = $feature; $nearest = $distance; } } } } - return $site_code; + return $cfg->{property} && $chosen ? $chosen->{properties}->{$cfg->{property}} : $chosen; } sub contact_name { diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index cd5e876b4..ceb41b40f 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -1125,17 +1125,6 @@ has duplicates => ( }, ); -has traffic_management_options => ( - is => 'ro', - lazy => 1, - default => sub { - my $self = shift; - my $cobrand = $self->get_cobrand_logged; - $cobrand = $cobrand->call_hook(get_body_handler_for_problem => $self) || $cobrand; - return $cobrand->traffic_management_options; - }, -); - has inspection_log_entry => ( is => 'ro', lazy => 1, |