Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Aberdeenshire] Added cobrand front-end #5323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 280 additions & 0 deletions perllib/FixMyStreet/Cobrand/Aberdeenshire.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
=head1 NAME

FixMyStreet::Cobrand::Aberdeenshire - code specific to the Aberdeenshire cobrand

=head1 SYNOPSIS

We integrate with Aberdeenshire's Confirm back end.

=head1 DESCRIPTION

=cut

package FixMyStreet::Cobrand::Aberdeenshire;
use parent 'FixMyStreet::Cobrand::Whitelabel';

use strict;
use warnings;

use Moo;

use LWP::Simple;
use URI;
use Try::Tiny;
use JSON::MaybeXS;


=pod

Confirm backends expect some extra values and have some maximum lengths for
certain fields. These roles implement that behaviour.

=cut

with 'FixMyStreet::Roles::ConfirmOpen311';
with 'FixMyStreet::Roles::ConfirmValidation';

=head2 Defaults

=over 4

=cut

sub council_area_id { '2226' }
sub council_area { 'Aberdeenshire' }
sub council_name { 'Aberdeenshire County Council' }
sub council_url { 'aberdeenshire' }

Check warning on line 46 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L43-L46

Added lines #L43 - L46 were not covered by tests

=item * Users with a Aberdeenshire.gov.uk email can always be found in the admin.

=cut

sub admin_user_domain { 'aberdeenshire.gov.uk' }

Check warning on line 52 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L52

Added line #L52 was not covered by tests

=item * Allows anonymous reporting

=cut

sub allow_anonymous_reports { 'button' }

Check warning on line 58 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L58

Added line #L58 was not covered by tests

=item * Aberdeenshire use their own privacy policy

=cut

sub privacy_policy_url {
'https://www.aberdeenshire.gov.uk/data/data-protection'

Check warning on line 65 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L65

Added line #L65 was not covered by tests
}

=item * Users can not reopen reports

=cut

sub reopening_disallowed {
my ($self, $problem) = @_;

Check warning on line 73 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L73

Added line #L73 was not covered by tests

# Only staff can reopen reports.
my $c = $self->{c};
my $user = $c->user;

Check warning on line 77 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L76-L77

Added lines #L76 - L77 were not covered by tests
return 0 if ($c->user_exists && $user->from_body && $user->from_body->cobrand_name eq $self->council_name);
return 1;

Check warning on line 79 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L79

Added line #L79 was not covered by tests
}

=item * Jobs from Confirm that are completed (marked as fixed or closed) are not displayed after 48 hours

=cut

sub report_age {
return {
closed => {

Check warning on line 88 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L88

Added line #L88 was not covered by tests
job => '48 hours',
},
fixed => {
job => '48 hours',
},
};
}

=item * We do not send questionnaires.

=cut

sub send_questionnaires { 0 }

Check warning on line 101 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L101

Added line #L101 was not covered by tests

=item * Don't show reports before the go-live date, 4th October 2023

=cut

sub cut_off_date { '2023-10-04' }

Check warning on line 107 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L107

Added line #L107 was not covered by tests

=item * Add display_name as an extra contact field

=cut

sub contact_extra_fields { [ 'display_name' ] }

Check warning on line 113 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L113

Added line #L113 was not covered by tests

=item * Custom label and hint for new report detail field

=cut

sub new_report_detail_field_label {
'Where is the location of the problem? Please be specific and identify the nearest property address or landmark to the problem.'

Check warning on line 120 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L120

Added line #L120 was not covered by tests
}

sub new_report_detail_field_hint {
"e.g. 'The drain outside number 42 is blocked'"

Check warning on line 124 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L124

Added line #L124 was not covered by tests
}

=pod

=back

=cut

=head2 open311_skip_report_fetch

Do not fetch reports from Confirm for categories that are marked private.

=cut

sub open311_skip_report_fetch {
my ( $self, $problem ) = @_;

Check warning on line 140 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L140

Added line #L140 was not covered by tests

return 1 if $problem->non_public;
}

=head2 open311_update_missing_data

Unlike the ConfirmOpen311 role, we want to fetch a central asset ID here, not a
site code.

