Skip to content

Commit

Permalink
Allow multiple waste reports to be created without redirection to con…
Browse files Browse the repository at this point in the history
…firm page
  • Loading branch information
davea committed Jun 26, 2023
1 parent 00627f1 commit bc6249b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions perllib/FixMyStreet/App/Controller/Report/New.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1846,9 +1846,11 @@ has been confirmed or email them a token if it has not been.
=cut

sub redirect_or_confirm_creation : Private {
my ( $self, $c ) = @_;
my ( $self, $c, $no_redirect ) = @_;
my $report = $c->stash->{report};

$no_redirect //= 0;

# If confirmed send the user straight there.
if ( $report->confirmed ) {
# Subscribe problem reporter to email updates
Expand All @@ -1872,9 +1874,11 @@ sub redirect_or_confirm_creation : Private {
$c->log->info($report->user->id . ' was logged in, redirecting to confirmation page for ' . $report->id);
$c->stash->{created_report} = 'loggedin';
$c->stash->{template} = 'tokens/confirm_problem.html';
my $redirect = $c->uri_for_action( '/report/confirmation', [ $report->id ] );
$redirect .= "?created_report=loggedin&template=confirm_problem";
return $c->res->redirect($redirect);
unless ($no_redirect) {
my $redirect = $c->uri_for_action( '/report/confirmation', [ $report->id ] );
$redirect .= "?created_report=loggedin&template=confirm_problem";
return $c->res->redirect($redirect);
}
}
return 1;
}
Expand All @@ -1897,8 +1901,10 @@ sub redirect_or_confirm_creation : Private {
# tell user that they've been sent an email
$c->stash->{template} = 'email_sent.html';
$c->stash->{email_type} = 'problem';
$redirect = $c->uri_for_action( '/report/confirmation', [ $report->id ] );
$redirect .= "?template=email_sent";
unless ($no_redirect) {
$redirect = $c->uri_for_action( '/report/confirmation', [ $report->id ] );
$redirect .= "?template=email_sent";
}
} elsif ($report->user->phone_verified) {
$c->forward( 'send_problem_confirm_text' );
$thing = 'text';
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ sub add_report : Private {
$report->confirm;
$report->update;
}
$c->forward('/report/new/redirect_or_confirm_creation');
$c->forward('/report/new/redirect_or_confirm_creation', [ 1 ]);
}

$c->user->update({ name => $original_name }) if $original_name;
Expand Down

0 comments on commit bc6249b

Please sign in to comment.