From 4ddb173ca119436bef150a870535bc7f8c84642e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 3 Oct 2013 14:16:21 +0200 Subject: [PATCH] Use notFound instead of status_not_found --- src/lib/Hydra/Controller/Jobset.pm | 34 ++++++++++------------------- src/lib/Hydra/Controller/Project.pm | 7 ++---- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 477cb111..5f30fe2e 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -12,31 +12,21 @@ sub jobsetChain :Chained('/') :PathPart('jobset') :CaptureArgs(2) { my $project = $c->model('DB::Projects')->find($projectName); - if ($project) { - $c->stash->{project} = $project; + notFound($c, "Project ‘$projectName’ doesn't exist.") if !$project; - $c->stash->{jobset_} = $project->jobsets->search({'me.name' => $jobsetName}); - my $jobset = $c->stash->{jobset_}->single; + $c->stash->{project} = $project; - if ($jobset) { - $c->stash->{jobset} = $jobset; - } else { - if ($c->action->name eq "jobset" and $c->request->method eq "PUT") { - $c->stash->{jobsetName} = $jobsetName; - } else { - $self->status_not_found( - $c, - message => "Jobset $jobsetName doesn't exist." - ); - $c->detach; - } - } + $c->stash->{jobset_} = $project->jobsets->search({'me.name' => $jobsetName}); + my $jobset = $c->stash->{jobset_}->single; + + if ($jobset) { + $c->stash->{jobset} = $jobset; } else { - $self->status_not_found( - $c, - message => "Project $projectName doesn't exist." - ); - $c->detach; + if ($c->action->name eq "jobset" and $c->request->method eq "PUT") { + $c->stash->{jobsetName} = $jobsetName; + } else { + notFound($c, "Jobset ‘$jobsetName’ doesn't exist."); + } } } diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index 6dba60ac..a9a9bec7 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -1,6 +1,5 @@ package Hydra::Controller::Project; -use utf8; use strict; use warnings; use base 'Hydra::Base::Controller::ListBuilds'; @@ -27,10 +26,8 @@ sub projectChain :Chained('/') :PathPart('project') :CaptureArgs(1) { "jobsets.enabled", ], join => [ 'owner', 'releases', 'jobsets' ], order_by => { -desc => "releases.timestamp" }, collapse => 1 }); - if (!$c->stash->{project} && !($c->action->name eq "project" and $c->request->method eq "PUT")) { - $self->status_not_found($c, message => "Project ‘$projectName’ doesn't exist."); - $c->detach; - } + notFound($c, "Project ‘$projectName’ doesn't exist.") + if (!$c->stash->{project} && !($c->action->name eq "project" and $c->request->method eq "PUT")); }