=cut

sub open311_update_missing_data {
my ($self, $row, $h, $contact) = @_;

Check warning on line 153 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L153

Added line #L153 was not covered by tests

# In case the client hasn't given us a central asset ID, look up the
# closest asset from the WFS service at the point we're sending the report
if (!$row->get_extra_field_value('central_asset_id')) {
if (my $id = $self->lookup_site_code($row)) {
$row->update_extra_field({ name => 'central_asset_id', value => $id });

Check warning on line 159 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L159

Added line #L159 was not covered by tests
}
}
}

sub lookup_site_code_config {
my $host = FixMyStreet->config('STAGING_SITE') ? "tilma.staging.mysociety.org" : "tilma.mysociety.org";
return {
buffer => 200, # metres
url => "https://$host/mapserver/aberdeenshire",
srsname => "urn:ogc:def:crs:EPSG::27700",
typename => "WSF",
property => "CentralAssetId",
accept_feature => sub { 1 }
};

Check warning on line 173 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L172-L173

Added lines #L172 - L173 were not covered by tests
}

=head2 open311_extra_data_include

Aberdeenshire want report title to be in description field, along with
subcategory text, which is not otherwise captured by Confirm. Report detail
goes into the location field.
Subcategory text may need to be fetched from '_wrapped_service_code'
extra data.

=cut

around open311_extra_data_include => sub {
my ( $orig, $self, $row, $h ) = @_;
my $open311_only = $self->$orig( $row, $h );

my $category = $row->category;
my $wrapped_for_report
= $row->get_extra_field_value('_wrapped_service_code');
my $wrapped_categories
= $row->contact->get_extra_field( code => '_wrapped_service_code' );

if ( $wrapped_for_report && $wrapped_categories ) {
($category)
= grep { $_->{key} eq $wrapped_for_report }
@{ $wrapped_categories->{values} };

$category = $category->{name};
}

push @$open311_only, {
name => 'description',
value => $category . ' | ' . $row->title,
};
push @$open311_only, {
name => 'location',
value => $row->detail,
};

return $open311_only;
};


sub disambiguate_location {
my $self = shift;
my $string = shift;

Check warning on line 219 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L218-L219

Added lines #L218 - L219 were not covered by tests

my $town = 'Aberdeenshire';

Check warning on line 221 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L221

Added line #L221 was not covered by tests

# As it's the requested example location, try to avoid a disambiguation page
$town .= ', GL20 5XA'
if $string =~ /^\s*gloucester\s+r(oa)?d,\s*tewkesbury\s*$/i;

return {
%{ $self->SUPER::disambiguate_location() },

Check warning on line 228 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L228

Added line #L228 was not covered by tests
town => $town,
centre => '51.825508771929094,-2.1263689427866654',
span => '0.53502964014244,1.07233523662321',
bounds => [
51.57753580138198, -2.687537158717889,
52.11256544152442, -1.6152019220946803,
],
};
}

=head2 is_defect

Returns true if it's a fetched job from Confirm.

=cut

sub is_defect {
my ($self, $p) = @_;
return $p->external_id && $p->external_id =~ /^JOB_/;

Check warning on line 247 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L246-L247

Added lines #L246 - L247 were not covered by tests
}

=head2 pin_colour

Green for anything completed or closed, yellow for the rest,
apart from defects which are blue.

=cut

sub pin_colour {
my ( $self, $p ) = @_;

Check warning on line 258 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L258

Added line #L258 was not covered by tests

return 'blue-work' if $self->is_defect($p);
return 'green-tick' if $p->is_fixed || $p->is_closed;
return 'yellow-cone';

Check warning on line 262 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L262

Added line #L262 was not covered by tests
}

sub path_to_pin_icons { '/i/pins/whole-shadow-cone-spot/' }

Check warning on line 265 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L265

Added line #L265 was not covered by tests

=head2 open311_config

Send multiple photos as files to Open311

=cut

