aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-05-17 13:04:50 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-06-04 09:57:38 +0100
commite26b6d32a8b15ea617343996a509c16f1eefd811 (patch)
treef302da32577a071b2a9cf95c93b585f648c7298d
parent5b66cc7fc8f48a09cb6ca6ab6988f8a1d8e5c8ba (diff)
[Open311] Factor cobrand overrides to functions.
[Stevenage] Make sure Other included, like East Herts.
-rw-r--r--perllib/Open311/PopulateServiceList.pm42
1 files changed, 28 insertions, 14 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index ac9f156ae..d283beb0f 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -237,6 +237,14 @@ 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);
+
+ $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');
@@ -264,11 +272,8 @@ sub _add_meta_to_contact {
if (my $override = $override{ $self->_current_body->name }) {
my %ignore = map { $_ => 1 } @{ $override };
- @meta = grep { ! $ignore{ $_->{ code } } } @meta;
+ @$meta = grep { ! $ignore{ $_->{ code } } } @$meta;
}
-
- $contact->set_extra_fields(@meta);
- $contact->update;
}
sub _normalize_service_name {
@@ -296,6 +301,21 @@ sub _delete_contacts_not_in_service_list {
}
);
+ $found_contacts = $self->_delete_contacts_not_in_service_list_cobrand_overrides($found_contacts);
+
+ $found_contacts->update(
+ {
+ state => 'deleted',
+ editor => $0,
+ whenedited => \'current_timestamp',
+ note => 'automatically marked as deleted by script'
+ }
+ );
+}
+
+sub _delete_contacts_not_in_service_list_cobrand_overrides {
+ my ( $self, $found_contacts ) = @_;
+
# for Warwickshire/Bristol/BANES, which are mixed Open311 and email, don't delete
# the email addresses
if ($self->_current_body->name eq 'Warwickshire County Council' ||
@@ -306,8 +326,9 @@ sub _delete_contacts_not_in_service_list {
email => { -not_like => '%@%' }
}
);
- } elsif ($self->_current_body->name eq 'East Hertfordshire District Council') {
- # For EHDC we need to leave the 'Other' category alone or reports made
+ } elsif ($self->_current_body->name eq 'East Hertfordshire District Council' ||
+ $self->_current_body->name eq 'Stevenage Borough Council') {
+ # For EHDC/Stevenage we need to leave the 'Other' category alone or reports made
# in this category will be sent only to Hertfordshire County Council.
$found_contacts = $found_contacts->search(
{
@@ -316,14 +337,7 @@ sub _delete_contacts_not_in_service_list {
);
}
- $found_contacts->update(
- {
- state => 'deleted',
- editor => $0,
- whenedited => \'current_timestamp',
- note => 'automatically marked as deleted by script'
- }
- );
+ return $found_contacts;
}
1;