forked from mysociety/fixmystreet
/
EastSussex.pm
123 lines (96 loc) · 3.24 KB
/
EastSussex.pm
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
package FixMyStreet::Cobrand::EastSussex;
use base 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
sub council_id { return 2224; }
sub council_area { return 'East Sussex'; }
sub council_name { return 'East Sussex County Council'; }
sub council_url { return 'eastsussex'; }
sub is_two_tier { return 1; }
sub disambiguate_location {
my $self = shift;
my $string = shift;
return {
%{ $self->SUPER::disambiguate_location() },
town => 'East Sussex',
centre => '50.9413275309703,0.276320277101682',
span => '0.414030932264716,1.00374244745585',
bounds => [ 50.7333642759327, -0.135851370247794, 51.1473952081975, 0.867891077208056 ],
};
}
sub example_places {
return ( 'BN7 2LZ', 'White Hill, Lewes' );
}
sub enter_postcode_text {
my ($self) = @_;
return 'Enter an East Sussex postcode, or street name and area';
}
# increase map zoom level so street names are visible
sub default_map_zoom { return 3; }
=head2 temp_update_potholes_contact
Routine to update the extra for potholes (temporary setup hack, will be
superseded by Open311/integration).
Can run with a script or command line like:
bin/cron-wrapper perl -MFixMyStreet::App -MFixMyStreet::Cobrand::EastSussex -e \
'FixMyStreet::Cobrand::EastSussex->new({c => FixMyStreet::App->new})->temp_update_potholes_contact'
=cut
use constant POTHOLE_SIZES => [
{'key' => ['Blank'], 'name' => ['--']},
{'key' => ['golf'], 'name' => ['Golf ball sized']},
{'key' => ['tennis'], 'name' => ['Tennis ball sized']},
{'key' => ['football'], 'name' => ['Football sized']},
{'key' => ['larger'], 'name' => ['Larger']}
];
use constant POTHOLE_DICT => {
map {
@{ $_->{key} },
@{ $_->{name} },
} @{ POTHOLE_SIZES() },
};
sub resolve_pothole_size {
my ($self, $key) = @_;
return $self->POTHOLE_DICT->{$key};
}
sub temp_update_potholes_contact {
my $self = shift;
my $category = 'Potholes';
my $contact = $self->{c}->model('DB::Contact')
->search({
body_id => $self->council_id,
category => $category,
})->first
or die "No such category: $category";
my $fields = [
{
'code' => 'detail_size', # there is already builtin handling for this field in Report::New
'variable' => 'true',
'order' => '1',
'description' => 'Size of the pothole?',
'required' => 'true',
'datatype' => 'singlevaluelist',
'datatype_description' => {},
'values' => {
'value' => $self->POTHOLE_SIZES,
},
}
];
# require IO::String; require RABX;
# RABX::wire_wr( $fields, IO::String->new(my $extra) );
$contact->update({ extra => $fields });
}
sub get_geocoder {
return 'OSM'; # default of Bing gives poor results, let's try overriding.
}
# for the /around/ page
sub on_map_default_max_pin_age {
return '3 months';
}
# for the /reports/ page
sub reports_per_page { return 20; }
sub pin_colour {
my ( $self, $p, $context ) = @_;
# TODO refactor to a Moo(se)? lazy attribute
my $open_states = $self->{open_states} ||= $p->open_states;
return $open_states->{ $p->state } ? 'yellow' : 'green';
}
1;