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

[Surrey] Cobrand & integration #5095

Merged
merged 60 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
15cf344
[Surrey] Minimal cobrand.
dracos Nov 20, 2023
e867242
[Surrey] Send report logged emails.
dracos Dec 6, 2023
f4ef507
[Surrey] Added front-end
lucascumsille Mar 28, 2024
4a1cba0
[Surrey] Added red_surrey for error messages
lucascumsille Apr 15, 2024
9235b03
[Surrey] Added black color to -color-desktop
lucascumsille Apr 23, 2024
37c313a
[Surrey] Display town from geocoder on front page recent problems
davea May 1, 2024
97e7a63
[Surrey] Surrey front-end first round of feedback
lucascumsille May 1, 2024
ea1a03e
[Surrey] Added styling to .form-error
lucascumsille May 8, 2024
e370ded
[Surrey] Added colour to input text and textarea
lucascumsille May 9, 2024
4ca3ee1
[Surrey] Added new footer
lucascumsille May 9, 2024
d95da35
[Surrey] Added styling to .site-message
lucascumsille May 9, 2024
ca1b591
[Surrey] Specify correct location for geocoder results
davea May 16, 2024
50cd2dd
[Surrey] Added btn-primary styling to 'continue' btn in mappage
lucascumsille Jun 18, 2024
4040f53
[Surrey] Show external ID if available.
dracos Jun 27, 2024
308fb00
[Surrey] Default map view durations.
dracos Jun 27, 2024
4efd35a
Stop wrapping category notices in a label.
dracos Jun 27, 2024
62e595d
[Surrey] Add display_name admin option.
dracos Jun 27, 2024
b91a760
Move Other to end of subcategory lists.
dracos Jun 28, 2024
a826233
[Surrey] Added fix for postcode form border color
lucascumsille Jul 22, 2024
1d3cbea
[Surrey] Added fix for color for Label in postcode-form-box element
lucascumsille Jul 22, 2024
83f4528
[Surrey] Reset mappage-sidebar-width to default
lucascumsille Jul 24, 2024
9688c4c
[Surrey] CSV export includes subscribers to the report
MorayMySoc Jun 12, 2024
f21b64f
[Surrey] Add template for ‘road not found’ message
davea Jul 31, 2024
ed7ef11
[Surrey] Added fix for filter category width
lucascumsille Jul 31, 2024
b5e8891
[Surrey] Improved style for js-responsibility-message
lucascumsille Jul 31, 2024
d271afa
[Surrey] Update not responsibility text
MorayMySoc Aug 5, 2024
74b39b9
[Surrey] Increased font-size of input[text] and textarea on mobile
lucascumsille Aug 8, 2024
461dbac
[Surrey] Added Happy or not section above newsletter
lucascumsille Aug 8, 2024
ea7898d
[Surrey] Allow some categories to be reported off road
MorayMySoc Aug 15, 2024
a38634d
[Surrey] Adjusted responsive font-size
lucascumsille Aug 21, 2024
56f6cd7
[Surrey] Add call hook to use service_name as title
MorayMySoc Aug 28, 2024
4e5f67b
[Surrey] Added FAQ new markup
lucascumsille Aug 21, 2024
0f64f8d
[Surrey] Added Powered and Footer Main Nav
lucascumsille Aug 29, 2024
70515df
[Surrey] Added sidebar html FAQ
lucascumsille Sep 2, 2024
1a143d6
[Surrey] Don’t show one particular district category
davea Sep 12, 2024
3b01c58
[Surrey] Don’t send alerts to problem reporters
davea May 16, 2024
b86d4bb
[Surrey] Update front page intro text
davea May 16, 2024
67027d3
[Surrey] Workaround Edge bug causing invisible autocomplete text
davea May 17, 2024
8e19b28
[Surrey] Adds privacy url
MorayMySoc May 23, 2024
f49f41d
[Surrey] Change wording for clicking map
MorayMySoc May 23, 2024
bf34c2c
[Surrey] Adds google tag
MorayMySoc May 24, 2024
34aeb5e
[Surrey] Don’t send questionnaires
davea Jun 12, 2024
9a67502
[Surrey] Pass extra data over Open311
davea Jun 12, 2024
5d273de
[Surrey] Allow lookup of Zendesk reports with numeric ID
davea Jul 1, 2024
0572529
[Surrey] Remove FMS ID from display on report page
davea Jul 3, 2024
47ae67a
[Surrey] Fetch USRN/road name using lookup_site_code when sending rep…
davea Jul 4, 2024
e69bc01
[Surrey] Report confirmation page improvements
davea Jul 4, 2024
39e11d8
[Surrey] Default to map zoom 3
davea Jul 4, 2024
58caf9b
[Surrey] Encode field description alongside Open311 attribute value
davea Jul 12, 2024
4baf51f
[Surrey] Disallow reopening reports; allow anon reports
davea Jul 23, 2024
302bd4a
[Surrey] Show message to user when reopening report is not allowed
davea Jul 23, 2024
8466658
[Surrey] Do not send ‘report sent’ confirmation emails
davea Jul 24, 2024
dd321d4
[Surrey] Use OSM Geocoder
davea Jul 31, 2024
1162378
[Surrey] Send multiple photos with updates
davea Jul 31, 2024
d517ede
[Surrey] Send category display name over Open311
davea Aug 2, 2024
ab00aa5
[Surrey] Remove council id from site and emails
MorayMySoc Aug 8, 2024
3b73082
[Surrey] Add HappyOrNot to page footer
davea Aug 2, 2024
24f533f
Add --update-contacts flag to export-import-data
davea Sep 12, 2024
31a83d2
Dupe suggestions can be disabled on a per-category basis in config
davea Sep 11, 2024
9142e52
[Surrey] Add PWA screenshots
davea Sep 16, 2024
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
2 changes: 1 addition & 1 deletion .cypress/cypress.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"baseUrl": "http://fixmystreet.localhost:3001",
"projectId": "y8vvs1",
"blacklistHosts": ["gaze.mysociety.org", "*.openstreetmap.org", "portal.roadworks.org", "tilma.mysociety.org", "tilma.staging.mysociety.org", "isharemaps.bathnes.gov.uk", "consent.cookiebot.com", "assets.adobedtm.com", "www.googletagmanager.com", "www.googleadservices.com", "*.virtualearth.net"],
"blacklistHosts": ["gaze.mysociety.org", "*.openstreetmap.org", "portal.roadworks.org", "tilma.mysociety.org", "tilma.staging.mysociety.org", "isharemaps.bathnes.gov.uk", "consent.cookiebot.com", "assets.adobedtm.com", "www.googletagmanager.com", "www.googleadservices.com", "*.virtualearth.net", "feedback.happy-or-not.com"],
"env": {
"postcode": "BS10 5EE"
},
Expand Down
26 changes: 26 additions & 0 deletions .cypress/cypress/integration/surrey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
describe('Surrey cobrand', function() {
it('contains Surrey configuration', function() {
cy.viewport(480, 800);
cy.visit('http://surrey.localhost:3001/');
cy.contains('Surrey');
});
});

