diff options
18 files changed, 56 insertions, 97 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 70edcabe3..e75bb05ab 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -106,6 +106,7 @@ sub submit_creator_fixed : Private { } my $problem = $c->cobrand->problems->find( { id => $c->stash->{problem_id} } ); + $c->stash->{problem} = $problem; # you should not be able to answer questionnaires about problems # that you've not submitted diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index e188a085d..817e2a631 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -168,9 +168,6 @@ sub format_problem_for_display : Private { } $c->stash->{extra_name_info} = $problem->bodies_str && $problem->bodies_str eq '2482' ? 1 : 0; - if ( $c->sessionid && $c->flash->{created_report} ) { - $c->stash->{created_report} = $c->flash->{created_report}; - } $c->forward('generate_map_tags'); diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index ebc5cc6a0..5021d90e0 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -1132,23 +1132,10 @@ sub redirect_or_confirm_creation : Private { if ( $report->confirmed ) { # Subscribe problem reporter to email updates $c->forward( 'create_reporter_alert' ); - my $report_uri; - - if ( $c->cobrand->moniker eq 'fixmybarangay' && $c->user->from_body && $c->stash->{external_source_id}) { - $report_uri = $c->uri_for( '/report', $report->id, undef, { external_source_id => $c->stash->{external_source_id} } ); - } elsif ( $c->cobrand->never_confirm_reports && $report->non_public ) { - $c->log->info( 'cobrand was set to always confirm reports and report was non public, success page showed'); - $c->stash->{template} = 'report_created.html'; - return 1; - } else { - $report_uri = $c->cobrand->base_url_for_report( $report ) . $report->url; - } - $c->log->info($report->user->id . ' was logged in, redirecting to /report/' . $report->id); - if ( $c->sessionid ) { - $c->flash->{created_report} = 'loggedin'; - } - $c->res->redirect($report_uri); - $c->detach; + $c->log->info($report->user->id . ' was logged in, showing confirmation page for ' . $report->id); + $c->stash->{created_report} = 'loggedin'; + $c->stash->{template} = 'tokens/confirm_problem.html'; + return 1; } # otherwise create a confirm token and email it to them. diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index b97420238..f1a1aa821 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -376,11 +376,8 @@ sub redirect_or_confirm_creation : Private { if ( $update->confirmed ) { $c->forward( 'update_problem' ); $c->forward( 'signup_for_alerts' ); - - my $report_uri = $c->cobrand->base_url_for_report( $update->problem ) . $update->problem->url; - $c->flash->{comment_created} = 1; - $c->res->redirect($report_uri); - $c->detach; + $c->stash->{template} = 'tokens/confirm_update.html'; + return 1; } # otherwise create a confirm token and email it to them. diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 44cb2429d..00ac63599 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -37,7 +37,7 @@ sub confirm_problem : Path('/P') { # Look at all problems, not just cobrand, in case am approving something we don't actually show my $problem = $c->model('DB::Problem')->find( { id => $problem_id } ) || $c->detach('token_error'); - $c->stash->{problem} = $problem; + $c->stash->{report} = $problem; if ( $problem->state eq 'unconfirmed' && $auth_token->created < DateTime->now->subtract( months => 1 ) ) { $c->stash->{template} = 'errors/generic.html'; @@ -83,7 +83,6 @@ sub confirm_problem : Path('/P') { ) if $problem->state eq 'unconfirmed'; # Subscribe problem reporter to email updates - $c->stash->{report} = $c->stash->{problem}; $c->forward( '/report/new/create_reporter_alert' ); # log the problem creation user in to the site diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 67e899102..49ff7b69e 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -750,8 +750,7 @@ subtest "test report creation for a user who is signing in as they report" => su my $report = $user->problems->first; ok $report, "Found the report"; - # check that we got redirected to /report/ - is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; + $mech->content_contains('Thank you for reporting this issue'); # Check the report has been assigned appropriately is $report->bodies_str, $body_ids{2651}; @@ -852,8 +851,7 @@ foreach my $test ( # Check the report has been assigned appropriately is $report->bodies_str, $body_ids{$test->{council}}; - # check that we got redirected to /report/ - is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; + $mech->content_contains('Thank you for reporting this issue'); # check that no emails have been sent $mech->email_count_is(0); @@ -1227,18 +1225,18 @@ subtest "test Hart" => sub { button => 'submit_register', }, { - desc => 'confirm redirect for cobrand council in two tier cobrand redirects to cobrand site', + desc => 'confirmation page for cobrand council in two tier cobrand links to cobrand site', category => 'Trees', council => 2333, national => 0, - redirect => 1, + confirm => 1, }, { - desc => 'confirm redirect for non cobrand council in two tier cobrand redirect to national site', + desc => 'confirmation page for non cobrand council in two tier cobrand links to national site', category => 'Street Lighting', council => 2227, national => 1, - redirect => 1, + confirm => 1, }, ) { subtest $test->{ desc } => sub { @@ -1247,7 +1245,7 @@ subtest "test Hart" => sub { $mech->clear_emails_ok; $mech->log_out_ok; - my $user = $mech->log_in_ok($test_email) if $test->{redirect}; + my $user = $mech->log_in_ok($test_email) if $test->{confirm}; FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'hart', 'fixmystreet' ], @@ -1258,13 +1256,13 @@ subtest "test Hart" => sub { $mech->content_contains( "Hart Council" ); $mech->submit_form_ok( { with_fields => { pc => 'GU51 4AE' } }, "submit location" ); $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); - my %optional_fields = $test->{redirect} ? () : + my %optional_fields = $test->{confirm} ? () : ( email => $test_email, phone => '07903 123 456' ); # we do this as otherwise test::www::mechanize::catalyst # goes to the value set in ->host above irregardless and # that is a 404. It works but it is not pleasant. - $mech->clear_host if $test->{redirect} && $test->{national}; + $mech->clear_host if $test->{confirm} && $test->{national}; $mech->submit_form_ok( { button => $test->{button}, @@ -1295,11 +1293,11 @@ subtest "test Hart" => sub { # Check the report has been assigned appropriately is $report->bodies_str, $body_ids{$test->{council}}; - if ( $test->{redirect} ) { - is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; + if ( $test->{confirm} ) { + is $mech->uri->path, "/report/new"; my $base = 'www.fixmystreet.com'; $base = "hart.fixmystreet.com" unless $test->{national}; - is $mech->uri->host, $base, 'redirected to correct site'; + $mech->content_contains("$base/report/" . $report->id, "links to correct site"); } else { # receive token my $email = $mech->get_email; @@ -1454,12 +1452,8 @@ subtest "test SeeSomething" => sub { ok $report->confirmed, 'Report is confirmed automatically'; - if ( $test->{public} ) { - is $mech->uri->path, '/report/' . $report->id, 'redirects to report page'; - } else { - is $mech->uri->path, '/report/new', 'stays on report/new page'; - $mech->content_contains( 'Your report has been sent', 'use report created template' ); - } + is $mech->uri->path, '/report/new', 'stays on report/new page'; + $mech->content_contains( 'Your report has been sent', 'use report created template' ); $user->alerts->delete; $user->problems->delete; @@ -1537,9 +1531,6 @@ subtest "extra google analytics code displayed on logged in problem creation" => my $report = $user->problems->first; ok $report, "Found the report"; - # check that we got redirected to /report/ - is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; - $mech->content_contains( "'id': 'report/" . $report->id . "'", 'extra google code present' ); # cleanup diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 832e6cb82..58d9eff86 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -457,6 +457,8 @@ for my $test ( }, 'submit update' ); + $mech->content_contains("/report/$report_id"); + $mech->get_ok("/report/$report_id"); $mech->content_contains('Test 2'); $mech->content_contains('Update no email confirm'); @@ -690,6 +692,7 @@ for my $test ( }, 'submit update' ); + $mech->get_ok("/report/$report_id"); $report->discard_changes; my $update = $report->comments->first; @@ -816,6 +819,7 @@ subtest "check comment with no status change has not status in meta" => sub { }, 'submit update' ); + $mech->get_ok("/report/$report_id"); $report->discard_changes; @updates = $report->comments->search(undef, { order_by => 'created' })->all;; @@ -971,7 +975,7 @@ for my $test ( "submit good details" ); - is $mech->uri->path, "/report/" . $report_id, "redirected to report page"; + $mech->content_contains('Thank you for updating this issue'); $mech->email_count_is(0); my $update = $report->comments->first; @@ -1201,7 +1205,9 @@ for my $test ( 'submit update' ); - is $mech->uri->path, "/report/" . $report_id, "redirected to report page"; + $mech->content_contains('Thank you for updating this issue'); + $mech->content_contains("/report/" . $report_id); + $mech->get_ok("/report/" . $report_id); if ( !defined( $test->{endstate_banner} ) ) { is $mech->extract_problem_banner->{text}, undef, 'endstate banner'; @@ -1255,7 +1261,6 @@ foreach my $test ( alert => 1, # we signed up for alerts before, do not unsign us anonymous => 0, answered => 0, - path => '/report/update', content => "Thanks, glad to hear it's been fixed! Could we just ask if you have ever reported a problem to a council before?", }, @@ -1282,7 +1287,6 @@ foreach my $test ( alert => 1, # we signed up for alerts before, do not unsign us anonymous => 0, answered => 0, - path => '/report/update', content => "Thanks, glad to hear it's been fixed! Could we just ask if you have ever reported a problem to a council before?", }, @@ -1310,7 +1314,6 @@ foreach my $test ( alert => 1, # we signed up for alerts before, do not unsign us anonymous => 0, answered => 1, - path => '/report/' . $report->id, content => $report->title, }, ) @@ -1363,7 +1366,7 @@ foreach my $test ( $mech->submit_form_ok( { with_fields => $test->{fields}, }, 'submit update' ); - is $mech->uri->path, $test->{path}, "page after submission"; + is $mech->uri->path, '/report/update', "page after submission"; $mech->content_contains( $test->{content} ); @@ -1393,6 +1396,7 @@ foreach my $test ( $mech->submit_form_ok( { with_fields => { reported => 'Yes' } } ); + $mech->content_contains( $report->title ); $mech->content_contains( 'Thank you for updating this issue' ); $questionnaire = FixMyStreet::App->model( 'DB::Questionnaire' )->find( @@ -1542,6 +1546,7 @@ for my $test ( $mech->submit_form_ok( { with_fields => { reported => 'Yes' } } ); + $mech->content_contains( $report->title ); $mech->content_contains( 'Thank you for updating this issue' ); $questionnaire = FixMyStreet::App->model( 'DB::Questionnaire' )->find( diff --git a/templates/web/base/report_created.html b/templates/web/base/report_created.html deleted file mode 100644 index 81083654b..000000000 --- a/templates/web/base/report_created.html +++ /dev/null @@ -1,9 +0,0 @@ -[% INCLUDE 'header.html', title => loc('Report created') %] - -<h1>[% loc("Report created") %]</h1> - -<p> -[% loc('Your report has been created and will shortly be sent.') %] -</p> - -[% INCLUDE 'footer.html' %] diff --git a/templates/web/base/tokens/confirm_problem.html b/templates/web/base/tokens/confirm_problem.html index 524339cf6..5892d0f9e 100644 --- a/templates/web/base/tokens/confirm_problem.html +++ b/templates/web/base/tokens/confirm_problem.html @@ -2,15 +2,15 @@ <div class="confirmation-header"> - <h1><a href="[% c.cobrand.base_url_for_report( problem ) %][% problem.url %]">[% problem.title %]</a></h1> + <h1><a href="[% c.cobrand.base_url_for_report( report ) %][% report.url %]">[% report.title %]</a></h1> [% IF c.cobrand.is_council %] <h2>Your issue is on its way to the council.</h2> - <p>Your reference for this problem is [% problem.id %], please quote it in any enquiries.</p> + <p>Your reference for this report is [% report.id %], please quote it in any enquiries.</p> [% ELSE %] <h2>[% loc('Thank you for reporting this issue!') %]</h2> - [% IF problem.bodies_str %] + [% IF report.bodies_str %] <p>[% loc('It’s on its way to the council right now.') %]</p> [% END %] @@ -23,7 +23,7 @@ [% INCLUDE next_steps.html, just_interacted = 1, - share_url = c.cobrand.base_url_for_report(problem) _ problem.url, + share_url = c.cobrand.base_url_for_report(report) _ report.url, twitter_comment = loc('I just reported a problem on @fixmystreet') %] diff --git a/templates/web/base/tokens/confirm_update.html b/templates/web/base/tokens/confirm_update.html index a230894ef..01ac992ab 100644 --- a/templates/web/base/tokens/confirm_update.html +++ b/templates/web/base/tokens/confirm_update.html @@ -1,14 +1,16 @@ -[% INCLUDE 'header.html', bodyclass = 'fullwidthpage', title => loc('Confirmation') %] +[% INCLUDE 'header.html', bodyclass = 'fullwidthpage', title = loc('Confirmation'); -[% IF creator_fixed %] - [% problem_url = c.uri_for('/report', problem_id) %] -[% ELSE %] - [% problem_url = c.uri_for( '/report', update.problem.id ) _ '#update_' _ update.id %] -[% END %] +DEFAULT problem = update.problem; +SET problem_url = c.uri_for('/report', problem.id); +IF update; + problem_url = problem_url _ '#update_' _ update.id; +END; + +%] <div class="confirmation-header"> - <h1><a href="[% problem_url %]">[% update.problem.title %]</a></h1> + <h1><a href="[% problem_url %]">[% problem.title %]</a></h1> <h2>[% loc('Thank you for updating this issue!') %]</h2> @@ -17,7 +19,7 @@ [% INCLUDE next_steps.html, just_interacted = 1, - share_url = c.cobrand.base_url_for_report(update.problem) _ update.problem.url, + share_url = c.cobrand.base_url_for_report(problem) _ problem.url, twitter_comment = loc('I just updated a problem on @fixmystreet') %] diff --git a/templates/web/emptyhomes/tokens/confirm_problem.html b/templates/web/emptyhomes/tokens/confirm_problem.html index 5e77ca59f..a8a025058 100644 --- a/templates/web/emptyhomes/tokens/confirm_problem.html +++ b/templates/web/emptyhomes/tokens/confirm_problem.html @@ -2,7 +2,7 @@ <h1>[% loc('Confirmation') %]</h1> -[% IF problem.bodies_str %] +[% IF report.bodies_str %] <p>[% loc( 'Thank you for reporting an empty property on ReportEmptyHomes.com. We have emailed the lead officer for empty homes in the council responsible with details, and asked them to do whatever they can to get the empty property back into use as soon as possible.' @@ -36,7 +36,7 @@ as possible will be covered.') [% END %] <p> - <a href="[% c.uri_for( '/report', problem.id ) | html %]">[% loc('View your report') %]</a>. + <a href="[% c.uri_for( '/report', report.id ) | html %]">[% loc('View your report') %]</a>. </p> [% INCLUDE 'footer.html' %] diff --git a/templates/web/fixmystreet.com/report/_extras_top.html b/templates/web/fixmystreet.com/report/_extras_top.html deleted file mode 100755 index 4938e8749..000000000 --- a/templates/web/fixmystreet.com/report/_extras_top.html +++ /dev/null @@ -1,3 +0,0 @@ -[% IF created_report %] - [% INCLUDE 'research/survey_link.html' %] -[% END %] diff --git a/templates/web/fixmystreet.com/tracking_code.html b/templates/web/fixmystreet.com/tracking_code.html index 23bd8d992..3b163f516 100644 --- a/templates/web/fixmystreet.com/tracking_code.html +++ b/templates/web/fixmystreet.com/tracking_code.html @@ -20,7 +20,7 @@ ga(function(tracker) { tracker.set('location', page + extra); }); ga('ecommerce:addItem', { - 'id': 'report/[% problem.id %]', + 'id': 'report/[% report.id %]', 'quantity': '1', 'name': 'Report' }); diff --git a/templates/web/fixmystreet/report/display.html b/templates/web/fixmystreet/report/display.html index 314b09b28..91762e022 100644 --- a/templates/web/fixmystreet/report/display.html +++ b/templates/web/fixmystreet/report/display.html @@ -17,8 +17,6 @@ <p class='form-success'>[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]</p> [% END %] -[% TRY %][% INCLUDE 'report/_extras_top.html' %][% CATCH file %][% END %] - [% INCLUDE 'report/banner.html' %] [% INCLUDE 'report/_main.html' %] diff --git a/templates/web/hart/tokens/confirm_problem.html b/templates/web/hart/tokens/confirm_problem.html index d5b6075ff..68223e92b 100644 --- a/templates/web/hart/tokens/confirm_problem.html +++ b/templates/web/hart/tokens/confirm_problem.html @@ -4,16 +4,16 @@ <p class="confirmed"> Thank you. You have successfully confirmed your report -[% IF c.cobrand.owns_problem( problem ) %] +[% IF c.cobrand.owns_problem( report ) %] and this will now be investigated by the council. -You can <a href="[% c.cobrand.base_url_for_report( problem ) %][% problem.url %]">view the problem on this site</a>. +You can <a href="[% c.cobrand.base_url_for_report( report ) %][% report.url %]">view the report on this site</a>. [% ELSE %] and this has now been passed on to [%# TODO make this generic %] <b>Hampshire County Council</b> to investigate. -Note that Hart District Council is not responsible for this type of problem. However you can continue to view your problem on the <a href="[% c.cobrand.base_url_for_report( problem ) %][% problem.url %]"><i>fixmystreet.com</i> website</a>. +Note that Hart District Council is not responsible for this type of problem. However you can continue to view your report on the <a href="[% c.cobrand.base_url_for_report( report ) %][% report.url %]"><i>fixmystreet.com</i> website</a>. [% END %] </p> -<p>Your reference for this problem is [% problem.id %], please quote it in any enquiries. +<p>Your reference for this report is [% report.id %], please quote it in any enquiries. </p> [% INCLUDE 'footer.html' %] diff --git a/templates/web/seesomething/report_created.html b/templates/web/seesomething/tokens/confirm_problem.html index 4a11d14b4..4a11d14b4 100644 --- a/templates/web/seesomething/report_created.html +++ b/templates/web/seesomething/tokens/confirm_problem.html diff --git a/templates/web/zerotb/report/display.html b/templates/web/zerotb/report/display.html index 697b5428c..9848c89db 100644 --- a/templates/web/zerotb/report/display.html +++ b/templates/web/zerotb/report/display.html @@ -15,12 +15,6 @@ [% INCLUDE 'report/banner.html' %] -[% IF c.flash.comment_created %] -<p> -[% loc('Your report has been sent') %] -</p> -[% END %] - [% INCLUDE 'report/_main.html' %] <div class="shadow-wrap"> diff --git a/templates/web/zurich/tokens/confirm_problem.html b/templates/web/zurich/tokens/confirm_problem.html index d61cf3ffa..d2025f124 100644 --- a/templates/web/zurich/tokens/confirm_problem.html +++ b/templates/web/zurich/tokens/confirm_problem.html @@ -6,8 +6,8 @@ loc('You have successfully confirmed your email address.'); tprintf( loc( 'You can <a href="%s%s">view the problem on this site</a>.' ), - c.cobrand.base_url_for_report( problem ), - problem.url + c.cobrand.base_url_for_report( report ), + report.url ); %] </p> |