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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
package FixMyStreet::Cobrand::Oxfordshire;
use base 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
sub council_area_id { return 2237; }
sub council_area { return 'Oxfordshire'; }
sub council_name { return 'Oxfordshire County Council'; }
sub council_url { return 'oxfordshire'; }
sub is_two_tier { return 1; }
sub report_validation {
my ($self, $report, $errors) = @_;
if ( length( $report->detail ) > 1700 ) {
$errors->{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1700 );
}
if ( length( $report->name ) > 50 ) {
$errors->{name} = sprintf( 'Names are limited to %d characters in length.', 50 );
}
if ( length( $report->user->phone ) > 20 ) {
$errors->{phone} = sprintf( 'Phone numbers are limited to %s characters in length.', 20 );
}
if ( length( $report->user->email ) > 50 ) {
$errors->{username} = sprintf( 'Emails are limited to %s characters in length.', 50 );
}
return $errors;
}
sub is_council_with_case_management {
# XXX Change this to return 1 when OCC FMSfC goes live.
return FixMyStreet->config('STAGING_SITE');
}
sub enter_postcode_text {
my ($self) = @_;
return 'Enter an Oxfordshire postcode, or street name and area';
}
sub disambiguate_location {
my $self = shift;
my $string = shift;
return {
%{ $self->SUPER::disambiguate_location() },
town => 'Oxfordshire',
centre => '51.765765,-1.322324',
span => '0.709058,0.849434',
bounds => [ 51.459413, -1.719500, 52.168471, -0.870066 ],
};
}
# don't send questionnaires to people who used the OCC cobrand to report their problem
sub send_questionnaires { return 0; }
# increase map zoom level so street names are visible
sub default_map_zoom { return 3; }
# let staff hide OCC reports
sub users_can_hide { return 1; }
sub lookup_by_ref_regex {
return qr/^\s*((?:ENQ)?\d+)\s*$/;
}
sub lookup_by_ref {
my ($self, $ref) = @_;
if ( $ref =~ /^ENQ/ ) {
my $len = length($ref);
my $filter = "%T18:customer_reference,T$len:$ref,%";
return { 'extra' => { -like => $filter } };
}
return 0;
}
sub reports_ordering {
return 'created-desc';
}
sub pin_colour {
my ( $self, $p, $context ) = @_;
return 'grey' unless $self->owns_problem( $p );
return 'grey' if $p->is_closed;
return 'green' if $p->is_fixed;
return 'yellow' if $p->state eq 'confirmed';
return 'orange'; # all the other `open_states` like "in progress"
}
sub pin_new_report_colour {
return 'yellow';
}
sub path_to_pin_icons {
return '/cobrands/oxfordshire/images/';
}
sub pin_hover_title {
my ($self, $problem, $title) = @_;
my $state = FixMyStreet::DB->resultset("State")->display($problem->state, 1);
return "$state: $title";
}
sub state_groups_inspect {
[
[ 'New', [ 'confirmed', 'investigating' ] ],
[ 'Scheduled', [ 'action scheduled' ] ],
[ 'Fixed', [ 'fixed - council' ] ],
[ 'Closed', [ 'not responsible', 'duplicate', 'unable to fix' ] ],
]
}
sub open311_config {
my ($self, $row, $h, $params) = @_;
my $extra = $row->get_extra_fields;
push @$extra, { name => 'external_id', value => $row->id };
push @$extra, { name => 'northing', value => $h->{northing} };
push @$extra, { name => 'easting', value => $h->{easting} };
if ($h->{closest_address}) {
push @$extra, { name => 'closest_address', value => "$h->{closest_address}" }
}
$row->set_extra_fields( @$extra );
$params->{multi_photos} = 1;
$params->{extended_description} = 'oxfordshire';
}
sub open311_config_updates {
my ($self, $params) = @_;
$params->{use_customer_reference} = 1;
}
sub should_skip_sending_update {
my ($self, $update ) = @_;
# Oxfordshire stores the external id of the problem as a customer reference
# in metadata
return 1 if !$update->problem->get_extra_metadata('customer_reference');
}
sub on_map_default_status { return 'open'; }
sub admin_user_domain { 'oxfordshire.gov.uk' }
sub traffic_management_options {
return [
"Signs and Cones",
"Stop and Go Boards",
"High Speed Roads",
];
}
sub admin_pages {
my $self = shift;
my $user = $self->{c}->user;
my $pages = $self->next::method();
if ( $user->has_body_permission_to('defect_type_edit') ) {
$pages->{defecttypes} = [ ('Defect Types'), 11 ];
$pages->{defecttype_edit} = [ undef, undef ];
};
return $pages;
}
sub user_extra_fields {
return [ 'initials' ];
}
sub display_days_ago_threshold { 28 }
sub max_detailed_info_length { 164 }
sub defect_type_extra_fields {
return [
'activity_code',
'defect_code',
];
};
sub available_permissions {
my $self = shift;
my $perms = $self->next::method();
$perms->{Bodies}->{defect_type_edit} = "Add/edit defect types";
return $perms;
}
1;
|