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
|
package FixMyStreet::Cobrand::Northamptonshire;
use parent 'FixMyStreet::Cobrand::Whitelabel';
use strict;
use warnings;
use Moo;
with 'FixMyStreet::Roles::ConfirmValidation';
sub council_area_id { 2234 }
sub council_area { 'Northamptonshire' }
sub council_name { 'Northamptonshire County Council' }
sub council_url { 'northamptonshire' }
sub enter_postcode_text { 'Enter a Northamptonshire postcode, street name and area, or check an existing report number' }
sub disambiguate_location {
my $self = shift;
my $string = shift;
return {
%{ $self->SUPER::disambiguate_location() },
centre => '52.30769080650276,-0.8647071378799923',
bounds => [ 51.97726778979222, -1.332346116362747, 52.643600776698605, -0.3416080408721255 ],
};
}
sub categories_restriction {
my ($self, $rs) = @_;
return $rs->search( { 'body.name' => 'Northamptonshire County Council' }, { join => 'body' });
}
sub send_questionnaires { 0 }
sub on_map_default_status { 'open' }
sub report_sent_confirmation_email { 'id' }
has body_obj => (
is => 'lazy',
default => sub {
FixMyStreet::DB->resultset('Body')->find({ name => 'Northamptonshire County Council' });
},
);
sub updates_disallowed {
my $self = shift;
my ($problem) = @_;
# Only open reports
return 1 if $problem->is_fixed || $problem->is_closed;
# Not on reports made by the body user
return 1 if $problem->user_id == $self->body_obj->comment_user_id;
return $self->next::method(@_);
}
sub is_defect {
my ($self, $p) = @_;
return $p->user_id == $self->body_obj->comment_user_id;
}
sub pin_colour {
my ($self, $p, $context) = @_;
return 'blue' if $self->is_defect($p);
return $self->SUPER::pin_colour($p, $context);
}
sub problems_on_map_restriction {
my ($self, $rs) = @_;
# Northamptonshire don't want to show district/borough reports
# on the site
return $self->problems_restriction($rs);
}
sub privacy_policy_url {
'https://www3.northamptonshire.gov.uk/councilservices/council-and-democracy/transparency/information-policies/privacy-notice/place/Pages/street-doctor.aspx'
}
sub is_two_tier { 1 }
sub get_geocoder { 'OSM' }
sub map_type { 'OSM' }
sub open311_config {
my ($self, $row, $h, $params) = @_;
my $extra = $row->get_extra_fields;
# remove the emergency category which is informational only
@$extra = grep { $_->{name} ne 'emergency' } @$extra;
push @$extra,
{ name => 'report_url',
value => $h->{url} },
{ name => 'title',
value => $row->title },
{ name => 'description',
value => $row->detail },
{ name => 'category',
value => $row->category };
$row->set_extra_fields(@$extra);
$params->{multi_photos} = 1;
}
sub open311_get_update_munging {
my ($self, $comment) = @_;
# If we've received an update via Open311, let us always take its state change
my $state = $comment->problem_state;
my $p = $comment->problem;
if ($state && $p->state ne $state && $p->is_visible) {
$p->state($state);
}
}
sub should_skip_sending_update {
my ($self, $comment) = @_;
my $p = $comment->problem;
my %body_users = map { $_->comment_user_id => 1 } values %{ $p->bodies };
if ( $body_users{ $p->user->id } ) {
return 1;
}
return 0;
}
sub report_validation {
my ($self, $report, $errors) = @_;
if ( length( $report->title ) > 120 ) {
$errors->{title} = sprintf( _('Summaries are limited to %s characters in length. Please shorten your summary'), 120 );
}
}
sub staff_ignore_form_disable_form {
my $self = shift;
my $c = $self->{c};
return $c->user_exists
&& $c->user->belongs_to_body( $self->body->id );
}
1;
|