aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/Angus.pm
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2015-12-17 17:07:58 +0000
committerDave Arter <davea@mysociety.org>2016-03-29 17:49:37 +0100
commit58a000d3095f0d3d327365af0f6d7bb4178bb5bb (patch)
treefca4112eb6f9a79031de4473ea721026e6b13b22 /perllib/FixMyStreet/Cobrand/Angus.pm
parentecb7e0ff7f75344d313c152a47790b32cbcf32b4 (diff)
[Angus] SOAP interface/send method for Angus CRM
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Angus.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand/Angus.pm73
1 files changed, 73 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Angus.pm b/perllib/FixMyStreet/Cobrand/Angus.pm
index 36d888744..a41d46205 100644
--- a/perllib/FixMyStreet/Cobrand/Angus.pm
+++ b/perllib/FixMyStreet/Cobrand/Angus.pm
@@ -46,4 +46,77 @@ sub contact_email {
return join( '@', 'accessline', 'angus.gov.uk' );
}
+=head2 temp_email_to_update, temp_update_contacts
+
+Temporary helper routines to update the extra for potholes (temporary setup
+hack, cargo-culted from Harrogate, may in future be superseded either by
+Open311/integration or a better mechanism for manually creating rich contacts).
+
+Can run with a script or command line like:
+
+ bin/cron-wrapper perl -MFixMyStreet::App -MFixMyStreet::Cobrand::Angus -e \
+ 'FixMyStreet::Cobrand::Angus->new({c => FixMyStreet::App->new})->temp_update_contacts'
+
+=cut
+
+sub temp_update_contacts {
+ my $self = shift;
+
+ my $contact_rs = $self->{c}->model('DB::Contact');
+
+ my $_update = sub {
+ my ($category, $field, $category_details) = @_;
+ # NB: we're accepting just 1 field, but supply as array [ $field ]
+
+ my $contact = $contact_rs->find_or_create(
+ {
+ body_id => $self->council_id,
+ category => $category,
+ %{ $category_details || {} },
+ },
+ {
+ key => 'contacts_body_id_category_idx'
+ }
+ );
+
+ my %default = (
+ variable => 'true',
+ order => '1',
+ required => 'no',
+ datatype => 'string',
+ datatype_description => 'a string',
+ );
+
+ if ($field->{datatype} || '' eq 'boolean') {
+ my $description = $field->{description};
+ %default = (
+ %default,
+ datatype => 'singlevaluelist',
+ datatype_description => 'Yes or No',
+ values => { value => [
+ { key => ['No'], name => ['No'] },
+ { key => ['Yes'], name => ['Yes'] },
+ ] },
+ );
+ }
+
+ $contact->update({
+ # XXX: we're just setting extra with the expected layout,
+ # this could be encapsulated more nicely
+ extra => { _fields => [ { %default, %$field } ] },
+ confirmed => 1,
+ deleted => 0,
+ editor => 'automated script',
+ whenedited => \'NOW()',
+ note => 'Edited by script as per requirements Jan 2016',
+ });
+ };
+
+ $_update->( 'Street lighting', {
+ code => 'column_id',
+ description => 'Column number',
+ });
+
+}
+
1;