describe('Reporting not on a road', function() {
it('Can report certain categories not on a road', function() {
cy.server();
cy.route('/report/new/ajax*').as('report-ajax');
cy.visit('http://surrey.localhost:3001/report/new?longitude=-0.441269&latitude=51.293415');
cy.wait('@report-ajax');
cy.pickCategory('Abandoned vehicles');
cy.contains('You cannot send Surrey County Council a report');
cy.get('#map_sidebar').scrollTo('bottom');
cy.get('.js-reporting-page--next:visible').should('be.disabled');
cy.pickCategory('Flooding inside a building');
cy.contains('You cannot send Surrey County Council a report').should('not.be.visible');
cy.get('#map_sidebar').scrollTo('bottom');
cy.get('.js-reporting-page--next:visible').should('not.be.disabled');
});
});


3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Fix setting of fixed timestamp in CSV export. #5119
- Fix CSV export of reports with only hidden/unconfirmed updates. #5119
- Fix displaying category page if over 1,000 history entries.
- Stop wrapping category notices in a label.
- Admin improvements:
- Rename emergency message to site message.
- Added a category control for overriding the text of the new report details field.
Expand All @@ -49,7 +50,7 @@
- Add `send_state` column to reports. #4048
- Return random unprocessed row to daemon.
- A cobrand level text override for the details field label on new reports can now be configured.
- Cobrands can provide per-category custom distances for duplicate lookup. #4746
- Cobrands can provide per-category custom distances for duplicate lookup. #4746 #5162
- Add perl 5.38 support.
- Add plain text template previews to /_dev/email. #5105
- Performance improvements:
Expand Down
1 change: 1 addition & 0 deletions bin/browser-tests
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ BEGIN {
oxfordshire
peterborough
shropshire
surrey
tfl
westminster
)];
Expand Down
43 changes: 29 additions & 14 deletions bin/export-import-data
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ my ($opt, $usage) = describe_options(
[ 'import=s', "File to import" ],
[ 'commit', "Actually commit changes to the database" ],
[ 'update-templates', "Update existing templates (default is to skip)" ],
[ 'update-contacts', "Update existing contacts (default is to skip)" ],
[ 'categories=s', "pipe-separated list of categories to export contacts for and filter templates by" ],
[ 'all-categories', "Use instead of --categories to export all contacts & templates" ],
[ 'help', "print usage message and exit", { shortcircuit => 1 } ],
Expand All @@ -36,7 +37,7 @@ my $body = FixMyStreet::DB->resultset("Body")->find({ name => $opt->name }) or d
my @categories = split(/\|/, ($opt->{categories} || ''));

if ($opt->import) {
import($opt->import, $opt->update_templates);
import($opt->import, $opt->update_templates, $opt->update_contacts);
} else {
export();
}
Expand Down Expand Up @@ -108,6 +109,7 @@ sub export {
sub import {
my $file = shift;
my $update_templates = shift;
my $update_contacts = shift;

my $json = path($file)->slurp;
my $out = $J->decode($json);
Expand All @@ -118,20 +120,33 @@ sub import {
foreach (@{$out->{contacts}}) {
my $existing = $body->contacts->search({ category => $_->{category} })->single;
if ($existing) {
warn "Category $_->{category} already exists, skipping";
next;
if ($update_contacts) {
$existing->update({
note => "Updated from $file",
editor => 'export-import-data',
whenedited => \'current_timestamp',
email => $_->{email},
state => $_->{state},
non_public => $_->{non_public},
extra => $_->{extra},
});
} else {
warn "Category $_->{category} already exists, skipping";
next;
}
} else {
my $contact = $body->contacts->new({
note => "Imported from $file",
editor => 'export-import-data',
whenedited => \'current_timestamp',
category => $_->{category},
email => $_->{email},
state => $_->{state},
non_public => $_->{non_public},
extra => $_->{extra},
});
$contact->insert;
}
my $contact = $body->contacts->new({
note => "Imported from $file",
editor => 'export-import-data',
whenedited => \'current_timestamp',
category => $_->{category},
email => $_->{email},
state => $_->{state},
non_public => $_->{non_public},
extra => $_->{extra},
});
$contact->insert;
}

foreach (@{$out->{templates}}) {
Expand Down
1 change: 1 addition & 0 deletions bin/fixmystreet.com/fixture
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ if ($opt->test_fixtures) {
{ area_id => 2500, categories => [ 'Abandoned vehicles', 'Flytipping', 'Flyposting' ], name => 'Merton Council', cobrand => 'merton' },
{ area_id => 2488, categories => [ 'Grass verges / shrub beds - littering' , 'Pavement damage', 'Fly-tipping', 'Dog fouling'], name => 'Brent Council', cobrand => 'brent' },
{ area_id => 2535, categories => [ 'Abandoned vehicles', 'Graffiti', 'Street lights'], name => 'Sandwell Borough Council' },
{ area_id => 2242, categories => [ 'Abandoned vehicles', 'Graffiti', 'Street lights', 'Flooding inside a building'], name => 'Surrey County Council' },
) {
$bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_);
if ($_->{cobrand}) {
Expand Down
33 changes: 33 additions & 0 deletions data/test-asset-layers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,39 @@ shropshire:
actions:
found: 'fixmystreet.assets.shropshire.street_found'
not_found: 'fixmystreet.assets.shropshire.street_not_found'
surrey:
- asset_type: 'spot'
max_resolution: 4.777314267158508
asset_id_field: 'assetNo'
srsName: "EPSG:4326"
body: "Surrey County Council"
format_class: OpenLayers.Format.GeoJSON
format_options: {ignoreExtraDims: true}
protocol_class: OpenLayers.Protocol.ArcgisHTTP
class: OpenLayers.Layer.VectorAssetMove
http_options:
params:
inSR: '4326'
f: 'geojson'
- always_visible: true
asset_type: road
road: true
actions:
found: fixmystreet.message_controller.road_found
not_found: fixmystreet.assets.surrey.road_not_found
permissive_categories: ['Flooding inside a building', 'Flooding not on the highway but in a park or private land']
no_asset_msg_id: '#js-not-a-road'
http_options:
params:
outFields: USRN
where: MAINTAINED_BY='Surrey CC'
url: https://tilma.mysociety.org/resource-proxy/proxy.php?https://surrey.assets/2/query?
non_interactive: true
class: OpenLayers.Layer.VectorNearest
stylemap: fixmystreet.assets.stylemap_invisible
usrn:
attribute: USRN
field: site_code
tfl:
- - http_wfs_url: "https://tilma.staging.mysociety.org/mapserver/tfl"
name: 'road'
Expand Down
76 changes: 45 additions & 31 deletions perllib/FixMyStreet/App/Controller/Report.pm
Original file line number Diff line number Diff line change
Expand Up @@ -727,38 +727,42 @@ sub _nearby_json :Private {
# This is for the list template, this is a list on that page.
$c->stash->{page} = 'report';

my $dist = $self->_find_distance($c, $params);
$params->{distance} = $dist / 1000 unless $params->{distance}; # DB measures in km
if (my $dist = $self->_find_distance($c, $params)) { # distance of 0 means we can skip lookup entirely
$params->{distance} = $dist / 1000 unless $params->{distance}; # DB measures in km

my $pin_size = $c->get_param('pin_size') || '';
$pin_size = 'small' unless $pin_size =~ /^(mini|small|normal|big)$/;
my $pin_size = $c->get_param('pin_size') || '';
$pin_size = 'small' unless $pin_size =~ /^(mini|small|normal|big)$/;

$params->{extra} = $c->cobrand->call_hook('display_location_extra_params');
$params->{limit} = 5;
$params->{extra} = $c->cobrand->call_hook('display_location_extra_params');
$params->{limit} = 5;

my $nearby = $c->model('DB::Nearby')->nearby($c, %$params);
my $nearby = $c->model('DB::Nearby')->nearby($c, %$params);

# Want to treat these as if they were on map
$nearby = [ map { $_->problem } @$nearby ];
my @pins = map {
my $p = $_->pin_data('around');
[ $p->{latitude}, $p->{longitude}, $p->{colour},
$p->{id}, $p->{title}, $pin_size, JSON->false
]
} @$nearby;
# Want to treat these as if they were on map
$nearby = [ map { $_->problem } @$nearby ];
my @pins = map {
my $p = $_->pin_data('around');
[ $p->{latitude}, $p->{longitude}, $p->{colour},
$p->{id}, $p->{title}, $pin_size, JSON->false
]
} @$nearby;

my @extra_pins = $c->cobrand->call_hook('extra_nearby_pins', $params->{latitude}, $params->{longitude}, $dist);
@pins = (@pins, @extra_pins) if @extra_pins;
my @extra_pins = $c->cobrand->call_hook('extra_nearby_pins', $params->{latitude}, $params->{longitude}, $dist);
@pins = (@pins, @extra_pins) if @extra_pins;

my $list_html = $c->render_fragment(
'report/nearby.html',
{ reports => $nearby, inline_maps => $c->get_param("inline_maps") ? 1 : 0, extra_pins => \@extra_pins }
);
my $json = { pins => \@pins };
$json->{reports_list} = $list_html if $list_html;
my $body = encode_json($json);
$c->res->content_type('application/json; charset=utf-8');
$c->res->body($body);
my $list_html = $c->render_fragment(
'report/nearby.html',
{ reports => $nearby, inline_maps => $c->get_param("inline_maps") ? 1 : 0, extra_pins => \@extra_pins }
);
my $json = { pins => \@pins };
$json->{reports_list} = $list_html if $list_html;
my $body = encode_json($json);
$c->res->content_type('application/json; charset=utf-8');
$c->res->body($body);
} else {
$c->res->content_type('application/json; charset=utf-8');
$c->res->body(encode_json({ 'pins' => []}));
}
}
}

Expand All @@ -769,7 +773,9 @@ sub _nearby_json :Private {
# b) distances for a group/parent category
# c) distances by mode
#
# NOTE: Distances for category or group only apply for the 'suggestions' mode.
# NOTES:
# - Distances for category or group only apply for the 'suggestions' mode.
# - Returning a distance of 0 means we can skip the nearby lookup entirely.
sub _find_distance {
my ($self, $c, $params) = @_;

Expand All @@ -782,17 +788,17 @@ sub _find_distance {
my $category = $params->{categories}[0];
my $group = $params->{group};

$dist = $category && $cobrand_distances->{$mode}{$category}
$dist = $category && defined $cobrand_distances->{$mode}{$category}
? $cobrand_distances->{$mode}{$category}
: $group && $cobrand_distances->{$mode}{$group}
: $group && defined $cobrand_distances->{$mode}{$group}
? $cobrand_distances->{$mode}{$group}
: $cobrand_distances->{$mode}{_fallback};
} else {
$dist = $cobrand_distances->{$mode};
}
}

$dist ||= $c->get_param('distance') || '';
$dist //= $c->get_param('distance') || '';
$dist = 1000 unless $dist =~ /^\d+$/;
$dist = 1000 if $dist > 1000;

Expand Down Expand Up @@ -839,7 +845,15 @@ sub stash_category_groups : Private {
my $contact = $category_groups{$_}[0];
push @list, [ $contact->category_display, $contact ];
} else {
push @list, [ $_, { id => $id, name => $_, categories => $category_groups{$_} } ];
my $cats = $category_groups{$_};
@$cats = sort {
my $aa = $a->category_display;
return 1 if $aa eq _('Other');
my $bb = $b->category_display;
return -1 if $bb eq _('Other');
$aa cmp $bb;
} @$cats;
push @list, [ $_, { id => $id, name => $_, categories => $cats } ];
}
}
@list = sort {
Expand Down
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/Cobrand/Default.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,8 @@ inspector de-duplication and report duplicate suggestions features.

Defaults to 1000m for inspectors, 250m for duplicate suggestions.

Returning a distance of 0 means no nearby reports will be returned at all.

Should return a hashref of the form

{
Expand Down
Loading
Loading