diff options
-rw-r--r-- | .cypress/cypress/integration/bathnes.js | 24 | ||||
-rwxr-xr-x | bin/browser-tests | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/BathNES.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Hounslow.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 6 | ||||
-rw-r--r-- | t/cobrand/hounslow.t | 14 | ||||
-rw-r--r-- | templates/web/bathnes/footer_extra_js.html | 8 | ||||
-rw-r--r-- | web/cobrands/bristol/assets.js | 77 |
8 files changed, 68 insertions, 76 deletions
diff --git a/.cypress/cypress/integration/bathnes.js b/.cypress/cypress/integration/bathnes.js index c675c34fa..1acbd3602 100644 --- a/.cypress/cypress/integration/bathnes.js +++ b/.cypress/cypress/integration/bathnes.js @@ -2,3 +2,27 @@ it('loads the right front page', function() { cy.visit('http://bathnes.localhost:3001/'); cy.contains('North East Somerset'); }); + +it('loads the staff layer correctly', function() { + cy.request({ + method: 'POST', + url: 'http://bathnes.localhost:3001/auth?r=/', + form: true, + body: { username: 'admin@example.org', password_sign_in: 'password' } + }); + cy.visit('http://bathnes.localhost:3001/'); + cy.contains('Your account'); + cy.get('[name=pc]').type(Cypress.env('postcode')); + cy.get('[name=pc]').parents('form').submit(); + cy.url().should('include', '/around'); + cy.window().its('fixmystreet.maps').should('have.property', 'banes_defaults'); + cy.window().then(function(win){ + var llpg = 0; + win.fixmystreet.map.layers.forEach(function(lyr) { + if (lyr.fixmystreet && lyr.fixmystreet.http_options.params.TYPENAME === 'LLPG') { + llpg++; + } + }); + expect(llpg).to.equal(1); + }); +}); diff --git a/bin/browser-tests b/bin/browser-tests index 6ce9159bf..11d83d133 100755 --- a/bin/browser-tests +++ b/bin/browser-tests @@ -88,6 +88,7 @@ sub run { ALLOWED_COBRANDS => $cobrand, MAPIT_URL => $mapit_url, BASE_URL => 'http://fixmystreet.localhost:3001', + STAGING_FLAGS => { skip_checks => 1 }, COBRAND_FEATURES => { category_groups => { map { $_ => 1 } @$cobrand }, } diff --git a/perllib/FixMyStreet/Cobrand/BathNES.pm b/perllib/FixMyStreet/Cobrand/BathNES.pm index 05c91c8dd..b6014a276 100644 --- a/perllib/FixMyStreet/Cobrand/BathNES.pm +++ b/perllib/FixMyStreet/Cobrand/BathNES.pm @@ -76,18 +76,6 @@ sub send_questionnaires { 0 } sub default_map_zoom { 3 } -sub map_js_extra { - my $self = shift; - - my $c = $self->{c}; - return unless $c->user_exists; - - my $banes_user = $c->user->from_body && $c->user->from_body->areas->{$self->council_area_id}; - if ( $banes_user || $c->user->is_superuser ) { - return ['/cobrands/bathnes/staff.js']; - } -} - sub category_extra_hidden { my ($self, $meta) = @_; my $code = $meta->{code}; diff --git a/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm index 18063c4aa..93512f2b9 100644 --- a/perllib/FixMyStreet/Cobrand/Hounslow.pm +++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm @@ -16,7 +16,7 @@ sub enter_postcode_text { return "Enter a Hounslow street name and area, or postcode"; } -sub admin_user_domain { 'hounslowhighways.org' } +sub admin_user_domain { ('hounslowhighways.org', 'hounslow.gov.uk') } sub disambiguate_location { my $self = shift; diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 1fe346e43..794c3dec6 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -102,8 +102,10 @@ sub users_restriction { 'me.id' => [ { -in => $problem_user_ids }, { -in => $update_user_ids } ], ]; if ($self->can('admin_user_domain')) { - my $domain = $self->admin_user_domain; - push @$or_query, email => { ilike => "%\@$domain" }; + my @domains = $self->admin_user_domain; + @domains = map { { ilike => "%\@$_" } } @domains; + @domains = [ @domains ] if @domains > 1; + push @$or_query, email => @domains; } return $rs->search($or_query); diff --git a/t/cobrand/hounslow.t b/t/cobrand/hounslow.t index 43a5a5523..cb67ad397 100644 --- a/t/cobrand/hounslow.t +++ b/t/cobrand/hounslow.t @@ -9,7 +9,8 @@ $mech->create_contact_ok( email => 'pothole@example.org', ); -$mech->create_user_ok('staff@example.org', from_body => $hounslow_id); +my $user = $mech->create_user_ok('staff@example.org', from_body => $hounslow_id); +$user->user_body_permissions->create({ body_id => $hounslow_id, permission_type => 'user_edit' }); my $tfl = $mech->create_body_ok( 2483, 'TfL'); $mech->create_contact_ok( @@ -96,4 +97,15 @@ subtest "Shows external ID on report page to staff users only" => sub { }; }; +subtest "Admin searches right domains" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'hounslow', + }, sub { + foreach ('hounslowhighways.org', 'hounslow.gov.uk') { + $mech->get_ok('/admin/users?search=xyz@' . $_); + $mech->content_contains('xyz@' . $_); + } + }; +}; + done_testing(); diff --git a/templates/web/bathnes/footer_extra_js.html b/templates/web/bathnes/footer_extra_js.html index c195600fc..240767d48 100644 --- a/templates/web/bathnes/footer_extra_js.html +++ b/templates/web/bathnes/footer_extra_js.html @@ -12,3 +12,11 @@ IF bodyclass.match('mappage'); ); END %] +[%~ +SET council_area_id = c.cobrand.council_area_id; +IF c.user_exists AND ((c.user.from_body AND c.user.from_body.areas.$council_area_id) OR c.user.is_superuser); + scripts.push( + version('/cobrands/bathnes/staff.js'), + ); +END +%] diff --git a/web/cobrands/bristol/assets.js b/web/cobrands/bristol/assets.js index ac1f0c861..af9d0f7d0 100644 --- a/web/cobrands/bristol/assets.js +++ b/web/cobrands/bristol/assets.js @@ -6,7 +6,7 @@ if (!fixmystreet.maps) { // Assets are served from two different WFS feeds; one for lighting and one // for everything else. They have some options in common: -var common_options = { +var options = { max_resolution: { 'bristol': 0.33072982812632296, 'fixmystreet': 4.777314267158508 @@ -15,22 +15,20 @@ var common_options = { asset_type: 'spot', body: "Bristol City Council", srsName: "EPSG:27700", - geometryName: 'SHAPE' -}; - - -var options = $.extend({}, common_options, { + geometryName: 'SHAPE', wfs_url: "https://maps.bristol.gov.uk/arcgis/services/ext/FixMyStreetSupportData/MapServer/WFSServer", wfs_feature: "COD_ASSETS_POINT", asset_id_field: 'COD_ASSET_ID', propertyNames: [ 'COD_ASSET_ID', 'COD_USRN', 'COD_ASSET_TYPE' ], + filter_key: 'COD_ASSET_TYPE', attributes: { asset_id: 'COD_ASSET_ID', usrn: 'COD_USRN' } -}); +}; fixmystreet.assets.add(options, { + filter_key: '', wfs_feature: "COD_ASSETS_AREA", asset_type: 'area', asset_category: "Bridges/Subways", @@ -40,80 +38,39 @@ fixmystreet.assets.add(options, { fixmystreet.assets.add(options, { asset_category: "Gully/Drainage", asset_item: 'gully', - filter_key: 'COD_ASSET_TYPE', filter_value: 'GULLY' }); fixmystreet.assets.add(options, { asset_category: "Grit Bins", asset_item: 'grit bin', - filter_key: 'COD_ASSET_TYPE', filter_value: 'GRITBIN' }); - -var lighting_options = $.extend({}, common_options, { - wfs_url: "https://maps.bristol.gov.uk/arcgis/services/ext/datagov/MapServer/WFSServer", - wfs_feature: "Streetlights_and_Street_Furniture", - asset_id_field: 'Unit_ID', - propertyNames: [ 'USRN', 'Unit_ID', 'Unit_type_description' ], - attributes: { - asset_id: function() { - if (this.attributes && this.attributes.Unit_ID) { - if (this.attributes.Unit_ID.match(/^SL/)) { - // Just in case they ever start prefixing it in the WFS... - return this.attributes.Unit_ID; - } else { - return "SL" + this.attributes.Unit_ID; - } - } else { - return ""; - } - }, - usrn: 'USRN' - }, - filter_key: 'Unit_type_description' -}); - -fixmystreet.assets.add(lighting_options, { +fixmystreet.assets.add(options, { asset_category: "Street Light", asset_item: 'street light', - filter_value: [ - 'SL: Street Light', - 'SL: Silverspring CMS', - 'SL: Philips CMS', - 'SL: Feature Fld.Lgt', - 'SL: Gas Light', - 'SL: High Mast', - 'SL: Refuge Column', - 'SL: Subway' - ] + filter_value: [ 'S070', 'S080', 'S100', 'S110', 'S120', 'S170', 'S220', 'S230' ] }); -fixmystreet.assets.add(lighting_options, { +fixmystreet.assets.add(options, { asset_category: "Zebra Crossing Light", asset_item: 'light', - filter_value: 'SL: Zebra' + filter_value: 'S260' }); -fixmystreet.assets.add(lighting_options, { - asset_category: "Iluminated Bollard", - asset_item: 'bollard', - filter_value: 'SL: Bollard' -}); - -// NB there's a typo in BCC's ‘Iluminated Bollard’ category so this repeats -// the above (without the typo) just in case they fix it. -fixmystreet.assets.add(lighting_options, { - asset_category: "Illuminated Bollard", +// NB there's a typo in BCC's ‘Iluminated Bollard’ category so this +// includes the correct spelling just in case they fix it. +fixmystreet.assets.add(options, { + asset_category: [ "Iluminated Bollard", "Illuminated Bollard" ], asset_item: 'bollard', - filter_value: 'SL: Bollard' + filter_value: 'S020' }); -fixmystreet.assets.add(lighting_options, { +fixmystreet.assets.add(options, { asset_category: "Illuminated Sign", asset_item: 'sign', - filter_value: 'SL: Sign' + filter_value: 'S180' }); var redirects = { @@ -127,7 +84,7 @@ var redirects = { $.each(redirects, function(name, value) { fixmystreet.message_controller.register_category({ - body: common_options.body, + body: options.body, category: name, message: 'If you wish to report an issue with ' + name + ', please use <a href="' + value + '">this service</a>.' }); |