sub open311_config {
my ($self, $row, $h, $params) = @_;

Check warning on line 274 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L274

Added line #L274 was not covered by tests

$params->{multi_photos} = 1;
$params->{upload_files} = 1;

Check warning on line 277 in perllib/FixMyStreet/Cobrand/Aberdeenshire.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Aberdeenshire.pm#L276-L277

Added lines #L276 - L277 were not covered by tests
}

1;
23 changes: 23 additions & 0 deletions templates/email/aberdeenshire/_email_color_overrides.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[%

color_primary = '#004289'
color_pale_grey = '#f0f0f0'

body_font_family = "Verdana, sans-serif"

header_background_color = color_primary
header_text_color = color_white

secondary_column_background_color = color_pale_grey

link_text_color = color_primary
link_hover_text_color = '#0081c9'

button_background_color = '#8c4e8d'
button_text_color = color_white

logo_file = 'aberdeenshire-logo-white.png'
logo_width = "293" # pixel measurement, but without 'px' suffix
logo_height = "60" # pixel measurement, but without 'px' suffix

%]
22 changes: 22 additions & 0 deletions templates/web/aberdeenshire/footer_extra.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<footer class="aberdeenshire-footer">
<div class="container pt-3 primary-links-container">
<ul class="footer-list">
<li><a href="https://www.aberdeenshire.gov.uk/" class="footer-link">Home</a></li>
<li><a href="https://www.aberdeenshire.gov.uk/accessibility-translations" class="footer-link">Help with this website</a></li>
<li><a href="https://www.aberdeenshire.gov.uk/data/accessibility" class="footer-link">Accessibility</a></li>
<li><a href="https://www.aberdeenshire.gov.uk/data/site-information" class="footer-link">Cookies</a></li>
<li><a href="https://www.aberdeenshire.gov.uk/data/data-protection" class="footer-link">Privacy</a></li>
<li><a href="https://www.aberdeenshire.gov.uk/news" class="footer-link">News</a></li>
<li><a href="https://www.aberdeenshire.gov.uk/contact-us" class="footer-link">Contact the council</a></li>
</ul>
<ul class="footer-list">
<li><a href="https://www.facebook.com/pages/Aberdeenshire/430917186975751" target="_blank" class="footer-link external-link">Facebook <span class="screen-reader-only">opens in a new tab</span></a></li>
<li><a href="https://twitter.com/aberdeenshire" target="_blank" class="footer-link external-link">X <span class="screen-reader-only">opens in a new tab</span></a></li>
<li><a href="https://www.linkedin.com/company/aberdeenshire-council" target="_blank" class="footer-link external-link">LinkedIn <span class="screen-reader-only">opens in a new tab</span></a></li>
<li><a href="https://www.youtube.com/user/aberdeenshirecouncil" target="_blank" class="footer-link external-link">YouTube <span class="screen-reader-only">opens in a new tab</span></a></li>
</ul>
<p class="strapline">from mountain to sea... the very best of Scotland!</p>
</div>
</footer>
[% PROCESS '_footer_main_nav.html' %]
[% PROCESS '_footer_extra_powered_by.html' %]
1 change: 1 addition & 0 deletions templates/web/aberdeenshire/footer_extra_js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[% PROCESS 'footer_extra_js_base.html' highways=1 roadworks=1 validation=1 cobrand_js=1 %]
Empty file.
2 changes: 2 additions & 0 deletions templates/web/aberdeenshire/header_extra.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link rel="icon" type="image/png" sizes="32x32" href="/cobrands/aberdeenshire/images/favicon.ico">
[% INCLUDE 'tracking_code.html' %]
2 changes: 2 additions & 0 deletions templates/web/aberdeenshire/header_logo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<a href="https://www.aberdeenshire.gov.uk/" id="site-logo">Aberdeenshire council</a>
<a href="/" id="report-cta" title="[%- loc('Report a problem') -%]">[%- loc('Report') -%]</a>
1 change: 1 addition & 0 deletions templates/web/aberdeenshire/site-name.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Aberdeenshire Council FixMyStreet
11 changes: 11 additions & 0 deletions templates/web/aberdeenshire/tracking_code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[% IF c.config.BASE_URL == "https://www.fixmystreet.com" %]

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-6Z7T');</script>
<!-- End Google Tag Manager -->

[% END %]
Loading