diff options
50 files changed, 311 insertions, 214 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ae1e0d1..c4f7bde7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Use category groups whenever category lists are shown. #2702 - Display map inline with duplicate suggestions on mobile. #2668 - Improved try again process on mobile. #2863 + - Improve messaging/display of private reports. - Admin improvements: - Add new roles system, to group permissions and apply to users. #2483 - Contact form emails now include user admin links. diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 7168e8379..72f96013a 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -160,7 +160,16 @@ sub load_problem_or_display_error : Private { $c->stash->{problem} = $problem; my $permissions = $c->stash->{_permissions} = $c->forward( 'check_has_permission_to', [ qw/report_inspect report_edit_category report_edit_priority report_mark_private / ] ); - if ( !$c->user || ($c->user->id != $problem->user->id && !($permissions->{report_inspect} || $permissions->{report_mark_private})) ) { + + # If someone has clicked a unique token link in an email to them + my $from_email = $c->sessionid && $c->flash->{alert_to_reporter} && $c->flash->{alert_to_reporter} == $problem->id; + + my $allowed = 0; + $allowed = 1 if $from_email; + $allowed = 1 if $c->user_exists && $c->user->id == $problem->user->id; + $allowed = 1 if $permissions->{report_inspect} || $permissions->{report_mark_private}; + + unless ($allowed) { my $url = '/auth?r=report/' . $problem->id; $c->detach( '/page_error_403_access_denied', diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 659d763de..c4e601a85 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -185,9 +185,7 @@ sub alert_to_reporter : Path('/R') { my $problem = $c->model('DB::Problem')->find( { id => $problem_id } ) || $c->detach('token_error'); - $c->detach('token_too_old') if $auth_token->created < DateTime->now->subtract( months => 1 ); - - $c->flash->{alert_to_reporter} = 1; + $c->flash->{alert_to_reporter} = $problem->id; my $report_uri = $c->cobrand->base_url_for_report( $problem ) . $problem->url; $c->res->redirect($report_uri); } diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index f10f1f7ec..b68c228b9 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -525,6 +525,31 @@ sub tokenised_url { return "/M/". $token->token; } +has view_token => ( + is => 'ro', + lazy => 1, + default => sub { + my $self = shift; + my $token = FixMyStreet::App->model('DB::Token')->create({ + scope => 'alert_to_reporter', + data => { id => $self->id } + }); + }, +); + +=head2 view_url + +Return a url for this problem report that will always show it +(even if e.g. a private report) but does not log the user in. + +=cut + +sub view_url { + my $self = shift; + return $self->url unless $self->non_public; + return "/R/" . $self->view_token->token; +} + =head2 is_hidden Returns 1 if the problem is in an hidden state otherwise 0. diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 48a827a63..4bd0fc991 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -73,38 +73,6 @@ subtest "change report to hidden and check for 410 status" => sub { ok $report->update( { state => 'confirmed' } ), 'confirm report again'; }; -subtest "change report to non_public and check for 403 status" => sub { - ok $report->update( { non_public => 1 } ), 'make report non public'; - ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; - is $mech->res->code, 403, "access denied"; - is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; - $mech->content_contains('permission to do that. If you are the problem reporter'); - $mech->content_lacks('Report another problem here'); - $mech->content_lacks($report->latitude); - $mech->content_lacks($report->longitude); - ok $report->update( { non_public => 0 } ), 'make report public'; -}; - -subtest "check owner of report can view non public reports" => sub { - ok $report->update( { non_public => 1 } ), 'make report non public'; - $mech->log_in_ok( $report->user->email ); - ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; - is $mech->res->code, 200, "report can be viewed"; - is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; - $mech->log_out_ok; - - $mech->log_in_ok( $user2->email ); - ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; - is $mech->res->code, 403, "access denied to user who is not report creator"; - is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; - $mech->content_contains('permission to do that. If you are the problem reporter'); - $mech->content_lacks('Report another problem here'); - $mech->content_lacks($report->latitude); - $mech->content_lacks($report->longitude); - $mech->log_out_ok; - ok $report->update( { non_public => 0 } ), 'make report public'; -}; - subtest "duplicate reports are signposted correctly" => sub { $report2->set_extra_metadata(duplicate_of => $report->id); $report2->state('duplicate'); diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index dcad10899..08435fb2b 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -360,6 +360,31 @@ subtest "Category extras includes description label for user" => sub { }; }; +subtest "Category extras are correct even if category has an ampersand in it" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + for ( + { url => '/report/new/ajax?' }, + { url => '/report/new/category_extras?category=Potholes+%26+Road+Defects' }, + ) { + my $category = "Potholes & Road Defects"; + $contact4->update({ category => $category }); + my $json = $mech->get_ok_json($_->{url} . '&latitude=55.952055&longitude=-3.189579'); + my $category_extra = $json->{by_category} ? $json->{by_category}{$category}{category_extra} : $json->{category_extra}; + contains_string($category_extra, "usrn") or diag $mech->content; + contains_string($category_extra, "central_asset_id"); + lacks_string($category_extra, "USRN", "Lacks 'USRN' label"); + lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label"); + contains_string($category_extra, "Size?"); + lacks_string($category_extra, '<option value=""'); + contains_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Contains description text"); + $contact4->update({ category => "Pothole" }); + } + }; +}; + subtest "Category extras includes form disabling string" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => 'fixmystreet', diff --git a/t/app/controller/report_non_public.t b/t/app/controller/report_non_public.t new file mode 100644 index 000000000..d1aa1943c --- /dev/null +++ b/t/app/controller/report_non_public.t @@ -0,0 +1,87 @@ +use FixMyStreet::TestMech; + +# disable info logs for this test run +FixMyStreet::App->log->disable('info'); +END { FixMyStreet::App->log->enable('info'); } + +my $mech = FixMyStreet::TestMech->new; + +my $body = $mech->create_body_ok(2237, 'Oxfordshire County Council'); +$mech->create_contact_ok( body_id => $body->id, category => 'Potholes', email => 'potholes@example.com' ); + +my $staffuser = $mech->create_user_ok('body-user@example.net', name => 'Body User', from_body => $body->id); +$staffuser->user_body_permissions->create({ body => $body, permission_type => 'contribute_as_another_user' }); +$staffuser->user_body_permissions->create({ body => $body, permission_type => 'report_mark_private' }); + +my $user = $mech->create_user_ok('test@example.com', name => 'Test User'); +my $user2 = $mech->create_user_ok('test2@example.com', name => 'Other User'); + +my ($report) = $mech->create_problems_for_body(1, $body->id, "Example", { + user => $user, + non_public => 1, +}); +my $report_id = $report->id; + +subtest "check cannot view non_public report by default" => sub { + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->res->code, 403, "access denied"; + is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; + $mech->content_contains('permission to do that. If you are the problem reporter'); + $mech->content_lacks('Report another problem here'); + $mech->content_lacks($report->latitude); + $mech->content_lacks($report->longitude); +}; + +subtest "check owner of report can view non public reports" => sub { + $mech->log_in_ok( $report->user->email ); + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->res->code, 200, "report can be viewed"; + is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; + $mech->log_out_ok; + + $mech->log_in_ok( $user2->email ); + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->res->code, 403, "access denied to user who is not report creator"; + is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; + $mech->content_contains('permission to do that. If you are the problem reporter'); + $mech->content_lacks('Report another problem here'); + $mech->content_lacks($report->latitude); + $mech->content_lacks($report->longitude); + $mech->log_out_ok; +}; + +subtest "Logged email working on private report" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->log_in_ok($staffuser->email); + $mech->get_ok('/report/new?latitude=51.7549262252&longitude=-1.25617899435'); + $mech->submit_form_ok({ + with_fields => { + form_as => 'another_user', + title => "Test Report", + detail => 'Test report details.', + category => 'Potholes', + name => 'Another User', + username => 'another@example.net', + non_public => 1, + } + }, "submit details"); + }; + $mech->content_contains('Thank you for reporting this issue'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + ok $report, "Found the report"; + is $report->state, 'confirmed', "report is now confirmed"; + is $report->non_public, 1; + + my $email = $mech->get_email; + my $body = $mech->get_text_body_from_email($email); + my $url = $mech->get_link_from_email($email); + like $body, qr/Your report to Oxfordshire County Council has been logged/; + $mech->get_ok($url); + $mech->content_lacks('Get updates'); + $mech->content_contains('To provide an update, please'); +}; + +done_testing(); diff --git a/templates/email/buckinghamshire/other-reported.html b/templates/email/buckinghamshire/other-reported.html index 4108f83b0..341df8120 100644 --- a/templates/email/buckinghamshire/other-reported.html +++ b/templates/email/buckinghamshire/other-reported.html @@ -12,11 +12,18 @@ INCLUDE '_email_top.html'; [% start_padded_box | safe %] <h1 style="[% h1_style %]">Your report has been logged</h1> <p style="[% p_style %]">Your report to [% report.body %] has been logged on [% site_name %].</p> + +[% IF report.non_public %] +<p style="[% p_style %]">It has been marked as private and will not be visible +to the general public; you may view it using the link below, or if you sign in +using the email address associated with the report.</p> +[% END %] + [% IF cobrand.owns_problem( report ) %] [% TRY %][% INCLUDE '_council_reference.html' problem=report %][% CATCH file %][% END %] [% END %] <p style="margin: 20px auto; text-align: center"> - <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.url %]">View my report</a> + <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.view_url %]">View my report</a> </p> [% end_padded_box | safe %] </th> diff --git a/templates/email/buckinghamshire/other-reported.txt b/templates/email/buckinghamshire/other-reported.txt index 1a042a60a..4d354d3ed 100644 --- a/templates/email/buckinghamshire/other-reported.txt +++ b/templates/email/buckinghamshire/other-reported.txt @@ -4,13 +4,20 @@ Hello [% report.name %], Your report to [% report.body %] has been logged on [% site_name %]. +[% IF report.non_public ~%] +It has been marked as private and will not be visible to the general public; +you may view it using the link below, or if you sign in using the email address +associated with the report. + +[% END ~%] + [% IF cobrand.owns_problem( report ) %] [% TRY %][% INCLUDE '_council_reference.txt' problem=report %][% CATCH file %][% END %] [% END %] It is available to view at: -[% cobrand.base_url_for_report(report) %][% report.url %] +[% cobrand.base_url_for_report(report) %][% report.view_url %] Your report is at the following location: diff --git a/templates/email/default/other-reported.html b/templates/email/default/other-reported.html index 07a36b6f3..c22bee231 100644 --- a/templates/email/default/other-reported.html +++ b/templates/email/default/other-reported.html @@ -12,14 +12,22 @@ INCLUDE '_email_top.html'; [% start_padded_box | safe %] <h1 style="[% h1_style %]">Your report has been logged</h1> <p style="[% p_style %]">Your report to [% report.body %] has been logged on [% site_name %].</p> + +[% IF report.non_public %] +<p style="[% p_style %]">It has been marked as private and will not be visible +to the general public; you may view it using the link below, or if you sign in +using the email address associated with the report.</p> +[% END %] + [% IF cobrand.is_council && !cobrand.owns_problem( report ) %] <p style="[% p_style %]">Please note that [% cobrand.council_name %] is not responsible for this type of report, so it will instead be sent to [% report.body %].</p> [% ELSE %] [% TRY %][% INCLUDE '_council_reference.html' problem=report %][% CATCH file %][% END %] [% END %] + <p style="margin: 20px auto; text-align: center"> - <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.url %]">View my report</a> + <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.view_url %]">View my report</a> </p> [% end_padded_box | safe %] </th> diff --git a/templates/email/default/other-reported.txt b/templates/email/default/other-reported.txt index 7b1230555..522a89b50 100644 --- a/templates/email/default/other-reported.txt +++ b/templates/email/default/other-reported.txt @@ -4,6 +4,13 @@ Hello [% report.name %], Your report to [% report.body %] has been logged on [% site_name %]. +[% IF report.non_public ~%] +It has been marked as private and will not be visible to the general public; +you may view it using the link below, or if you sign in using the email address +associated with the report. + +[% END ~%] + [% IF cobrand.is_council && !cobrand.owns_problem( report ) %] Please note that [% cobrand.council_name %] is not responsible for this type of report, so it will instead be sent to [% report.body %]. @@ -13,7 +20,7 @@ of report, so it will instead be sent to [% report.body %]. It is available to view at: -[% cobrand.base_url_for_report(report) %][% report.url %] +[% cobrand.base_url_for_report(report) %][% report.view_url %] Your report has the title: diff --git a/templates/email/fixamingata/other-reported.html b/templates/email/fixamingata/other-reported.html index c7e6b5c63..751da0cae 100644 --- a/templates/email/fixamingata/other-reported.html +++ b/templates/email/fixamingata/other-reported.html @@ -12,13 +12,20 @@ INCLUDE '_email_top.html'; [% start_padded_box | safe %] <h1 style="[% h1_style %]">Din rapport har loggats</h1> <p style="[% p_style %]">Din rapport till [% report.body %] har blivit loggad på [% site_name %]. + +[% IF report.non_public %] +<p style="[% p_style %]">It has been marked as private and will not be visible +to the general public; you may view it using the link below, or if you sign in +using the email address associated with the report.</p> +[% END %] + [% IF cobrand.is_council && !cobrand.owns_problem( report ) %] Eftersom [% cobrand.council_name %] inte är ansvarig för den här typen av rapporter, så kommer rapporten istället att skickas till [% report.body %]. [% END %] </p> <p style="margin: 20px auto; text-align: center"> - <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.url %]">Visa min rapport</a> + <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.view_url %]">Visa min rapport</a> </p> [% end_padded_box | safe %] </th> diff --git a/templates/email/fixamingata/other-reported.txt b/templates/email/fixamingata/other-reported.txt index e39adf527..e9ed542d3 100644 --- a/templates/email/fixamingata/other-reported.txt +++ b/templates/email/fixamingata/other-reported.txt @@ -4,6 +4,13 @@ Hej [% report.name %], Din rapport till [% report.body %] har blivit loggad på [% site_name %]. +[% IF report.non_public ~%] +It has been marked as private and will not be visible to the general public; +you may view it using the link below, or if you sign in using the email address +associated with the report. + +[% END ~%] + [% IF cobrand.is_council && !cobrand.owns_problem( report ) %] Eftersom [% cobrand.council_name %] inte är ansvarig för den här typen av rapporter, så kommer rapporten istället att skickas till [% report.body %]. @@ -11,7 +18,7 @@ rapporter, så kommer rapporten istället att skickas till [% report.body %]. Du kan se din rapport på: -[% cobrand.base_url_for_report(report) %][% report.url %] +[% cobrand.base_url_for_report(report) %][% report.view_url %] Din rapport har titeln: diff --git a/templates/email/hounslow/other-reported.html b/templates/email/hounslow/other-reported.html index a45f64a3e..b4b4faa99 100644 --- a/templates/email/hounslow/other-reported.html +++ b/templates/email/hounslow/other-reported.html @@ -12,6 +12,13 @@ INCLUDE '_email_top.html'; [% start_padded_box | safe %] <h1 style="[% h1_style %]">Your report has been logged</h1> <p style="[% p_style %]">Your report to [% cobrand.council_name %] has been logged on [% site_name %].</p> + +[% IF report.non_public %] +<p style="[% p_style %]">It has been marked as private and will not be visible +to the general public; you may view it using the link below, or if you sign in +using the email address associated with the report.</p> +[% END %] + [% IF cobrand.is_council && !cobrand.owns_problem( report ) %] <p style="[% p_style %]">Please note that [% cobrand.council_name %] is not responsible for this type of report, so it will instead be sent to [% report.body %].</p> @@ -19,7 +26,7 @@ of report, so it will instead be sent to [% report.body %].</p> [% TRY %][% INCLUDE '_council_reference.html' problem=report %][% CATCH file %][% END %] [% END %] <p style="margin: 20px auto; text-align: center"> - <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.url %]">View my report</a> + <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.view_url %]">View my report</a> </p> [% end_padded_box | safe %] </th> diff --git a/templates/email/hounslow/other-reported.txt b/templates/email/hounslow/other-reported.txt index b976c4edc..a3b7e37c8 100644 --- a/templates/email/hounslow/other-reported.txt +++ b/templates/email/hounslow/other-reported.txt @@ -4,6 +4,13 @@ Hello [% report.name %], Your report to [% cobrand.council_name %] has been logged on [% site_name %]. +[% IF report.non_public ~%] +It has been marked as private and will not be visible to the general public; +you may view it using the link below, or if you sign in using the email address +associated with the report. + +[% END ~%] + [% IF cobrand.is_council && !cobrand.owns_problem( report ) %] Please note that [% cobrand.council_name %] is not responsible for this type of report, so it will instead be sent to [% report.body %]. @@ -13,7 +20,7 @@ of report, so it will instead be sent to [% report.body %]. It is available to view at: -[% cobrand.base_url_for_report(report) %][% report.url %] +[% cobrand.base_url_for_report(report) %][% report.view_url %] Your report has the title: diff --git a/templates/email/tfl/other-reported.html b/templates/email/tfl/other-reported.html index f28f5a819..89e76b303 100644 --- a/templates/email/tfl/other-reported.html +++ b/templates/email/tfl/other-reported.html @@ -12,9 +12,16 @@ INCLUDE '_email_top.html'; [% start_padded_box | safe %] <h1 style="[% h1_style %]">Your report has been logged</h1> <p style="[% p_style %]">Your report to Transport for London has been logged on [% site_name %].</p> + +[% IF report.non_public %] +<p style="[% p_style %]">It has been marked as private and will not be visible +to the general public; you may view it using the link below, or if you sign in +using the email address associated with the report.</p> +[% END %] + [% TRY %][% INCLUDE '_council_reference.html' problem=report %][% CATCH file %][% END %] <p style="margin: 20px auto; text-align: center"> - <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.url %]">View my report</a> + <a style="[% button_style %]" href="[% cobrand.base_url_for_report(report) %][% report.view_url %]">View my report</a> </p> [% end_padded_box | safe %] </th> diff --git a/templates/email/tfl/other-reported.txt b/templates/email/tfl/other-reported.txt index 6c959493f..e70c4eb1c 100644 --- a/templates/email/tfl/other-reported.txt +++ b/templates/email/tfl/other-reported.txt @@ -4,11 +4,18 @@ Hello [% report.name %], Your report to Transport for London has been logged on [% site_name %]. +[% IF report.non_public ~%] +It has been marked as private and will not be visible to the general public; +you may view it using the link below, or if you sign in using the email address +associated with the report. + +[% END ~%] + [% TRY %][% INCLUDE '_council_reference.txt' problem=report %][% CATCH file %][% END %] It is available to view at: -[% cobrand.base_url_for_report(report) %][% report.url %] +[% cobrand.base_url_for_report(report) %][% report.view_url %] Your report has the title: diff --git a/templates/web/base/report/display_tools.html b/templates/web/base/report/display_tools.html index b65320394..e16ffcb2c 100644 --- a/templates/web/base/report/display_tools.html +++ b/templates/web/base/report/display_tools.html @@ -1,5 +1,6 @@ <div class="shadow-wrap"> <ul id="key-tools"> + [% IF c.user_exists OR NOT problem.non_public %] [% IF c.user_exists AND c.cobrand.users_can_hide AND c.user.belongs_to_body( problem.bodies_str ) %] <li><form method="post" action="/report/[% problem.id %]/delete" id="remove-from-site-form"> <input type="hidden" name="token" value="[% csrf_token %]"> @@ -16,6 +17,7 @@ [% IF c.cobrand.moniker == 'fixmystreet' %] <li><a rel="nofollow" id="key-tool-report-share" class="share" href="#report-share">[% loc('Share') %]</a></li> [% END %] + [% END %] [% IF c.cobrand.moniker == 'zurich' %] <li><a class="chevron" id="key-tool-problems-nearby" href="[% c.uri_for( '/around', { lat => latitude, lon => longitude } ) %]">[% loc( 'Problems on the map' ) %]</a></li> [% ELSE %] diff --git a/templates/web/base/report/new/category_extras.html b/templates/web/base/report/new/category_extras.html index 5cef391ce..9b4149119 100644 --- a/templates/web/base/report/new/category_extras.html +++ b/templates/web/base/report/new/category_extras.html @@ -1,5 +1,6 @@ [% SET default_list = [] %][% FOR b IN bodies_to_list.values %][% default_list.push(b.cobrand_name) %][% END %] [% DEFAULT list_of_names = default_list %] +[% category = mark_safe(category) %] <div id="category_meta"> [%- IF unresponsive.$category %] diff --git a/templates/web/base/report/new/councils_text.html b/templates/web/base/report/new/councils_text.html index 5f4b113ca..9b3d6fce7 100644 --- a/templates/web/base/report/new/councils_text.html +++ b/templates/web/base/report/new/councils_text.html @@ -1,4 +1,5 @@ [% FILTER collapse %] +[% category = mark_safe(category) %] [% IF unresponsive.$category OR unresponsive.ALL OR bodies_to_list.size == 0 %] [% tprintf( loc('These will be published online for others to see, in accordance with our <a href="%s">privacy policy</a>.'), diff --git a/templates/web/base/report/new/councils_text_all.html b/templates/web/base/report/new/councils_text_all.html index da512c980..08e27e8b3 100644 --- a/templates/web/base/report/new/councils_text_all.html +++ b/templates/web/base/report/new/councils_text_all.html @@ -1,5 +1,6 @@ [% SET default_list = [] %][% FOR b IN bodies_to_list.values %][% default_list.push(b.cobrand_name) %][% END %] [% DEFAULT list_of_names = default_list %] +[% category = mark_safe(category) %] <p> [% UNLESS non_public_categories.$category; diff --git a/templates/web/base/report/new/councils_text_private.html b/templates/web/base/report/new/councils_text_private.html index cab38c97e..80bcfed74 100644 --- a/templates/web/base/report/new/councils_text_private.html +++ b/templates/web/base/report/new/councils_text_private.html @@ -1,4 +1,5 @@ [% FILTER collapse %] +[% category = mark_safe(category) %] [% IF unresponsive.$category OR unresponsive.ALL OR bodies_to_list.size == 0 %] [% loc('These details will never be shown online without your permission.') %] [% ELSE %] diff --git a/templates/web/base/report/update-form-wrapper.html b/templates/web/base/report/update-form-wrapper.html index 5347df3c3..a46207a3c 100644 --- a/templates/web/base/report/update-form-wrapper.html +++ b/templates/web/base/report/update-form-wrapper.html @@ -1,4 +1,10 @@ [% UNLESS c.cobrand.updates_disallowed(problem) %] + + [% IF NOT c.user_exists AND problem.non_public # Came via other-reported token or similar %] + <p>[% tprintf(loc('To provide an update, please <a href="%s">sign in</a>.'), '/auth?r=report/' _ problem.id) %]</p> + + [% ELSE %] + [% IF two_column_sidebar %] <button type="button" class="btn btn--provide-update js-provide-update hidden-nojs">[% loc('Provide an update') %]</button> <div class="hidden-js"> @@ -7,6 +13,9 @@ [% IF two_column_sidebar %] </div> [% END %] + + [% END %] + [% ELSE %] [% TRY %][% INCLUDE 'report/_updates_disallowed_message.html' %][% CATCH file %][% END %] [% END %] diff --git a/templates/web/bathnes/footer_extra_js.html b/templates/web/bathnes/footer_extra_js.html index 5059d59f2..e46e103e8 100644 --- a/templates/web/bathnes/footer_extra_js.html +++ b/templates/web/bathnes/footer_extra_js.html @@ -1,13 +1,4 @@ -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/bathnes/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] [%~ 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); diff --git a/templates/web/bexley/footer_extra_js.html b/templates/web/bexley/footer_extra_js.html index db48a126c..7369f7147 100644 --- a/templates/web/bexley/footer_extra_js.html +++ b/templates/web/bexley/footer_extra_js.html @@ -1,14 +1 @@ -[% scripts.push( - version('/cobrands/fixmystreet-uk-councils/js.js'), -) %] -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/bexley/js.js'), - version('/cobrands/tfl/assets.js'), - version('/cobrands/highways/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 tfl=1 %] diff --git a/templates/web/bristol/footer_extra_js.html b/templates/web/bristol/footer_extra_js.html index deff4e395..3965c9d1e 100644 --- a/templates/web/bristol/footer_extra_js.html +++ b/templates/web/bristol/footer_extra_js.html @@ -1,13 +1 @@ -[% scripts.push( - version('/cobrands/fixmystreet-uk-councils/js.js'), -) %] -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/bristol/assets.js'), - version('/cobrands/highways/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 ~%] diff --git a/templates/web/bromley/footer_extra_js.html b/templates/web/bromley/footer_extra_js.html index a64ad1451..c3bad670c 100644 --- a/templates/web/bromley/footer_extra_js.html +++ b/templates/web/bromley/footer_extra_js.html @@ -2,13 +2,9 @@ version('/jslib/jquery-1.7.2.min.js'), version('/cobrands/bromley/a-z-nav.js'), ) %] +[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 validation=1 tfl=1 %] [% IF bodyclass.match('mappage'); scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), version('/cobrands/bromley/map.js'), - version('/cobrands/bromley/assets.js'), - version('/cobrands/tfl/assets.js'), ); END %] diff --git a/templates/web/buckinghamshire/footer_extra_js.html b/templates/web/buckinghamshire/footer_extra_js.html index 36be5e7dc..9132ead25 100644 --- a/templates/web/buckinghamshire/footer_extra_js.html +++ b/templates/web/buckinghamshire/footer_extra_js.html @@ -1,10 +1 @@ -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/buckinghamshire/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] diff --git a/templates/web/cheshireeast/footer_extra_js.html b/templates/web/cheshireeast/footer_extra_js.html index 9400b2938..9132ead25 100644 --- a/templates/web/cheshireeast/footer_extra_js.html +++ b/templates/web/cheshireeast/footer_extra_js.html @@ -1,10 +1 @@ -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/cheshireeast/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] diff --git a/templates/web/fixmystreet-uk-councils/footer_extra_js.html b/templates/web/fixmystreet-uk-councils/footer_extra_js.html index 76451344b..09f2bf87d 100644 --- a/templates/web/fixmystreet-uk-councils/footer_extra_js.html +++ b/templates/web/fixmystreet-uk-councils/footer_extra_js.html @@ -1,12 +1 @@ -[% scripts.push( - version('/cobrands/fixmystreet-uk-councils/js.js'), -) %] -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/highways/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 ~%] diff --git a/templates/web/fixmystreet-uk-councils/footer_extra_js_base.html b/templates/web/fixmystreet-uk-councils/footer_extra_js_base.html new file mode 100644 index 000000000..58e2872e3 --- /dev/null +++ b/templates/web/fixmystreet-uk-councils/footer_extra_js_base.html @@ -0,0 +1,29 @@ +[% +IF bodyclass.match('mappage'); + scripts.push( + version('/cobrands/fixmystreet-uk-councils/js.js'), + version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), + version('/cobrands/fixmystreet/assets.js'), + ); + IF validation; + scripts.push( + version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), + ); + END; + IF cobrand_js; + scripts.push( + version('/cobrands/' _ c.cobrand.moniker _ '/assets.js'), + ); + END; + IF highways; + scripts.push( + version('/cobrands/highways/assets.js'), + ); + END; + IF tfl; + scripts.push( + version('/cobrands/tfl/assets.js'), + ); + END; +END +~%] diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html index 2dbe8cc96..d2fe1e588 100644 --- a/templates/web/fixmystreet.com/footer_extra_js.html +++ b/templates/web/fixmystreet.com/footer_extra_js.html @@ -6,7 +6,7 @@ IF bodyclass.match('mappage'); scripts.push( version('/cobrands/fixmystreet/assets.js') ); scripts.push( version('/cobrands/fixmystreet-uk-councils/alloy.js') ); scripts.push( version('/cobrands/bathnes/assets.js') ); - scripts.push( version('/cobrands/bexley/js.js') ); + scripts.push( version('/cobrands/bexley/assets.js') ); scripts.push( version('/cobrands/bristol/assets.js') ); scripts.push( version('/cobrands/bromley/assets.js') ); scripts.push( version('/cobrands/buckinghamshire/assets.js') ); @@ -16,7 +16,7 @@ IF bodyclass.match('mappage'); scripts.push( version('/cobrands/northamptonshire/assets.js') ); scripts.push( version('/cobrands/hounslow/assets.js') ); scripts.push( version('/cobrands/westminster/assets.js') ); - scripts.push( version('/cobrands/peterborough/js.js') ); + scripts.push( version('/cobrands/peterborough/assets.js') ); scripts.push( version('/cobrands/tfl/assets.js') ); scripts.push( version('/cobrands/highways/assets.js') ); scripts.push( version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js') ); diff --git a/templates/web/greenwich/footer_extra_js.html b/templates/web/greenwich/footer_extra_js.html index 7b37893cf..8cbe4c48f 100644 --- a/templates/web/greenwich/footer_extra_js.html +++ b/templates/web/greenwich/footer_extra_js.html @@ -1,13 +1 @@ -[% scripts.push( - version('/cobrands/fixmystreet-uk-councils/js.js'), -) %] -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/highways/assets.js'), - version('/cobrands/tfl/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 tfl=1 %] diff --git a/templates/web/hounslow/footer_extra_js.html b/templates/web/hounslow/footer_extra_js.html index 58f7abd15..081ec3a12 100644 --- a/templates/web/hounslow/footer_extra_js.html +++ b/templates/web/hounslow/footer_extra_js.html @@ -1,13 +1,8 @@ +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 tfl=1 %] [% IF bodyclass.match('mappage'); scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/highways/assets.js'), version('/cobrands/hounslow/js.js'), - version('/cobrands/hounslow/assets.js'), - version('/cobrands/tfl/assets.js'), ); END %] diff --git a/templates/web/isleofwight/footer_extra_js.html b/templates/web/isleofwight/footer_extra_js.html index 563da86b6..a7cea7811 100644 --- a/templates/web/isleofwight/footer_extra_js.html +++ b/templates/web/isleofwight/footer_extra_js.html @@ -1,9 +1,6 @@ +[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 %] [% IF bodyclass.match('mappage'); scripts.push( - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/fixmystreet-uk-councils/js.js'), version('/cobrands/isleofwight/js.js'), - version('/cobrands/isleofwight/assets.js'), ); END %] diff --git a/templates/web/lincolnshire/footer_extra_js.html b/templates/web/lincolnshire/footer_extra_js.html index 0278798a4..9132ead25 100644 --- a/templates/web/lincolnshire/footer_extra_js.html +++ b/templates/web/lincolnshire/footer_extra_js.html @@ -1,10 +1 @@ -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/lincolnshire/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] diff --git a/templates/web/northamptonshire/footer_extra_js.html b/templates/web/northamptonshire/footer_extra_js.html index c17d2777e..fbd33dd11 100644 --- a/templates/web/northamptonshire/footer_extra_js.html +++ b/templates/web/northamptonshire/footer_extra_js.html @@ -1,11 +1,7 @@ [% IF bodyclass.match('mappage'); scripts.push( - version('/cobrands/fixmystreet/assets.js'), version('/cobrands/fixmystreet-uk-councils/alloy.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/northamptonshire/assets.js'), - version('/cobrands/highways/assets.js'), - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), ); END %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] diff --git a/templates/web/oxfordshire/footer_extra_js.html b/templates/web/oxfordshire/footer_extra_js.html index d3f1f03ee..88fc006e7 100644 --- a/templates/web/oxfordshire/footer_extra_js.html +++ b/templates/web/oxfordshire/footer_extra_js.html @@ -1,10 +1 @@ -[% -IF bodyclass.match('mappage'); - scripts.push( - version('/cobrands/fixmystreet/assets.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/highways/assets.js'), - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - ); -END; -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 validation=1 %] diff --git a/templates/web/oxfordshire/report/new/councils_text_all.html b/templates/web/oxfordshire/report/new/councils_text_all.html index 08852a772..38459b059 100644 --- a/templates/web/oxfordshire/report/new/councils_text_all.html +++ b/templates/web/oxfordshire/report/new/councils_text_all.html @@ -1,3 +1,4 @@ +[% category = mark_safe(category) %] <p> All the information you provide here will be sent to the [% # NB this empty class attribute is so fixmystreet.update_public_councils_text diff --git a/templates/web/peterborough/footer_extra_js.html b/templates/web/peterborough/footer_extra_js.html index 22cc42e60..9132ead25 100644 --- a/templates/web/peterborough/footer_extra_js.html +++ b/templates/web/peterborough/footer_extra_js.html @@ -1,14 +1 @@ -[% scripts.push( - version('/cobrands/fixmystreet-uk-councils/js.js'), -) %] -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/peterborough/js.js'), - version('/cobrands/highways/assets.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] diff --git a/templates/web/rutland/footer_extra_js.html b/templates/web/rutland/footer_extra_js.html index ba3b6ec02..88fc006e7 100644 --- a/templates/web/rutland/footer_extra_js.html +++ b/templates/web/rutland/footer_extra_js.html @@ -1,7 +1 @@ -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/cobrands/fixmystreet-uk-councils/council_validation_rules.js'), - ); -END -%] +[% PROCESS 'footer_extra_js_base.html' highways=1 validation=1 %] diff --git a/templates/web/tfl/footer_extra_js.html b/templates/web/tfl/footer_extra_js.html index e91a2a389..a8ccc80d0 100644 --- a/templates/web/tfl/footer_extra_js.html +++ b/templates/web/tfl/footer_extra_js.html @@ -1,15 +1,11 @@ [% scripts.push( version('/jslib/jquery-1.7.2.min.js'), - version('/cobrands/fixmystreet-uk-councils/js.js'), ) %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 %] [%~ IF bodyclass.match('mappage'); scripts.push( - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/highways/assets.js'), version('/cobrands/tfl/js.js'), - version('/cobrands/tfl/assets.js'), ); END %] diff --git a/templates/web/tfl/report/new/councils_text_all.html b/templates/web/tfl/report/new/councils_text_all.html index 22e130347..ae9fb3307 100644 --- a/templates/web/tfl/report/new/councils_text_all.html +++ b/templates/web/tfl/report/new/councils_text_all.html @@ -1,4 +1,5 @@ <p> +[% category = mark_safe(category) %] [% UNLESS non_public_categories.$category; tprintf( diff --git a/templates/web/westminster/footer_extra_js.html b/templates/web/westminster/footer_extra_js.html index 33fdb4dc2..f6e8c8bf9 100644 --- a/templates/web/westminster/footer_extra_js.html +++ b/templates/web/westminster/footer_extra_js.html @@ -1,11 +1 @@ -[%~ -IF bodyclass.match('mappage'); - scripts.push( - version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js'), - version('/cobrands/fixmystreet/assets.js'), - version('/cobrands/westminster/assets.js'), - version('/cobrands/tfl/assets.js'), - ); -END -%] - +[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 tfl=1 %] diff --git a/web/cobrands/bathnes/assets.js b/web/cobrands/bathnes/assets.js index f508ca97c..fb31749f2 100644 --- a/web/cobrands/bathnes/assets.js +++ b/web/cobrands/bathnes/assets.js @@ -207,15 +207,24 @@ fixmystreet.assets.add(fixmystreet.maps.banes_defaults, { all_categories: true, // Not really, but want to allow on all but one, not stop no_asset_msg_id: '#js-not-a-road', cat_map: { + 'Blocked drain surface': 'road', + 'Blocked drain': 'road', 'Damage to pavement': 'pavement', - 'Damage to road': 'road' + 'Damage to road': 'road', + 'Damaged Railing, manhole, or drain cover': 'road', + 'Damaged bollard or post': 'road', + 'Damaged road sign': 'road', + 'Damaged street nameplate': 'road', + 'Faded road markings': 'road', + 'Flooding of a road or pavement': 'road' }, actions: { found: fixmystreet.message_controller.road_found, not_found: function(layer) { var cat = $('select#form_category').val(); - if (cat === 'Damage to pavement' || cat === 'Damage to road') { - layer.fixmystreet.asset_item = layer.fixmystreet.cat_map[cat]; + var asset_item = layer.fixmystreet.cat_map[cat]; + if (asset_item) { + layer.fixmystreet.asset_item = asset_item; fixmystreet.message_controller.road_not_found(layer); } else { fixmystreet.message_controller.road_found(layer); diff --git a/web/cobrands/bexley/js.js b/web/cobrands/bexley/assets.js index a500ebbf3..a500ebbf3 100644 --- a/web/cobrands/bexley/js.js +++ b/web/cobrands/bexley/assets.js diff --git a/web/cobrands/fixmystreet-uk-councils/alloy.js b/web/cobrands/fixmystreet-uk-councils/alloy.js index 27e43a4dd..77494f975 100644 --- a/web/cobrands/fixmystreet-uk-councils/alloy.js +++ b/web/cobrands/fixmystreet-uk-councils/alloy.js @@ -122,7 +122,7 @@ OpenLayers.Strategy.Alloy = OpenLayers.Class(OpenLayers.Strategy.FixMyStreet, { }); -fixmystreet.assets.alloy_defaults = { +fixmystreet.alloy_defaults = { http_options: { base: "https://alloy-api-tile01.yotta.co.uk/api/render-layer/tile/${layerid}/${environment}/${layerVersion}/${z}/${x}/${y}", }, diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index cee8271e7..15ba18df4 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -453,7 +453,7 @@ $.extend(fixmystreet.set_up, { } if (data && data.non_public) { $(".js-hide-if-private-category").hide(); - $(".js-hide-if-public-category").show(); + $(".js-hide-if-public-category").removeClass("hidden-js").show(); } else { $(".js-hide-if-private-category").show(); $(".js-hide-if-public-category").hide(); diff --git a/web/cobrands/northamptonshire/assets.js b/web/cobrands/northamptonshire/assets.js index 67d75fb97..9f1e0750d 100644 --- a/web/cobrands/northamptonshire/assets.js +++ b/web/cobrands/northamptonshire/assets.js @@ -365,7 +365,7 @@ OpenLayers.Layer.NCCVectorAsset = OpenLayers.Class(OpenLayers.Layer.VectorAsset, // default options for northants assets include // a) checking for multiple assets in same location // b) preventing submission unless an asset is selected -var northants_defaults = $.extend(true, {}, fixmystreet.assets.alloy_defaults, { +var northants_defaults = $.extend(true, {}, fixmystreet.alloy_defaults, { class: OpenLayers.Layer.NCCVectorAsset, protocol_class: OpenLayers.Protocol.Alloy, http_options: { @@ -442,7 +442,7 @@ $.each(layers, function(index, layer) { // NCC roads layers which prevent report submission unless we have selected // an asset. -var northants_road_defaults = $.extend(true, {}, fixmystreet.assets.alloy_defaults, { +var northants_road_defaults = $.extend(true, {}, fixmystreet.alloy_defaults, { protocol_class: OpenLayers.Protocol.Alloy, http_options: { environment: is_live ? 26 : 28 diff --git a/web/cobrands/peterborough/js.js b/web/cobrands/peterborough/assets.js index 47172712d..47172712d 100644 --- a/web/cobrands/peterborough/js.js +++ b/web/cobrands/peterborough/assets.js |