From 8b2c00d30b69087d24af95c779593a8d0eda87ff Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Wed, 18 Dec 2024 16:37:47 +0000 Subject: [PATCH] fixup! [Gloucester] Added cobrand front-end --- perllib/FixMyStreet/Cobrand/Gloucester.pm | 198 +----------------- .../gloucester/archive-old-enquiries.html | 59 ------ .../gloucester/archive-old-enquiries.txt | 29 --- templates/web/gloucester/tracking_code.html | 8 +- web/cobrands/gloucester/assets.js | 98 --------- 5 files changed, 10 insertions(+), 382 deletions(-) delete mode 100644 templates/email/gloucester/archive-old-enquiries.html delete mode 100644 templates/email/gloucester/archive-old-enquiries.txt delete mode 100644 web/cobrands/gloucester/assets.js diff --git a/perllib/FixMyStreet/Cobrand/Gloucester.pm b/perllib/FixMyStreet/Cobrand/Gloucester.pm index 2b866877ec3..3bfc6930078 100644 --- a/perllib/FixMyStreet/Cobrand/Gloucester.pm +++ b/perllib/FixMyStreet/Cobrand/Gloucester.pm @@ -4,7 +4,7 @@ FixMyStreet::Cobrand::Gloucester - code specific to the Gloucester cobrand =head1 SYNOPSIS -We integrate with Gloucester's Confirm back end. +We integrate with Gloucester's Alloy back end. =head1 DESCRIPTION @@ -18,31 +18,15 @@ 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_id { '2325' } sub council_area { 'Gloucester' } -sub council_name { 'Gloucester County Council' } +sub council_name { 'Gloucester City Council' } sub council_url { 'gloucester' } =item * Users with a gloucester.gov.uk email can always be found in the admin. @@ -79,50 +63,17 @@ sub reopening_disallowed { return 1; } -=item * Jobs from Confirm that are completed (marked as fixed or closed) are not displayed after 48 hours - -=cut - -sub report_age { - return { - closed => { - job => '48 hours', - }, - fixed => { - job => '48 hours', - }, - }; -} - =item * We do not send questionnaires. =cut sub send_questionnaires { 0 } -=item * Don't show reports before the go-live date, 4th October 2023 - -=cut - -sub cut_off_date { '2023-10-04' } - -=item * Add display_name as an extra contact field - -=cut - -sub contact_extra_fields { [ 'display_name' ] } - -=item * Custom label and hint for new report detail field +=item * TODO: Don't show reports before the go-live date =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.' -} - -sub new_report_detail_field_hint { - "e.g. 'The drain outside number 42 is blocked'" -} +# sub cut_off_date { '2024-03-31' } =pod @@ -130,153 +81,22 @@ sub new_report_detail_field_hint { =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 ) = @_; - - 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) = @_; - - # 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 }); - } - } -} - -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/gloucester", - srsname => "urn:ogc:def:crs:EPSG::27700", - typename => "WSF", - property => "CentralAssetId", - accept_feature => sub { 1 } - }; -} - -=head2 open311_extra_data_include - -Gloucester 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; my $town = 'Gloucester'; - # 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() }, town => $town, - centre => '51.825508771929094,-2.1263689427866654', - span => '0.53502964014244,1.07233523662321', + centre => '51.8493825813624,-2.24025312382298', + span => '0.0776436939868574,0.12409536555503', bounds => [ - 51.57753580138198, -2.687537158717889, - 52.11256544152442, -1.6152019220946803, + 51.8075803711933, -2.30135343437398, + 51.8852240651802, -2.17725806881895 ], }; } -=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_/; -} - -=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 ) = @_; - - return 'defects' if $self->is_defect($p); - return 'green' if $p->is_fixed || $p->is_closed; - return 'yellow'; -} - -sub path_to_pin_icons { - return '/cobrands/oxfordshire/images/'; -} - -=head2 open311_config - -Send multiple photos as files to Open311 - -=cut - -sub open311_config { - my ($self, $row, $h, $params) = @_; - - $params->{multi_photos} = 1; - $params->{upload_files} = 1; -} - 1; diff --git a/templates/email/gloucester/archive-old-enquiries.html b/templates/email/gloucester/archive-old-enquiries.html deleted file mode 100644 index 8de1e0f23ac..00000000000 --- a/templates/email/gloucester/archive-old-enquiries.html +++ /dev/null @@ -1,59 +0,0 @@ -[% - -email_summary = "Your reports on " _ site_name; - -PROCESS '_email_settings.html'; - -INCLUDE '_email_top.html'; - -%] - - -

Your reports on [% site_name %]

-

- Hello [% user.name %], -

-

- I am writing to let you know about some exciting new changes. -

-

- FixMyStreet is being updated in Gloucestershire to improve how Highway issues are being reported. All reports are still being processed as usual and you don't need to do anything. -

-

- This change makes the reporting system quicker, more efficient and lets you know automatically when work progresses or is completed. -

-

- This was launched on Wednesday, 4 October 2023 and as part of this process, reports made on FixMyStreet.com before the update have been closed. -

-

- All of your reports will have been received and reviewed by Gloucestershire County Council, it is just the enquiry on FixMyStreet.com that has been closed. If your report is currently ongoing, it will still be being processed by Gloucestershire County Council and you will receive updates. -

-

