diff options
author | Struan Donald <struan@exo.org.uk> | 2019-04-25 14:02:51 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2019-09-27 17:18:37 +0100 |
commit | effcb0f3043f3684e94db4866d0b434440e8ba53 (patch) | |
tree | d4c5db0bd5b4baa067f914c15ff25b9933be8f29 | |
parent | 8b962fdf43724c853b5959539b36b4d46b25639f (diff) |
[IsleOfWight] Initial cobrand.
Co-authored-by: Matthew Somerville <matthew@mysociety.org>
Configured to allow:
- updates only from original reporter
- close updates from fetch reports
- use OSM geocoder
26 files changed, 313 insertions, 22 deletions
diff --git a/.cypress/cypress/integration/isleofwight.js b/.cypress/cypress/integration/isleofwight.js new file mode 100644 index 000000000..430bd0aa8 --- /dev/null +++ b/.cypress/cypress/integration/isleofwight.js @@ -0,0 +1,19 @@ +describe('When you look at the Island Roads site', function() { + + beforeEach(function() { + cy.server(); + cy.fixture('roads.xml'); + cy.route('/report/new/ajax*').as('report-ajax'); + cy.visit('http://isleofwight.localhost:3001/'); + cy.contains('Island Roads'); + cy.get('[name=pc]').type('PO30 5XJ'); + cy.get('[name=pc]').parents('form').submit(); + }); + + it('uses the correct name', function() { + cy.get('#map_box').click(); + cy.wait('@report-ajax'); + cy.get('select:eq(4)').select('Potholes'); + cy.contains('sent to Island Roads'); + }); +}); diff --git a/bin/browser-tests b/bin/browser-tests index 013c0d8d3..0180db0b5 100755 --- a/bin/browser-tests +++ b/bin/browser-tests @@ -11,7 +11,7 @@ my ($cobrand, $coords, $area_id, $name, $mapit_url); BEGIN { $config_file = 'conf/general.yml-example'; - $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow' ]; + $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow', 'isleofwight' ]; $coords = '51.532851,-2.284277'; $area_id = 2608; $name = 'Borsetshire'; @@ -150,7 +150,7 @@ browser-tests [running options] [fixture options] [cypress options] --help this help message Fixture option: - --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire + --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight --coords Default co-ordinates for created reports --area_id Area ID to use for created body --name Name to use for created body diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture index 760c76414..98556393e 100755 --- a/bin/fixmystreet.com/fixture +++ b/bin/fixmystreet.com/fixture @@ -99,6 +99,7 @@ if ($opt->test_fixtures) { { area_id => 2257, categories => ['Flytipping', 'Graffiti'], name => 'Chiltern District Council' }, { area_id => 2397, categories => [ 'Graffiti' ], name => 'Northampton Borough Council' }, { area_id => 2483, categories => [ 'Potholes', 'Other' ], name => 'Hounslow Borough Council' }, + { area_id => 2636, categories => [ 'Potholes' ], name => 'Isle of Wight Council' }, ) { $bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_); my $cats = join(', ', @{$_->{categories}}); diff --git a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm new file mode 100644 index 000000000..336649971 --- /dev/null +++ b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm @@ -0,0 +1,70 @@ +package FixMyStreet::Cobrand::IsleOfWight; +use parent 'FixMyStreet::Cobrand::Whitelabel'; + +use strict; +use warnings; + +sub council_area_id { 2636 } +sub council_area { 'Isle of Wight' } +sub council_name { 'Island Roads' } +sub council_url { 'isleofwight' } +sub all_reports_single_body { { name => "Isle of Wight Council" } } +sub link_to_council_cobrand { "Island Roads" } + +sub enter_postcode_text { + my ($self) = @_; + return 'Enter an ' . $self->council_area . ' postcode, or street name and area'; +} + +sub on_map_default_status { 'open' } + +sub send_questionnaires { 0 } + +sub map_type { 'OSM' } + +sub disambiguate_location { + my $self = shift; + my $string = shift; + + return { + %{ $self->SUPER::disambiguate_location() }, + centre => '50.675761,-1.296571', + bounds => [ 50.574653, -1.591732, 50.767567, -1.062957 ], + }; +} + +sub updates_disallowed { + my ($self, $problem) = @_; + + my $c = $self->{c}; + return 0 if $c->user_exists && $c->user->id eq $problem->user->id; + return 1; +} + +sub get_geocoder { 'OSM' } + +sub open311_get_update_munging { + my ($self, $comment) = @_; + + # If we've received an update via Open311 that's closed + # or fixed the report, also close it to updates. + $comment->problem->set_extra_metadata(closed_updates => 1) + if !$comment->problem->is_open; +} + +sub open311_config { + my ($self, $row, $h, $params) = @_; + + my $extra = $row->get_extra_fields; + push @$extra, + { name => 'report_url', + value => $h->{url} }, + { name => 'title', + value => $row->title }, + { name => 'description', + value => $row->detail }; + + $row->set_extra_fields(@$extra); +} + +1; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 39f446549..1ffcc7b40 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -231,6 +231,8 @@ sub meta_line { $body = "$body <img src='/cobrands/greenwich/favicon.png' alt=''>"; } elsif ($body eq 'Hounslow Borough Council') { $body = 'Hounslow Highways'; + } elsif ($body eq 'Isle of Wight Council') { + $body = 'Island Roads'; } } my $cobrand_always_view_body_user = $c->cobrand->call_hook("always_view_body_contribute_details"); diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index b5cc694df..8b8bb5978 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -49,6 +49,7 @@ my @PLACES = ( [ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ], [ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ], [ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ], + [ 'PO30 5XJ', 50.71086, -1.29573, 2636, 'Isle of Wight Council', 'UTA' ], [ 'OX28 4DS', 51.784721, -1.494453 ], [ 'E14 2DN', 51.508536, '0.000001' ], # Norway diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t new file mode 100644 index 000000000..c3e5a7810 --- /dev/null +++ b/t/cobrand/isleofwight.t @@ -0,0 +1,37 @@ +use FixMyStreet::TestMech; + +ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); + +my $isleofwight_id = $mech->create_body_ok(2636, 'Isle of Wight Council')->id; +$mech->create_contact_ok( + body_id => $isleofwight_id, + category => 'Potholes', + email => 'pothole@example.org', +); + +my $user = $mech->create_user_ok('user@example.org'); + +my @reports = $mech->create_problems_for_body(1, $isleofwight_id, 'An Isle of wight report', { + confirmed => '2019-05-25 09:00', + lastupdate => '2019-05-25 09:00', + latitude => 50.7108, + longitude => -1.29573, + user => $user +}); + +subtest "only original reporter can comment" => sub { + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + ALLOWED_COBRANDS => 'isleofwight', + }, sub { + $mech->get_ok('/report/' . $reports[0]->id); + $mech->content_contains('Only the original reporter may leave updates'); + + $mech->log_in_ok('user@example.org'); + $mech->get_ok('/report/' . $reports[0]->id); + $mech->content_lacks('Only the original reporter may leave updates'); + }; +}; + + +done_testing(); diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 809fd3a19..382f684f9 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -24,6 +24,7 @@ my $user = FixMyStreet::DB->resultset('User')->find_or_create( my %bodies = ( 2237 => FixMyStreet::DB->resultset("Body")->create({ name => 'Oxfordshire' }), 2494 => FixMyStreet::DB->resultset("Body")->create({ name => 'Bexley' }), + 2636 => FixMyStreet::DB->resultset("Body")->create({ name => 'Isle of Wight' }), 2482 => FixMyStreet::DB->resultset("Body")->create({ name => 'Bromley', send_method => 'Open311', @@ -36,6 +37,7 @@ my %bodies = ( ); $bodies{2237}->body_areas->create({ area_id => 2237 }); $bodies{2494}->body_areas->create({ area_id => 2494 }); +$bodies{2636}->body_areas->create({ area_id => 2636 }); my $response_template = $bodies{2482}->response_templates->create({ title => "investigating template", @@ -529,29 +531,34 @@ for my $test ( }; } -subtest 'Marking report as fixed closes it for updates (Bexley)' => sub { - my $local_requests_xml = setup_xml($problemB->external_id, $problemB->id, 'CLOSED'); - my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); +for ( + { id => 2494, cobrand => 'bexley' }, + { id => 2636, cobrand => 'isleofwight' } +) { + subtest "Marking report as fixed closes it for updates ($_->{cobrand})" => sub { + my $local_requests_xml = setup_xml($problemB->external_id, $problemB->id, 'CLOSED'); + my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); - $problemB->update( { bodies_str => $bodies{2494}->id } ); + $problemB->update( { bodies_str => $bodies{$_->{id}}->id } ); - my $update = Open311::GetServiceRequestUpdates->new( - system_user => $user, - current_open311 => $o, - current_body => $bodies{2494}, - current_cobrand => $bodies{2494}->get_cobrand_handler, - ); - FixMyStreet::override_config { - ALLOWED_COBRANDS => 'bexley', - }, sub { - $update->process_body; - }; + my $update = Open311::GetServiceRequestUpdates->new( + system_user => $user, + current_open311 => $o, + current_body => $bodies{$_->{id}}, + current_cobrand => $bodies{$_->{id}}->get_cobrand_handler, + ); + FixMyStreet::override_config { + ALLOWED_COBRANDS => $_->{cobrand}, + }, sub { + $update->process_body; + }; - $problemB->discard_changes; - is $problemB->comments->count, 1, 'comment count'; - is $problemB->get_extra_metadata('closed_updates'), 1; - $problemB->comments->delete; -}; + $problemB->discard_changes; + is $problemB->comments->count, 1, 'comment count'; + is $problemB->get_extra_metadata('closed_updates'), 1; + $problemB->comments->delete; + }; +} subtest 'Update with media_url includes image in update' => sub { my $UPLOAD_DIR = tempdir( CLEANUP => 1 ); diff --git a/templates/email/isleofwight/_council_reference.html b/templates/email/isleofwight/_council_reference.html new file mode 100644 index 000000000..5b73ee7e7 --- /dev/null +++ b/templates/email/isleofwight/_council_reference.html @@ -0,0 +1,4 @@ +[% IF problem.external_id ~%] +<p style="[% p_style %]">The report's reference number is <strong>[% problem.external_id %]</strong>. + Please quote this if you need to contact Island Roads about this report.</p> +[%~ END %] diff --git a/templates/email/isleofwight/_council_reference.txt b/templates/email/isleofwight/_council_reference.txt new file mode 100644 index 000000000..d6922217d --- /dev/null +++ b/templates/email/isleofwight/_council_reference.txt @@ -0,0 +1,2 @@ +[% IF problem.external_id %]The report's reference number is [% problem.external_id %]. Please quote this if +you need to contact Island Roads about this report.[% END %] diff --git a/templates/email/isleofwight/_council_reference_alert_update.html b/templates/email/isleofwight/_council_reference_alert_update.html new file mode 100644 index 000000000..5b73ee7e7 --- /dev/null +++ b/templates/email/isleofwight/_council_reference_alert_update.html @@ -0,0 +1,4 @@ +[% IF problem.external_id ~%] +<p style="[% p_style %]">The report's reference number is <strong>[% problem.external_id %]</strong>. + Please quote this if you need to contact Island Roads about this report.</p> +[%~ END %] diff --git a/templates/email/isleofwight/_council_reference_alert_update.txt b/templates/email/isleofwight/_council_reference_alert_update.txt new file mode 100644 index 000000000..d6922217d --- /dev/null +++ b/templates/email/isleofwight/_council_reference_alert_update.txt @@ -0,0 +1,2 @@ +[% IF problem.external_id %]The report's reference number is [% problem.external_id %]. Please quote this if +you need to contact Island Roads about this report.[% END %] diff --git a/templates/email/isleofwight/_email_color_overrides.html b/templates/email/isleofwight/_email_color_overrides.html new file mode 100644 index 000000000..3d6218ca4 --- /dev/null +++ b/templates/email/isleofwight/_email_color_overrides.html @@ -0,0 +1,19 @@ +[% + +color_cyan = '#00aeef' +color_blue = '#00478c' +color_green = '#75c044' +color_white = '#fff' + +header_background_color = color_white +header_text_color = color_blue + +secondary_column_background_color = color_white + +button_background_color = color_green +button_text_color = color_white + +logo_width = "282" # pixel measurement, but without 'px' suffix +logo_height = "76" # pixel measurement, but without 'px' suffix + +%] diff --git a/templates/web/base/reports/body.html b/templates/web/base/reports/body.html index 02791ba3b..23540104b 100755 --- a/templates/web/base/reports/body.html +++ b/templates/web/base/reports/body.html @@ -1,6 +1,8 @@ [% SET body_name = body.name %] [% IF c.cobrand.moniker == 'hounslow' %] [% SET body_name = 'Hounslow Highways' %] +[% ELSIF c.cobrand.moniker == 'isleofwight' %] + [% SET body_name = 'Island Roads' %] [% END %] [% IF ward %] diff --git a/templates/web/isleofwight/footer_extra_js.html b/templates/web/isleofwight/footer_extra_js.html new file mode 100644 index 000000000..2f5e03f86 --- /dev/null +++ b/templates/web/isleofwight/footer_extra_js.html @@ -0,0 +1,3 @@ +[% scripts.push( + version('/cobrands/isleofwight/js.js'), +) %] diff --git a/templates/web/isleofwight/header_extra.html b/templates/web/isleofwight/header_extra.html new file mode 100644 index 000000000..8a977495f --- /dev/null +++ b/templates/web/isleofwight/header_extra.html @@ -0,0 +1 @@ +[% INCLUDE 'tracking_code.html' %] diff --git a/templates/web/isleofwight/header_logo.html b/templates/web/isleofwight/header_logo.html new file mode 100644 index 000000000..e563007a7 --- /dev/null +++ b/templates/web/isleofwight/header_logo.html @@ -0,0 +1,2 @@ +<a href="http://www.islandroads.com" id="site-logo">Island Roads</a> +<a href="/" id="report-cta" title="[%- loc('Report a problem') -%]">[%- loc('Report') -%]</a> diff --git a/templates/web/isleofwight/report/_updates_disallowed_message.html b/templates/web/isleofwight/report/_updates_disallowed_message.html new file mode 100644 index 000000000..af56f73b1 --- /dev/null +++ b/templates/web/isleofwight/report/_updates_disallowed_message.html @@ -0,0 +1,8 @@ +<p> + Only the original reporter may leave updates. + [% IF NOT c.user_exists %] + If you made the original report please + <a href="/auth?r=report/[% problem.id %]">log in</a> + to leave an update. + [% END %] +</p> diff --git a/templates/web/isleofwight/report/new/councils_text_all.html b/templates/web/isleofwight/report/new/councils_text_all.html new file mode 100644 index 000000000..199c92314 --- /dev/null +++ b/templates/web/isleofwight/report/new/councils_text_all.html @@ -0,0 +1,5 @@ +<p> + These will be sent to <strong>Island Roads</strong> and also published + online for others to see, in accordance with our + <a href="[% c.cobrand.privacy_policy_url %]">privacy policy</a>. +</p> diff --git a/templates/web/isleofwight/tracking_code.html b/templates/web/isleofwight/tracking_code.html new file mode 100644 index 000000000..26358b589 --- /dev/null +++ b/templates/web/isleofwight/tracking_code.html @@ -0,0 +1,16 @@ +[% IF c.config.BASE_URL == "https://www.fixmystreet.com" %] + +<script> + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); + + ga('create', 'UA-136557400-2', 'auto'); + ga('send', 'pageview'); + +</script> + +[% ELSE %] +<!-- Tracking code not inserted as "[% c.config.BASE_URL %]" not "https://www.fixmystreet.com" --> +[% END %] diff --git a/web/cobrands/isleofwight/_colours.scss b/web/cobrands/isleofwight/_colours.scss new file mode 100644 index 000000000..688eb66e0 --- /dev/null +++ b/web/cobrands/isleofwight/_colours.scss @@ -0,0 +1,31 @@ +/* COLOURS */ + +$menu-image: 'menu-black'; + +$mappage-header-height: 124px; + +$blue: #00478c; +$cyan: #00aeef; // + 60 25 +$orange: #fcaf17; +$green: #75c044; + +//Any 20% tint of the above + +$primary_text: #fff; +$primary: $cyan; +$primary_b: #222; + +$base_bg: #fff; +$base_fg: #222; + +$nav_background_colour: #fff; +$nav_colour: $blue; +$nav_hover_background_colour: $cyan; + +$col_click_map: $green; + +$header-top-border: false; + +$body-font: Helvetica, Arial, sans-serif; +$heading-font: $body-font; +$meta-font: $body-font; diff --git a/web/cobrands/isleofwight/base.scss b/web/cobrands/isleofwight/base.scss new file mode 100644 index 000000000..c499b259f --- /dev/null +++ b/web/cobrands/isleofwight/base.scss @@ -0,0 +1,14 @@ +@import "../sass/h5bp"; +@import "./_colours"; +@import "../sass/mixins"; +@import "../sass/base"; + +/* Header */ + +#site-logo { + width: 141px; + height: 38px; + padding: 1em 0; + background: url(/cobrands/isleofwight/images/logo.gif) 0 50% no-repeat; + background-size: 141px 38px; +} diff --git a/web/cobrands/isleofwight/images/email-logo.gif b/web/cobrands/isleofwight/images/email-logo.gif new file mode 120000 index 000000000..94a12010e --- /dev/null +++ b/web/cobrands/isleofwight/images/email-logo.gif @@ -0,0 +1 @@ +logo.gif
\ No newline at end of file diff --git a/web/cobrands/isleofwight/images/logo.gif b/web/cobrands/isleofwight/images/logo.gif Binary files differnew file mode 100644 index 000000000..7238ca8a3 --- /dev/null +++ b/web/cobrands/isleofwight/images/logo.gif diff --git a/web/cobrands/isleofwight/js.js b/web/cobrands/isleofwight/js.js new file mode 100644 index 000000000..ed106cef6 --- /dev/null +++ b/web/cobrands/isleofwight/js.js @@ -0,0 +1,20 @@ +(function(){ + +if (!fixmystreet.maps) { + return; +} + + +if (fixmystreet.cobrand == 'isleofwight') { + // We want the cobranded site to always display "Island Roads" + // as the destination for reports in the "Public details" section. + // This is OK because the cobranded site only shows categories which + // Island Roads actually handle. + // Replacing this function with a no-op stops the changes made + // to the cobranded councils_text_all.html from being clobbered and + // the 'correct' (according to bodies set up within FMS) body names + // being shown. + fixmystreet.update_public_councils_text = function() {}; +} + +})(); diff --git a/web/cobrands/isleofwight/layout.scss b/web/cobrands/isleofwight/layout.scss new file mode 100644 index 000000000..e3d362969 --- /dev/null +++ b/web/cobrands/isleofwight/layout.scss @@ -0,0 +1,20 @@ +@import "_colours"; + +@import "../sass/layout"; + +body.twothirdswidthpage .content .sticky-sidebar aside { + top: 10em; +} + +#site-logo { + width: 282px; + height: 76px; + padding: 24px 0; + background-position: 0px 50%; + background-size: 282px 76px; +} + +.mappage #site-header { + box-sizing: border-box; + border-bottom: solid 5px $cyan; +} |