diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 39 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Warwickshire.pm | 8 | ||||
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 58 |
3 files changed, 51 insertions, 54 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 11c685c91..386e1a269 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -196,5 +196,44 @@ sub open311_pre_send { } } +sub open311_contact_meta_override { + my ($self, $service, $contact, $meta) = @_; + + $contact->set_extra_metadata( id_field => 'service_request_id_ext'); + + # Lights we want to store feature ID, PROW on all categories. + push @$meta, { + code => 'prow_reference', + datatype => 'string', + description => 'Right of way reference', + order => 101, + required => 'false', + variable => 'true', + automated => 'hidden_field', + }; + push @$meta, { + code => 'feature_id', + datatype => 'string', + description => 'Feature ID', + order => 100, + required => 'false', + variable => 'true', + automated => 'hidden_field', + } if $service->{service_code} eq 'SLRS'; + + my @override = qw( + requested_datetime + report_url + title + last_name + email + report_title + public_anonymity_required + email_alerts_requested + ); + my %ignore = map { $_ => 1 } @override; + @$meta = grep { !$ignore{$_->{code}} } @$meta; +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Warwickshire.pm b/perllib/FixMyStreet/Cobrand/Warwickshire.pm index 73f66f3da..c301450bc 100644 --- a/perllib/FixMyStreet/Cobrand/Warwickshire.pm +++ b/perllib/FixMyStreet/Cobrand/Warwickshire.pm @@ -34,4 +34,12 @@ sub contact_name { 'Warwickshire County Council (do not reply)'; } sub send_questionnaires { 0 } +sub open311_contact_meta_override { + my ($self, $service, $contact, $meta) = @_; + + $contact->set_extra_metadata( id_field => 'external_id'); + + @$meta = grep { $_->{code} ne 'closest_address' } @$meta; +} + 1; diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index 0bbd902ed..d506111ec 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -233,65 +233,15 @@ sub _add_meta_to_contact { # Some Open311 endpoints, such as Bromley and Warwickshire send <metadata> # for attributes which we *don't* want to display to the user (e.g. as - # fields in "category_extras" - $self->_add_meta_to_contact_cobrand_overrides($contact, \@meta); + # fields in "category_extras"), or need additional attributes adding not + # returned by the server for whatever reason. + $self->_current_body_cobrand && $self->_current_body_cobrand->call_hook( + open311_contact_meta_override => $self->_current_service, $contact, \@meta); $contact->set_extra_fields(@meta); $contact->update; } -sub _add_meta_to_contact_cobrand_overrides { - my ( $self, $contact, $meta ) = @_; - - if ($self->_current_body->name eq 'Bromley Council') { - $contact->set_extra_metadata( id_field => 'service_request_id_ext'); - # Lights we want to store feature ID, PROW on all categories. - push @$meta, { - code => 'prow_reference', - datatype => 'string', - description => 'Right of way reference', - order => 101, - required => 'false', - variable => 'true', - automated => 'hidden_field', - }; - push @$meta, { - code => 'feature_id', - datatype => 'string', - description => 'Feature ID', - order => 100, - required => 'false', - variable => 'true', - automated => 'hidden_field', - } if $self->_current_service->{service_code} eq 'SLRS'; - } elsif ($self->_current_body->name eq 'Warwickshire County Council') { - $contact->set_extra_metadata( id_field => 'external_id'); - } - - my %override = ( - #2482 - 'Bromley Council' => [qw( - requested_datetime - report_url - title - last_name - email - report_title - public_anonymity_required - email_alerts_requested - ) ], - #2243, - 'Warwickshire County Council' => [qw( - closest_address - ) ], - ); - - if (my $override = $override{ $self->_current_body->name }) { - my %ignore = map { $_ => 1 } @{ $override }; - @$meta = grep { ! $ignore{ $_->{ code } } } @$meta; - } -} - sub _normalize_service_name { my $self = shift; |