aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm18
-rw-r--r--t/app/controller/report_new.t42
2 files changed, 54 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 2a68b170e..bd7c5fa8d 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -105,6 +105,7 @@ sub report_new : Path : Args(0) {
# deal with the user and report and check both are happy
return unless $c->forward('check_form_submitted');
+
$c->forward('/auth/check_csrf_token');
$c->forward('process_user');
$c->forward('process_report');
@@ -493,7 +494,7 @@ Work out what the location of the report should be - either by using lat,lng or
a tile click or what's come in from a partial. Returns false if no location
could be found.
-=cut
+=cut
sub determine_location : Private {
my ( $self, $c ) = @_;
@@ -515,7 +516,7 @@ sub determine_location : Private {
Detect that the map tiles have been clicked on by looking for the tile
parameters.
-=cut
+=cut
sub determine_location_from_tile_click : Private {
my ( $self, $c ) = @_;
@@ -566,7 +567,7 @@ sub determine_location_from_tile_click : Private {
Use latitude and longitude stored in the report - this is probably result of a
partial report being loaded.
-=cut
+=cut
sub determine_location_from_report : Private {
my ( $self, $c ) = @_;
@@ -1203,9 +1204,14 @@ sub redirect_or_confirm_creation : Private {
to => [ [ $report->user->email, $report->name ] ],
} );
}
- $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';
+ if ($c->user_exists && $c->user->has_body_permission_to('planned_reports')) {
+ $c->log->info($report->user->id . ' is an inspector - redirecting straight to report page for ' . $report->id);
+ $c->res->redirect( '/report/'. $report->id );
+ } else {
+ $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;
}
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 71090cd26..f3bee0513 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -1635,6 +1635,48 @@ subtest "extra google analytics code displayed on email confirmation problem cre
};
};
+subtest "inspectors get redirected directly to the report page" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ BASE_URL => 'https://www.fixmystreet.com',
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->log_out_ok;
+
+ my $user = $mech->create_user_ok('inspector@example.org', name => 'inspector', from_body => $bodies[0]);
+ $user->user_body_permissions->find_or_create({
+ body => $bodies[0],
+ permission_type => 'planned_reports',
+ });
+
+ $mech->log_in_ok('inspector@example.org');
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => 'GL50 2PR' } },
+ "submit location" );
+ $mech->follow_link_ok(
+ { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link"
+ );
+
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ title => "Inspector report",
+ detail => 'Inspector report details.',
+ photo1 => '',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ phone => '07903 123 456',
+ category => 'Trees',
+ }
+ },
+ "submit good details"
+ );
+
+ like $mech->uri->path, qr/\/report\/[0-9]+/, 'Redirects directly to report';
+ }
+};
+
done_testing();
END {