diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 3c1c15fb..68496a7c 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -17,7 +17,7 @@ sub build : Chained('/') PathPart CaptureArgs(1) { notFound($c, "Build with ID $id doesn't exist.") if !defined $c->stash->{build}; - $c->stash->{curProject} = $c->stash->{build}->project; + $c->stash->{project} = $c->stash->{build}->project; } diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index 1caf1757..a3be5c2f 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -10,16 +10,10 @@ use Hydra::Helper::CatalystUtils; sub job : Chained('/') PathPart('job') CaptureArgs(3) { my ($self, $c, $projectName, $jobsetName, $jobName) = @_; - # !!! cut&paste from Project::project. - my $project = $c->model('DB::Projects')->find($projectName) - or notFound($c, "Project $projectName doesn't exist."); - - $c->stash->{curProject} = $project; - - $c->stash->{jobset} = $project->jobsets->find({name => $jobsetName}) - or notFound($c, "Jobset $jobsetName doesn't exist."); - - $c->stash->{jobName} = $jobName; + $c->stash->{job} = $c->model('DB::Jobs')->find({project => $projectName, jobset => $jobsetName, name => $jobName}) + or notFound($c, "Job $projectName:$jobsetName:$jobName doesn't exist."); + $c->stash->{project} = $c->stash->{job}->project; + $c->stash->{jobset} = $c->stash->{job}->jobset; } @@ -32,10 +26,9 @@ sub index : Chained('job') PathPart('') Args(0) { # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('job') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; - $c->stash->{allBuilds} = - $c->stash->{jobset}->builds->search({job => $c->stash->{jobName}}); + $c->stash->{allBuilds} = $c->stash->{job}->builds; $c->stash->{channelBaseName} = - $c->stash->{curProject}->name . "-" . $c->stash->{jobset}->name . "-" . $c->stash->{jobName}; + $c->stash->{project}->name . "-" . $c->stash->{jobset}->name . "-" . $c->stash->{job}->name; } diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index d694c332..8e21ae63 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -13,7 +13,7 @@ sub jobset : Chained('/') PathPart('jobset') CaptureArgs(2) { my $project = $c->model('DB::Projects')->find($projectName) or notFound($c, "Project $projectName doesn't exist."); - $c->stash->{curProject} = $project; + $c->stash->{project} = $project; $c->stash->{jobset} = $project->jobsets->find({name => $jobsetName}) or notFound($c, "Jobset $jobsetName doesn't exist."); @@ -32,7 +32,7 @@ sub get_builds : Chained('jobset') PathPart('') CaptureArgs(0) { $c->stash->{allBuilds} = $c->stash->{jobset}->builds; $c->stash->{channelBaseName} = - $c->stash->{curProject}->name . "-" . $c->stash->{jobset}->name; + $c->stash->{project}->name . "-" . $c->stash->{jobset}->name; } diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index d03020c2..461d2c18 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -13,7 +13,7 @@ sub project : Chained('/') PathPart('project') CaptureArgs(1) { my $project = $c->model('DB::Projects')->find($projectName) or notFound($c, "Project $projectName doesn't exist."); - $c->stash->{curProject} = $project; + $c->stash->{project} = $project; } @@ -22,14 +22,14 @@ sub view : Chained('project') PathPart('') Args(0) { $c->stash->{template} = 'project.tt'; - getBuildStats($c, scalar $c->stash->{curProject}->builds); + getBuildStats($c, scalar $c->stash->{project}->builds); } sub edit : Chained('project') PathPart Args(0) { my ($self, $c) = @_; - requireProjectOwner($c, $c->stash->{curProject}); + requireProjectOwner($c, $c->stash->{project}); $c->stash->{template} = 'project.tt'; $c->stash->{edit} = 1; @@ -39,12 +39,12 @@ sub edit : Chained('project') PathPart Args(0) { sub submit : Chained('project') PathPart Args(0) { my ($self, $c) = @_; - requireProjectOwner($c, $c->stash->{curProject}); + requireProjectOwner($c, $c->stash->{project}); error($c, "Request must be POSTed.") if $c->request->method ne "POST"; $c->model('DB')->schema->txn_do(sub { - updateProject($c, $c->stash->{curProject}); + updateProject($c, $c->stash->{project}); }); $c->res->redirect($c->uri_for($self->action_for("view"), $c->req->captures)); @@ -54,12 +54,12 @@ sub submit : Chained('project') PathPart Args(0) { sub delete : Chained('project') PathPart Args(0) { my ($self, $c) = @_; - requireProjectOwner($c, $c->stash->{curProject}); + requireProjectOwner($c, $c->stash->{project}); error($c, "Request must be POSTed.") if $c->request->method ne "POST"; $c->model('DB')->schema->txn_do(sub { - $c->stash->{curProject}->delete; + $c->stash->{project}->delete; }); $c->res->redirect($c->uri_for("/")); @@ -224,8 +224,8 @@ sub updateProject { # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('project') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; - $c->stash->{allBuilds} = $c->stash->{curProject}->builds; - $c->stash->{channelBaseName} = $c->stash->{curProject}->name; + $c->stash->{allBuilds} = $c->stash->{project}->builds; + $c->stash->{channelBaseName} = $c->stash->{project}->name; } diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 1c97212c..00ba6562 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -68,7 +68,7 @@ sub releasesets :Local { my $project = $c->model('DB::Projects')->find($projectName); notFound($c, "Project $projectName doesn't exist.") if !defined $project; - $c->stash->{curProject} = $project; + $c->stash->{project} = $project; $c->stash->{releaseSets} = [$project->releasesets->all]; } @@ -79,7 +79,7 @@ sub getReleaseSet { my $project = $c->model('DB::Projects')->find($projectName); die "Project $projectName doesn't exist." if !defined $project; - $c->stash->{curProject} = $project; + $c->stash->{project} = $project; (my $releaseSet) = $c->model('DB::ReleaseSets')->find($projectName, $releaseSetName); die "Release set $releaseSetName doesn't exist." if !defined $releaseSet; @@ -175,7 +175,7 @@ sub create_releaseset :Local { my $project = $c->model('DB::Projects')->find($projectName); die "Project $projectName doesn't exist." if !defined $project; - $c->stash->{curProject} = $project; + $c->stash->{project} = $project; requireProjectOwner($c, $project); diff --git a/src/root/all.tt b/src/root/all.tt index efc58cfe..65979cc7 100644 --- a/src/root/all.tt +++ b/src/root/all.tt @@ -2,9 +2,9 @@ [% PROCESS common.tt %]
Showing builds [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + builds.size %] out of [% totalBuilds %] in order of descending timestamp.
diff --git a/src/root/edit-releaseset.tt b/src/root/edit-releaseset.tt index 90ed6dfe..c2f68001 100644 --- a/src/root/edit-releaseset.tt +++ b/src/root/edit-releaseset.tt @@ -1,8 +1,8 @@ -[% WRAPPER layout.tt title=(create ? "New Release Set" : "Release Set ‘$curProject.name:$releaseSet.name’") %] +[% WRAPPER layout.tt title=(create ? "New Release Set" : "Release Set ‘$project.name:$releaseSet.name’") %] [% PROCESS common.tt %] [% USE HTML %] --[Edit] -[Latest] +[Edit] +[Latest]