diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 5 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 21 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 28 |
6 files changed, 47 insertions, 29 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index f48518d77..222c0c242 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -41,6 +41,11 @@ Handle contact us form submission sub submit : Path('submit') : Args(0) { my ( $self, $c ) = @_; + if (my $testing = $c->req->params->{_test_}) { + $c->stash->{success} = $c->req->params->{success}; + return; + } + $c->res->redirect( '/contact' ) and return unless $c->req->method eq 'POST'; return diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 70edcabe3..f6cc33e74 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -67,9 +67,16 @@ token), or the mini own-report one (when we'll have a problem ID). sub submit : Path('submit') { my ( $self, $c ) = @_; - if ( $c->req->params->{token} ) { + if (my $token = $c->req->params->{token}) { + if ($token eq '_test_') { + $c->stash->{been_fixed} = $c->req->params->{been_fixed}; + $c->stash->{new_state} = $c->req->params->{new_state}; + $c->stash->{template} = 'questionnaire/completed.html'; + return; + } $c->forward('submit_standard'); - } elsif ( $c->req->params->{problem} ) { + } elsif (my $p = $c->req->params->{problem}) { + $c->detach('creator_fixed') if $p eq '_test_'; $c->forward('submit_creator_fixed'); } else { $c->detach( '/page_error_404_not_found' ); @@ -106,6 +113,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..c8a7531d6 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -28,6 +28,16 @@ problem but are not logged in. sub confirm_problem : Path('/P') { my ( $self, $c, $token_code ) = @_; + if ($token_code eq '_test_') { + $c->stash->{report} = { + id => 123, + title => 'Title of Report', + bodies_str => 'True', + url => '/report/123', + }; + return; + } + my $auth_token = $c->forward( 'load_auth_token', [ $token_code, 'problem' ] ); @@ -37,7 +47,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 +93,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 @@ -135,6 +144,11 @@ alert but are not logged in. sub confirm_alert : Path('/A') { my ( $self, $c, $token_code ) = @_; + if ($token_code eq '_test_') { + $c->stash->{confirm_type} = $c->req->params->{confirm_type}; + return; + } + my $auth_token = $c->forward( 'load_auth_token', [ $token_code, 'alert' ] ); # Load the problem @@ -170,6 +184,16 @@ update but are not logged in. sub confirm_update : Path('/C') { my ( $self, $c, $token_code ) = @_; + if ($token_code eq '_test_') { + $c->stash->{problem} = { + id => 123, + title => 'Title of Report', + bodies_str => 'True', + url => '/report/123', + }; + return; + } + my $auth_token = $c->forward( 'load_auth_token', [ $token_code, 'comment' ] ); |