aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm15
2 files changed, 8 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index f732b94f1..6c14f33fb 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -60,9 +60,9 @@ sub load_problem_or_display_error : Private {
my ( $self, $c, $id ) = @_;
# try to load a report if the id is a number
- my $problem #
- = $id =~ m{\D} # is id non-numeric?
- ? undef # ...don't even search
+ my $problem
+ = ( !$id || $id =~ m{\D} ) # is id non-numeric?
+ ? undef # ...don't even search
: $c->cobrand->problems->find( { id => $id } );
# check that the problem is suitable to show.
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 2f1d88d08..4e0d6d6c5 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -20,10 +20,6 @@ Creates an update to a report
sub report_update : Path : Args(0) {
my ( $self, $c ) = @_;
- # if there's no id then we should just stop now
- $c->detach( '/page_error_404_not_found', [ _('Unknown problem ID') ] )
- unless $c->req->param('id');
-
$c->forward( '/report/load_problem_or_display_error', [ $c->req->param('id') ] )
&& $c->forward('process_user')
&& $c->forward('process_update')
@@ -182,7 +178,7 @@ sub check_for_errors : Private {
# let the model check for errors
my %field_errors = (
- %{ $c->stash->{update_user}->check_for_errors },
+ %{ $c->stash->{update}->user->check_for_errors },
%{ $c->stash->{update}->check_for_errors },
);
@@ -213,14 +209,13 @@ Save the update and the user as appropriate.
sub save_update : Private {
my ( $self, $c ) = @_;
- my $user = $c->stash->{update_user};
my $update = $c->stash->{update};
- if ( !$user->in_storage ) {
- $user->insert;
+ if ( !$update->user->in_storage ) {
+ $update->user->insert;
}
- elsif ( $c->user && $c->user->id == $user->id ) {
- $user->update;
+ elsif ( $c->user && $c->user->id == $update->user->id ) {
+ $update->user->update;
$update->confirm;
}