Use notFound instead of status_not_found

This commit is contained in:
Eelco Dolstra 2013-10-03 14:16:21 +02:00
parent 2166c478ef
commit 4ddb173ca1
2 changed files with 14 additions and 27 deletions

View file

@ -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.");
}
}
}

View file

@ -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"));
}