- We noticed that you have [% report_count %] old [% nget('report', 'reports', report_count) %] on the FixMyStreet.com system, - which are listed below. -

- - [% FOR report IN reports %] -
- [% IF report.photo %] - - - - [% END %] -

- [%~ report.title | html ~%] -

-

[% report.detail | html %]

-

- Reported [% report.time_ago %] ago. -

-
- [% END %] - -

- The FixMyStreet team and Gloucestershire Highways -

- - - -[% INCLUDE '_email_bottom.html' %] diff --git a/templates/email/gloucester/archive-old-enquiries.txt b/templates/email/gloucester/archive-old-enquiries.txt deleted file mode 100644 index 5c2d6dae790..00000000000 --- a/templates/email/gloucester/archive-old-enquiries.txt +++ /dev/null @@ -1,29 +0,0 @@ -Subject: Your reports on [% site_name %] - -Hello [% user.name %], - -I am writing to let you know about some exciting new changes. - -FixMyStreet is being updated in Gloucestershire to improve how Highway issues are being reported. All reports are still being processed as usual and you don't need to do anything. - -This change makes the reporting system quicker, more efficient and lets you know automatically when work progresses or is completed. - -This was launched on Wednesday, 4 October 2023 and as part of this process, reports made on FixMyStreet.com before the update have been closed. - -All of your reports will have been received and reviewed by Gloucestershire County Council, it is just the enquiry on FixMyStreet.com that has been closed. If your report is currently ongoing, it will still be being processed by Gloucestershire County Council and you will receive updates. - -We noticed that you have [% report_count %] old [% nget('report', 'reports', report_count) %] on the FixMyStreet.com system, which are listed below. - -[% FOR report IN reports %] - -[% report.title %] - -Reported [% report.time_ago %] ago. - -View report: https://www.fixmystreet.com/report/[% report.id %] - ----- - -[% END %] - -The FixMyStreet team and Gloucestershire Highways \ No newline at end of file diff --git a/templates/web/gloucester/tracking_code.html b/templates/web/gloucester/tracking_code.html index e4c242e006d..6dbcc5dc70e 100644 --- a/templates/web/gloucester/tracking_code.html +++ b/templates/web/gloucester/tracking_code.html @@ -1,11 +1,5 @@ [% IF c.config.BASE_URL == "https://www.fixmystreet.com" %] - - - + [% END %] diff --git a/web/cobrands/gloucester/assets.js b/web/cobrands/gloucester/assets.js deleted file mode 100644 index 53711d15628..00000000000 --- a/web/cobrands/gloucester/assets.js +++ /dev/null @@ -1,98 +0,0 @@ -(function(){ - -if (!fixmystreet.maps) { - return; -} - -// Track open popup for defect pins -var defect_popup; - -function show_defect_popup(feature) { - defect_popup = new OpenLayers.Popup.FramedCloud( - "gccDefects", - feature.geometry.getBounds().getCenterLonLat(), - null, - feature.attributes.title.replace("\n", "
"), - { size: new OpenLayers.Size(0, 0), offset: new OpenLayers.Pixel(6, -46) }, - true, - close_defect_popup - ); - fixmystreet.map.addPopup(defect_popup); - - // On mobile the popup is obscured by the crosshairs, so hide them (and - // the "Start new report here" button) when the popup is shown - if ($('html').hasClass('mobile')) { - $(".map-crosshairs, .map-mobile-report-button").addClass("hidden"); - - // after a short delay (to ignore any `maps:click` events that trigger - // during the current handler code) add a callback to close the popup - // when the map is clicked. - window.setTimeout(function() { - $(fixmystreet).on('maps:click', close_defect_popup); - }, 500); - } -} - -function close_defect_popup() { - if (!!defect_popup) { - fixmystreet.map.removePopup(defect_popup); - defect_popup.destroy(); - defect_popup = null; - } - - if ($('html').hasClass('mobile')) { - // Don't forget to restore the crosshair/new report button - $(".map-crosshairs, .map-mobile-report-button").removeClass("hidden"); - - // and remove the callback handler for clicking the map - $(fixmystreet).off('maps:click', close_defect_popup); - } -} - -// Handle clicks on defect pins when showing duplicates -function setup_defect_popup() { - var select_defect = new OpenLayers.Control.SelectFeature( - fixmystreet.markers, - { - hover: true, - clickFeature: function (feature) { - close_defect_popup(); - if (feature.attributes.id >= 0) { - // We're only interested in defects - return; - } - show_defect_popup(feature); - } - } - ); - fixmystreet.map.addControl(select_defect); - select_defect.activate(); -} - -function handle_marker_click(e, feature) { - close_defect_popup(); - - // Show popups for defects, which have negative fake IDs - if (feature.attributes.id < 0) { - show_defect_popup(feature); - } -} - -$(fixmystreet).on('maps:render_duplicates', setup_defect_popup); -$(fixmystreet).on('maps:marker_click', handle_marker_click); - -if (!$('html').hasClass('mobile')) { - // Prevent the popup being closed as soon as it's opened on mobile. - // Mobile reports are started with the crosshair & button so no - // need to deal with getting the popup out of the way. - $(fixmystreet).on('maps:click', close_defect_popup); -} - -$(function() { - if (fixmystreet.page == 'reports') { - // Refresh markers on page load so that defects are loaded in over AJAX. - fixmystreet.markers.events.triggerEvent('refresh'); - } -}); - -})();