1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
package FixMyStreet::Cobrand::Angus;
use parent 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
sub council_id { return 2550; }
sub council_area { return 'Angus'; }
sub council_name { return 'Angus Council'; }
sub council_url { return 'angus'; }
sub base_url {
my $self = shift;
return $self->next::method() if FixMyStreet->config('STAGING_SITE');
return 'https://fix.angus.gov.uk';
}
sub enter_postcode_text {
my ($self) = @_;
return 'Enter an Angus postcode, or street name and area';
}
sub example_places {
return ( 'DD8 3AP', "Canmore Street" );
}
sub default_show_name { 0 }
sub disambiguate_location {
my $self = shift;
my $string = shift;
return {
%{ $self->SUPER::disambiguate_location() },
town => 'Angus',
centre => '56.7240845983561,-2.91774391131183',
span => '0.525195055746977,0.985870680170788',
bounds => [ 56.4616875530489, -3.40703662677109, 56.9868826087959, -2.4211659466003 ],
};
}
sub pin_colour {
my ( $self, $p, $context ) = @_;
return 'grey' if $p->state eq 'not responsible';
return 'green' if $p->is_fixed || $p->is_closed;
return 'red' if $p->state eq 'confirmed';
return 'yellow';
}
sub contact_email {
my $self = shift;
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 => 'Lamp post number',
});
}
1;
|