diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 18 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 6 |
4 files changed, 27 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 66b46877f..c853827d0 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -362,13 +362,19 @@ sub update_contacts : Private { $contact->api_key( $c->get_param('api_key') ); $contact->send_method( $c->get_param('send_method') ); - # Set the photo_required flag in extra to the appropriate value + # Set flags in extra to the appropriate values if ( $c->get_param('photo_required') ) { $contact->set_extra_metadata_if_undefined( photo_required => 1 ); } else { $contact->unset_extra_metadata( 'photo_required' ); } + if ( $c->get_param('inspection_required') ) { + $contact->set_extra_metadata( inspection_required => 1 ); + } + else { + $contact->unset_extra_metadata( 'inspection_required' ); + } if ( %errors ) { $c->stash->{updated} = _('Please correct the errors below'); diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 2f6418886..7f1132117 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -318,13 +318,17 @@ sub inspect : Private { } } - if ( $c->get_param('save') ) { + if ( $c->get_param('save') || $c->get_param('save_inspected') ) { $c->forward('/auth/check_csrf_token'); foreach (qw/priority detailed_location detailed_information traffic_information/) { $problem->set_extra_metadata( $_ => $c->get_param($_) ); } + if ( $c->get_param('save_inspected') ) { + $problem->set_extra_metadata( inspected => 1 ); + } + # Handle the state changing my $old_state = $problem->state; $problem->state($c->get_param('state')); diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index a58f50b18..b5487ea5b 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -860,25 +860,25 @@ sub get_report_stats { return 0; } sub get_body_sender { my ( $self, $body, $category ) = @_; + # look up via category + my $contact = $body->contacts->search( { category => $category } )->first; if ( $body->can_be_devolved ) { - # look up via category - my $config = $body->result_source->schema->resultset("Contact")->search( { body_id => $body->id, category => $category } )->first; - if ( $config->send_method ) { - return { method => $config->send_method, config => $config }; + if ( $contact->send_method ) { + return { method => $contact->send_method, config => $contact, contact => $contact }; } else { - return { method => $body->send_method, config => $body }; + return { method => $body->send_method, config => $body, contact => $contact }; } } elsif ( $body->send_method ) { - return { method => $body->send_method, config => $body }; + return { method => $body->send_method, config => $body, contact => $contact }; } - return $self->_fallback_body_sender( $body, $category ); + return $self->_fallback_body_sender( $body, $category, $contact ); } sub _fallback_body_sender { - my ( $self, $body, $category ) = @_; + my ( $self, $body, $category, $contact ) = @_; - return { method => 'Email' }; + return { method => 'Email', contact => $contact }; }; sub example_places { diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index a51923456..ab0d90ba8 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -143,6 +143,12 @@ sub send(;$) { } $reporters{ $sender } ||= $sender->new(); + my $inspection_required = $sender_info->{contact}->get_extra_metadata('inspection_required') if $sender_info->{contact}; + if ( $inspection_required && !$row->get_extra_metadata('inspected') ) { + $skip = 1; + debug_print("skipped because not yet inspected", $row->id) if $debug_mode; + } + if ( $reporters{ $sender }->should_skip( $row ) ) { $skip = 1; debug_print("skipped by sender " . $sender_info->{method} . " (might be due to previous failed attempts?)", $row->id) if $debug_mode; |