diff options
22 files changed, 92 insertions, 59 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 1b75b9ba2..6a41d93a9 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -368,8 +368,8 @@ sub construct_email { my $vars = { from => [ $sender, _($sender_name) ], %{ $c->stash }, - %$extra_stash_values, additional_template_paths => \@include_path, + %$extra_stash_values, }; $vars->{site_name} = Utils::trim_text($c->view('EmailText')->render($c, 'site-name.txt', $vars)); $vars->{signature} = $c->view('EmailText')->render($c, 'signature.txt', $vars); diff --git a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm index 3b7739966..18bcbbc5f 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm @@ -248,7 +248,8 @@ sub update_contact : Private { my $email = $c->get_param('email'); $email =~ s/\s+//g; my $send_method = $c->get_param('send_method') || $contact->body->send_method || ""; - unless ( $send_method eq 'Open311' ) { + my $email_unchanged = $contact->email && $email && $contact->email eq $email; + unless ( $send_method eq 'Open311' || $email_unchanged ) { $errors{email} = _('Please enter a valid email') unless is_valid_email_list($email) || $email eq 'REFUSED'; } diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index 3a4480e85..058fa3806 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -548,13 +548,15 @@ sub heatmap_filters :Private { my ($self, $c, $where) = @_; # Wards - my @areas = @{$c->user->area_ids || []}; - # Want to get everything if nothing given in an ajax call - if (!$c->stash->{wards} && @areas) { - $c->stash->{wards} = [ map { { id => $_ } } @areas ]; - $where->{areas} = [ - map { { 'like', '%,' . $_ . ',%' } } @areas - ]; + if ($c->user_exists) { + my @areas = @{$c->user->area_ids || []}; + # Want to get everything if nothing given in an ajax call + if (!$c->stash->{wards} && @areas) { + $c->stash->{wards} = [ map { { id => $_ } } @areas ]; + $where->{areas} = [ + map { { 'like', '%,' . $_ . ',%' } } @areas + ]; + } } # Date range @@ -588,9 +590,14 @@ sub heatmap_sidebar :Private { my $params = { map { my $n = $_; s/me\./problem\./; $_ => $where->{$n} } keys %$where }; my $body = $c->stash->{body}; + + my @user; + push @user, $c->user->id if $c->user_exists; + push @user, $body->comment_user_id if $body->comment_user_id; + $params->{'me.user_id'} = { -not_in => \@user } if @user; + my @c = $c->model('DB::Comment')->to_body($body)->search({ %$params, - 'me.user_id' => { -not_in => [ $c->user->id, $body->comment_user_id || () ] }, 'me.state' => 'confirmed', }, { columns => 'problem_id', diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index cbbf8971a..ba37a25fa 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -691,6 +691,8 @@ sub setup_categories_and_bodies : Private { ->search( { 'me.body_id' => [ keys %bodies ] }, { prefetch => 'body' } ); my @contacts = $c->cobrand->categories_restriction($contacts)->all_sorted; + $c->cobrand->call_hook(munge_report_new_contacts => \@contacts); + # variables to populate my %bodies_to_list = (); # Bodies with categories assigned my @category_options = (); # categories to show diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index 6e0a0e2a5..fcbeebb48 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -83,8 +83,8 @@ sub munge_reports_categories_list { } } -sub munge_report_new_category_list { - my ($self, $options, $contacts, $extras) = @_; +sub munge_report_new_contacts { + my ($self, $contacts) = @_; my %bodies = map { $_->body->name => $_->body } @$contacts; @@ -92,20 +92,16 @@ sub munge_report_new_category_list { my $user = $self->{c}->user; if ( $user && ( $user->is_superuser || $user->belongs_to_body( $bodies{'Isle of Wight Council'}->id ) ) ) { @$contacts = grep { !$_->send_method || $_->send_method ne 'Triage' } @$contacts; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; return; } @$contacts = grep { $_->send_method && $_->send_method eq 'Triage' } @$contacts; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; } if ( $bodies{'TfL'} ) { # Presented categories vary if we're on/off a red route my $tfl = FixMyStreet::Cobrand->get_class_for_moniker( 'tfl' )->new({ c => $self->{c} }); - $tfl->munge_red_route_categories($options, $contacts); + $tfl->munge_red_route_categories($contacts); } } diff --git a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm index ab79be832..a46b540ad 100644 --- a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm +++ b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm @@ -108,8 +108,8 @@ sub munge_reports_category_list { return @$categories; } -sub munge_report_new_category_list { - my ($self, $options, $contacts, $extras) = @_; +sub munge_report_new_contacts { + my ($self, $contacts) = @_; my $user = $self->{c}->user; my %bodies = map { $_->body->name => $_->body } @$contacts; @@ -117,14 +117,10 @@ sub munge_report_new_category_list { if ( $user && ( $user->is_superuser || $user->belongs_to_body( $b->id ) ) ) { @$contacts = grep { !$_->send_method || $_->send_method ne 'Triage' } @$contacts; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; return; } @$contacts = grep { $_->send_method && $_->send_method eq 'Triage' } @$contacts; - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; } sub munge_around_category_where { diff --git a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm index 60def9e15..bfcbf5af0 100644 --- a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm +++ b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm @@ -36,6 +36,8 @@ sub on_map_default_status { 'open' } sub report_sent_confirmation_email { 'id' } +sub admin_user_domain { 'northamptonshire.gov.uk' } + has body_obj => ( is => 'lazy', default => sub { diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm index 1449a9614..320f35991 100644 --- a/perllib/FixMyStreet/Cobrand/TfL.pm +++ b/perllib/FixMyStreet/Cobrand/TfL.pm @@ -313,12 +313,18 @@ sub must_have_2fa { sub update_email_shortlisted_user { my ($self, $update) = @_; my $c = $self->{c}; + my $cobrand = FixMyStreet::Cobrand::TfL->new; # $self may be FMS my $shortlisted_by = $update->problem->shortlisted_user; if ($shortlisted_by && $shortlisted_by->from_body && $shortlisted_by->from_body->name eq 'TfL' && $shortlisted_by->id ne $update->user_id) { $c->send_email('alert-update.txt', { + additional_template_paths => [ + FixMyStreet->path_to( 'templates', 'email', 'tfl' ), + FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com'), + ], to => [ [ $shortlisted_by->email, $shortlisted_by->name ] ], report => $update->problem, - problem_url => $c->cobrand->base_url_for_report($update->problem) . $update->problem->url, + cobrand => $cobrand, + problem_url => $cobrand->base_url . $update->problem->url, data => [ { item_photo => $update->photo, item_text => $update->text, @@ -434,10 +440,10 @@ sub report_new_is_on_tlrn { return scalar @$features ? 1 : 0; } -sub munge_report_new_category_list { } +sub munge_report_new_contacts { } sub munge_red_route_categories { - my ($self, $options, $contacts) = @_; + my ($self, $contacts) = @_; if ( $self->report_new_is_on_tlrn ) { # We're on a red route - only send TfL categories (except the disabled # one that directs the user to borough for street cleaning) and borough @@ -455,8 +461,6 @@ sub munge_red_route_categories { $tlrn_cats{$self->_tfl_council_category} = 1; @$contacts = grep { !( $_->body->name eq 'TfL' && $tlrn_cats{$_->category } ) } @$contacts; } - my $seen = { map { $_->category => 1 } @$contacts }; - @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; } # Reports in these categories can only be made on a red route @@ -489,6 +493,7 @@ sub _tlrn_categories { [ "Scaffolding blocking carriageway or footway", "Single Light out (street light)", "Standing water", + "Street Light - Equipment damaged, pole leaning", "Unstable hoardings", "Unstable scaffolding", "Worn out road markings", diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 97c8b6c81..7336e60ca 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -289,14 +289,14 @@ sub prefill_report_fields_for_inspector { 1 } sub social_auth_disabled { 1 } -sub munge_report_new_category_list { - my ($self, $options, $contacts, $extras) = @_; +sub munge_report_new_contacts { + my ($self, $contacts) = @_; my %bodies = map { $_->body->name => $_->body } @$contacts; if ( $bodies{'TfL'} ) { # Presented categories vary if we're on/off a red route my $tfl = FixMyStreet::Cobrand->get_class_for_moniker( 'tfl' )->new({ c => $self->{c} }); - $tfl->munge_red_route_categories($options, $contacts); + $tfl->munge_red_route_categories($contacts); } } diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 5c8ae4e28..5bb975104 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -68,7 +68,7 @@ sub uniquify_email { my ($self, $email, $file) = @_; $file = (caller)[1] unless $file; - (my $pkg = $file) =~ s{/}{}g; + (my $pkg = $file) =~ s{[/\.]}{}g; if ($email =~ /@/ && $email !~ /^pkg-/) { $email = "pkg-$pkg-$email"; diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index cd441856a..7dafb7af5 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -55,6 +55,7 @@ my @PLACES = ( [ 'PE1 1HF', 52.57146, -0.24201, 2566, 'Peterborough City Council', 'UTA' ], [ 'OX28 4DS', 51.784721, -1.494453 ], [ 'E14 2DN', 51.508536, '0.000001' ], + [ '?', 52.51093, -1.86514, 11809, 'West Midlands', 'EUR' ], # Norway [ '3290', 59, 10, 709, 'Larvik', 'NKO', 7, 'Vestfold', 'NFY' ], [ '0045', "59.9", "10.9", 301, 'Oslo', 'NKO', 3, 'Oslo', 'NFY' ], diff --git a/t/Mock/OpenIDConnect.pm b/t/Mock/OpenIDConnect.pm index 1a1428758..ba7d03b1d 100644 --- a/t/Mock/OpenIDConnect.pm +++ b/t/Mock/OpenIDConnect.pm @@ -55,7 +55,7 @@ sub dispatch_request { extension_CrmContactId => "1c304134-ef12-c128-9212-123908123901", nonce => 'MyAwesomeRandomValue', }; - $payload->{emails} = ['pkg-tappcontrollerauth_social.t-oidc@example.org'] if $self->returns_email; + $payload->{emails} = ['pkg-tappcontrollerauth_socialt-oidc@example.org'] if $self->returns_email; my $signature = "dummy"; my $id_token = join(".", ( encode_base64($self->json->encode($header), ''), diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t index 61d851422..24185993b 100644 --- a/t/cobrand/tfl.t +++ b/t/cobrand/tfl.t @@ -592,15 +592,24 @@ subtest 'TfL admin allows inspectors to be assigned to borough areas' => sub { $staffuser->update({ area_ids => undef}); # so login below doesn't break }; -subtest 'Leave an update on a shortlisted report, get an email' => sub { - my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'}); - $staffuser->add_to_planned_reports($report); - $mech->log_in_ok( $user->email ); - $mech->get_ok('/report/' . $report->id); - $mech->submit_form_ok({ with_fields => { update => 'This is an update' }}); - my $email = $mech->get_text_body_from_email; - like $email, qr/This is an update/; -}; +my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'}); +$report->update({ cobrand => 'fixmystreet' }); +$staffuser->add_to_planned_reports($report); + +for my $host ( 'www.fixmystreet.com', 'tfl.fixmystreet.com' ) { + subtest "Leave an update on a shortlisted report on $host, get an email" => sub { + $mech->host($host); + $mech->log_in_ok( $user->email ); + $mech->get_ok('/report/' . $report->id); + $mech->submit_form_ok({ with_fields => { update => 'This is an update' }}); + my $email = $mech->get_email; + my $text = $mech->get_text_body_from_email; + like $text, qr/This is an update/, 'Right email'; + like $text, qr/street.tfl/, 'Right url'; + like $text, qr/Street Care/, 'Right name'; + like $email->as_string, qr/iEYI87gX6Upb\+tKYzrSmN83pTnv606AOtahHTepSm/, 'Right logo'; + }; +} subtest 'TfL staff can access TfL admin' => sub { $mech->log_in_ok( $staffuser->email ); diff --git a/templates/email/tfl/signature.txt b/templates/email/tfl/signature.txt new file mode 100644 index 000000000..ef8d7d667 --- /dev/null +++ b/templates/email/tfl/signature.txt @@ -0,0 +1 @@ +Street Care diff --git a/templates/web/base/report/new/category.html b/templates/web/base/report/new/category.html index 961954f33..b5bfd0251 100644 --- a/templates/web/base/report/new/category.html +++ b/templates/web/base/report/new/category.html @@ -1,3 +1,4 @@ +[% TRY %][% PROCESS 'report/new/_form_labels.html' %][% CATCH file %][% END ~%] [% # If only one option, pre-select that as if it were already selected. This # carries through to the category_extras template because this template is @@ -19,7 +20,7 @@ END category_lc = category | lower; END; ~%] <label for='form_category' id="form_category_label"> - [%~ loc('Category') ~%] + [%~ form_category_label OR loc('Category') ~%] </label>[% =%] <select required class="validCategory form-control[% IF category_groups.size %] js-grouped-select[% END %]" name="category" id="form_category" [%~ IF c.user.from_body =%] diff --git a/templates/web/base/report/new/category_wrapper.html b/templates/web/base/report/new/category_wrapper.html index 15616221c..a5e0e3556 100644 --- a/templates/web/base/report/new/category_wrapper.html +++ b/templates/web/base/report/new/category_wrapper.html @@ -1,6 +1,6 @@ <div id="form_category_row"> [% IF js %] - <label for="form_category">[% loc('Category') %]</label> + <label for="form_category">[% form_category_label OR loc('Category') %]</label> <select class="validCategory form-control" name="category" id="form_category" [%~ IF c.user.from_body =%] [%~ prefill_report = c.cobrand.prefill_report_fields_for_inspector || c.user.has_body_permission_to('report_prefill') %] diff --git a/templates/web/base/report/new/form_report.html b/templates/web/base/report/new/form_report.html index d6112703c..3b28d4aa7 100644 --- a/templates/web/base/report/new/form_report.html +++ b/templates/web/base/report/new/form_report.html @@ -1,4 +1,5 @@ [% SET form_show_category_only = NOT category || field_errors.category || disable_form_message || have_disable_qn_to_answer %] +[% TRY %][% PROCESS 'report/new/_form_labels.html' %][% CATCH file %][% END %] <!-- report/new/form_report.html --> [% INCLUDE 'report/new/form_after_heading.html' %] @@ -25,7 +26,6 @@ [% END %] <div class="js-hide-if-invalid-category[% ' hidden-nojs' IF form_show_category_only %]"> -[% TRY %][% PROCESS 'report/new/_form_labels.html' %][% CATCH file %][% END %] [% UNLESS public_councils_text_at_top %] [% INCLUDE public_councils_text %] diff --git a/templates/web/base/reports/_list-filters-sort.html b/templates/web/base/reports/_list-filters-sort.html new file mode 100644 index 000000000..c5911e716 --- /dev/null +++ b/templates/web/base/reports/_list-filters-sort.html @@ -0,0 +1,14 @@ +<p class="report-list-filters"> + <label for="sort">[% loc('Sort by') %]</label> + <select class="form-control" name="sort" id="sort"> + [% IF shortlist %] + <option value="shortlist"[% ' selected' IF sort_key == 'shortlist' %]>[% loc('Manual order') %]</option> + [% END %] + <option value="created-desc"[% ' selected' IF sort_key == 'created-desc' %]>[% loc('Newest') %]</option> + <option value="created-asc"[% ' selected' IF sort_key == 'created-asc' %]>[% loc('Oldest') %]</option> + <option value="updated-desc"[% ' selected' IF sort_key == 'updated-desc' %]>[% loc('Recently updated') %]</option> + <option value="updated-asc"[% ' selected' IF sort_key == 'updated-asc' %]>[% loc('Least recently updated') %]</option> + <option value="comments-desc"[% ' selected' IF sort_key == 'comments-desc' %]>[% loc('Most commented') %]</option> + </select> + <input type="submit" name="filter_update" value="[% loc('Go') %]"> +</p> diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html index 08132cef7..0cd477d1f 100644 --- a/templates/web/base/reports/_list-filters.html +++ b/templates/web/base/reports/_list-filters.html @@ -27,20 +27,8 @@ <input type="submit" name="filter_update" value="[% loc('Go') %]"> </p> - <p class="report-list-filters"> - <label for="sort">[% loc('Sort by') %]</label> - <select class="form-control" name="sort" id="sort"> - [% IF shortlist %] - <option value="shortlist"[% ' selected' IF sort_key == 'shortlist' %]>[% loc('Manual order') %]</option> - [% END %] - <option value="created-desc"[% ' selected' IF sort_key == 'created-desc' %]>[% loc('Newest') %]</option> - <option value="created-asc"[% ' selected' IF sort_key == 'created-asc' %]>[% loc('Oldest') %]</option> - <option value="updated-desc"[% ' selected' IF sort_key == 'updated-desc' %]>[% loc('Recently updated') %]</option> - <option value="updated-asc"[% ' selected' IF sort_key == 'updated-asc' %]>[% loc('Least recently updated') %]</option> - <option value="comments-desc"[% ' selected' IF sort_key == 'comments-desc' %]>[% loc('Most commented') %]</option> - </select> - <input type="submit" name="filter_update" value="[% loc('Go') %]"> - </p> + [% PROCESS 'reports/_list-filters-sort.html' %] + [% IF page == 'around' %] <p id="show_old_reports_wrapper" class="report-list-filters[% ' hidden' UNLESS num_old_reports > 0 %]"> <label for="show_old_reports">[% loc('Show older reports') %]</label> diff --git a/web/cobrands/fixmystreet/density-map.js b/web/cobrands/fixmystreet/density-map.js index 9febf66d7..601e6cdca 100644 --- a/web/cobrands/fixmystreet/density-map.js +++ b/web/cobrands/fixmystreet/density-map.js @@ -55,9 +55,11 @@ $(function(){ $('#heatmap_yes').on('click', function() { fixmystreet.markers.setVisibility(false); heat_layer.setVisibility(true); + $(fixmystreet.map.div).addClass("heatmap-active"); }); $('#heatmap_no').on('click', function() { + $(fixmystreet.map.div).removeClass("heatmap-active"); heat_layer.setVisibility(false); fixmystreet.markers.setVisibility(true); }); @@ -65,6 +67,7 @@ $(function(){ if (heatmap_on) { fixmystreet.markers.setVisibility(false); heat_layer.setVisibility(true); + $(fixmystreet.map.div).addClass("heatmap-active"); } $('#sort').closest('.report-list-filters').hide(); diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index ced554249..6f1aba817 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -1683,6 +1683,12 @@ input.final-submit { height: 100%; // Needs to be position:absolute for the mobile banners to show on top position: absolute; + + &.heatmap-active { + .olLayerGrid, .olBackBuffer { + filter: grayscale(0.75); + } + } } } diff --git a/web/cobrands/tfl/assets.js b/web/cobrands/tfl/assets.js index 15a0f4933..ccfaad321 100644 --- a/web/cobrands/tfl/assets.js +++ b/web/cobrands/tfl/assets.js @@ -72,6 +72,7 @@ var tlrn_categories = [ "Scaffolding blocking carriageway or footway", "Single Light out (street light)", "Standing water", + "Street Light - Equipment damaged, pole leaning", "Unstable hoardings", "Unstable scaffolding", "Worn out road markings" |