diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bexley.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Rutland.pm | 4 | ||||
-rw-r--r-- | t/cobrand/bexley.t | 91 | ||||
-rw-r--r-- | web/cobrands/fixmystreet-uk-councils/council_validation_rules.js | 4 | ||||
-rw-r--r-- | web/cobrands/northamptonshire/assets.js | 16 |
5 files changed, 96 insertions, 47 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm index 8720f42d8..d3787ef67 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley.pm @@ -103,16 +103,26 @@ sub open311_post_send { my %lighting = map { $_ => 1 } @lighting; my $emails = $self->feature('open311_email') || return; - my ($e, $n); - if ($row->category eq 'Abandoned and untaxed vehicles' || $row->category eq 'Dead animal') { - $e = $emails->{p1}; - $n = 'Bexley P1 email'; - } elsif ($lighting{$row->category}) { - $e = $emails->{lighting}; - $n = 'FixMyStreet Bexley Street Lighting'; + my $dangerous = $row->get_extra_field_value('dangerous') || ''; + my $reportType = $row->get_extra_field_value('reportType') || ''; + + my $p1_email = 0; + if ($row->category eq 'Parks and open spaces') { + $p1_email = 1 if $reportType =~ /locked in a park|Wild animal/; + $p1_email = 1 if $dangerous eq 'Yes' && $reportType =~ /Playgrounds|park furniture|gates are broken|Vandalism|Other/; + } else { + $p1_email = 1 if $dangerous eq 'Yes'; } - return unless $e; - my $sender = FixMyStreet::SendReport::Email->new( to => [ [ $e, $n ] ] ); + + my @to; + if ($row->category eq 'Abandoned and untaxed vehicles' || $row->category eq 'Dead animal' || $p1_email) { + push @to, [ $emails->{p1}, 'Bexley P1 email' ] if $emails->{p1}; + } + if ($lighting{$row->category}) { + push @to, [ $emails->{lighting}, 'FixMyStreet Bexley Street Lighting' ] if $emails->{lighting}; + } + return unless @to; + my $sender = FixMyStreet::SendReport::Email->new( to => \@to ); $self->open311_config($row); # Populate NSGRef again if needed diff --git a/perllib/FixMyStreet/Cobrand/Rutland.pm b/perllib/FixMyStreet/Cobrand/Rutland.pm index 407d43d14..97bcfe637 100644 --- a/perllib/FixMyStreet/Cobrand/Rutland.pm +++ b/perllib/FixMyStreet/Cobrand/Rutland.pm @@ -12,6 +12,10 @@ sub council_url { return 'rutland'; } sub report_validation { my ($self, $report, $errors) = @_; + if ( length( $report->title ) > 254 ) { + $errors->{title} = sprintf( _('Summaries are limited to %s characters in length. Please shorten your summary'), 254 ); + } + if ( length( $report->name ) > 40 ) { $errors->{name} = sprintf( _('Names are limited to %d characters in length.'), 40 ); } diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t index f6ec1014d..07d7ed91b 100644 --- a/t/cobrand/bexley.t +++ b/t/cobrand/bexley.t @@ -31,6 +31,9 @@ my $body = $mech->create_body_ok(2494, 'London Borough of Bexley', { send_method => 'Open311', api_key => 'key', 'endpoint' => 'e', 'jurisdiction' => 'j' }); $mech->create_contact_ok(body_id => $body->id, category => 'Abandoned and untaxed vehicles', email => "ABAN"); $mech->create_contact_ok(body_id => $body->id, category => 'Lamp post', email => "LAMP"); +$mech->create_contact_ok(body_id => $body->id, category => 'Parks and open spaces', email => "PARK"); +$mech->create_contact_ok(body_id => $body->id, category => 'Dead animal', email => "ANIM"); +$mech->create_contact_ok(body_id => $body->id, category => 'Something dangerous', email => "DANG"); FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'bexley' ], @@ -50,40 +53,62 @@ FixMyStreet::override_config { $mech->content_contains('Bexley'); }; - my ($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', { - category => 'Abandoned and untaxed vehicles', cobrand => 'bexley', - latitude => 51.408484, longitude => 0.074653, - }); - $report->set_extra_fields({ 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'Yes' }); - $report->update; - - subtest 'Server-side NSGRef included' => sub { - my $test_data = FixMyStreet::Script::Reports::send(); - my $req = $test_data->{test_req_used}; - my $c = CGI::Simple->new($req->content); - is $c->param('service_code'), 'ABAN'; - is $c->param('attribute[NSGRef]'), 'Road ID'; - - my $email = $mech->get_email; - like $email->header('To'), qr/"Bexley P1 email".*bexley/; - like $mech->get_text_body_from_email($email), qr/NSG Ref: Road ID/; - $mech->clear_emails_ok; - }; - - ($report) = $mech->create_problems_for_body(1, $body->id, 'Lamp', { - category => 'Lamp post', cobrand => 'bexley', - latitude => 51.408484, longitude => 0.074653, - }); - - subtest 'Correct email sent' => sub { - my $test_data = FixMyStreet::Script::Reports::send(); - my $req = $test_data->{test_req_used}; - my $c = CGI::Simple->new($req->content); - is $c->param('service_code'), 'LAMP'; + foreach my $test ( + { category => 'Abandoned and untaxed vehicles', email => 1, code => 'ABAN', + extra => { 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'Yes' } }, + { category => 'Abandoned and untaxed vehicles', code => 'ABAN', + extra => { 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'No' } }, + { category => 'Dead animal', email => 1, code => 'ANIM' }, + { category => 'Something dangerous', email => 1, code => 'DANG', + extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } }, + { category => 'Something dangerous', code => 'DANG', + extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } }, + { category => 'Parks and open spaces', email => 1, code => 'PARK', + extra => { 'name' => 'reportType', description => 'Type of report', 'value' => 'Wild animal' } }, + { category => 'Parks and open spaces', code => 'PARK', + extra => { 'name' => 'reportType', description => 'Type of report', 'value' => 'Maintenance' } }, + { category => 'Parks and open spaces', code => 'PARK', + extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } }, + { category => 'Parks and open spaces', email => 1, code => 'PARK', + extra => [ + { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' }, + { 'name' => 'reportType', description => 'Type of report', 'value' => 'Vandalism' }, + ] }, + { category => 'Lamp post', code => 'LAMP', email => 'thirdparty', + extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } }, + { category => 'Lamp post', code => 'LAMP', email => 'p1.*thirdparty', + extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } }, + ) { + my ($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', { + category => $test->{category}, cobrand => 'bexley', + latitude => 51.408484, longitude => 0.074653, + }); + if ($test->{extra}) { + $report->set_extra_fields(ref $test->{extra} eq 'ARRAY' ? @{$test->{extra}} : $test->{extra}); + $report->update; + } - my $email = $mech->get_email; - like $email->header('To'), qr/thirdparty/; - }; + subtest 'NSGRef and correct email config' => sub { + my $test_data = FixMyStreet::Script::Reports::send(); + my $req = $test_data->{test_req_used}; + my $c = CGI::Simple->new($req->content); + is $c->param('service_code'), $test->{code}; + is $c->param('attribute[NSGRef]'), 'Road ID'; + + if (my $t = $test->{email}) { + my $email = $mech->get_email; + if ($t eq 1) { + like $email->header('To'), qr/"Bexley P1 email".*bexley/; + } else { + like $email->header('To'), qr/$t/; + } + like $mech->get_text_body_from_email($email), qr/NSG Ref: Road ID/; + $mech->clear_emails_ok; + } else { + $mech->email_count_is(0); + } + }; + } }; diff --git a/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js b/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js index ee3dfde88..49c23db89 100644 --- a/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js +++ b/web/cobrands/fixmystreet-uk-councils/council_validation_rules.js @@ -17,6 +17,10 @@ body_validation_rules = { 'Lincolnshire County Council': confirm_validation_rules, 'Bath and North East Somerset Council': confirm_validation_rules, 'Rutland County Council': { + title: { + required: true, + maxlength: 254 + }, name: { required: true, maxlength: 40 diff --git a/web/cobrands/northamptonshire/assets.js b/web/cobrands/northamptonshire/assets.js index fe726a1a8..07745ac8b 100644 --- a/web/cobrands/northamptonshire/assets.js +++ b/web/cobrands/northamptonshire/assets.js @@ -257,26 +257,28 @@ var layers = [ }, { "categories": [ "Bridge-Damaged/ Missing" ], - "item_name": "bridge", + "item_name": "bridge or right of way", "layer_name": "BRIDGES", "layer": 177, "version": "177.18-" }, { "categories": [ "Gate - Damaged/ Missing" ], + "item_name": "gate or right of way", "layer_name": "GATE", "layer": 181, "version": "181.3-" }, { "categories": [ "Stile-Damaged/Missing" ], + "item_name": "stile or right of way", "layer_name": "STILE", "layer": 185, "version": "185.3-" }, { "categories": [ "Sign/Waymarking - Damaged/Missing" ], - "item_name": "waymarking", + "item_name": "waymarking or right of way", "layer_name": "WAYMARK POST", "layer": 187, "version": "187.3-" @@ -485,8 +487,8 @@ var highways_style = new OpenLayers.Style({ fixmystreet.assets.add(northants_road_defaults, { protocol_class: OpenLayers.Protocol.Alloy, http_options: { - layerid: is_live ? 20 : 308, - layerVersion: is_live ? '20.123-' : '308.8-', + layerid: 20, + layerVersion: '20.143-', }, stylemap: new OpenLayers.StyleMap({ 'default': highways_style @@ -541,8 +543,12 @@ fixmystreet.assets.add(northants_road_defaults, { no_asset_msg_id: "#js-not-a-road", asset_item: 'right of way', asset_category: [ + "Bridge-Damaged/ Missing", + "Gate - Damaged/ Missing", "Livestock", - "Passage-Obstructed/Overgrown" + "Passage-Obstructed/Overgrown", + "Sign/Waymarking - Damaged/Missing", + "Stile-Damaged/Missing" ] }); |