forked from lix-project/hydra
This commit is contained in:
parent
e4e7fac958
commit
06b49e0df7
|
@ -202,18 +202,18 @@ sub attrsToSQL {
|
||||||
|
|
||||||
|
|
||||||
sub getReleaseSet {
|
sub getReleaseSet {
|
||||||
my ($c, $projectName, $releaseName) = @_;
|
my ($c, $projectName, $releaseSetName) = @_;
|
||||||
|
|
||||||
my $project = $c->model('DB::Projects')->find($projectName);
|
my $project = $c->model('DB::Projects')->find($projectName);
|
||||||
die "Project $projectName doesn't exist." if !defined $project;
|
die "Project $projectName doesn't exist." if !defined $project;
|
||||||
$c->stash->{curProject} = $project;
|
$c->stash->{curProject} = $project;
|
||||||
|
|
||||||
(my $releaseSet) = $c->model('DB::Releasesets')->find($projectName, $releaseName);
|
(my $releaseSet) = $c->model('DB::Releasesets')->find($projectName, $releaseSetName);
|
||||||
die "Release set $releaseName doesn't exist." if !defined $releaseSet;
|
die "Release set $releaseSetName doesn't exist." if !defined $releaseSet;
|
||||||
$c->stash->{releaseSet} = $releaseSet;
|
$c->stash->{releaseSet} = $releaseSet;
|
||||||
|
|
||||||
(my $primaryJob) = $releaseSet->releasesetjobs->search({isprimary => 1});
|
(my $primaryJob) = $releaseSet->releasesetjobs->search({isprimary => 1});
|
||||||
die "Release set $releaseName doesn't have a primary job." if !defined $primaryJob;
|
die "Release set $releaseSetName doesn't have a primary job." if !defined $primaryJob;
|
||||||
|
|
||||||
$c->stash->{jobs} = [$releaseSet->releasesetjobs->search({},
|
$c->stash->{jobs} = [$releaseSet->releasesetjobs->search({},
|
||||||
{order_by => ["isprimary DESC", "job", "attrs"]})];
|
{order_by => ["isprimary DESC", "job", "attrs"]})];
|
||||||
|
@ -266,12 +266,46 @@ sub getRelease {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub updateReleaseSet {
|
||||||
|
my ($c, $releaseSet) = @_;
|
||||||
|
|
||||||
|
my $releaseSetName = trim $c->request->params->{name};
|
||||||
|
die "Invalid release set name: $releaseSetName" unless $releaseSetName =~ /^[[:alpha:]]\w*$/;
|
||||||
|
|
||||||
|
$releaseSet->name($releaseSetName);
|
||||||
|
$releaseSet->description(trim $c->request->params->{description});
|
||||||
|
$releaseSet->update;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub releases :Local {
|
sub releases :Local {
|
||||||
my ($self, $c, $projectName, $releaseName) = @_;
|
my ($self, $c, $projectName, $releaseSetName, $subcommand) = @_;
|
||||||
|
|
||||||
|
my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseSetName);
|
||||||
|
|
||||||
|
if ($subcommand ne "") {
|
||||||
|
|
||||||
|
return requireLogin($c) if !$c->user_exists;
|
||||||
|
|
||||||
|
return error($c, "Only the project owner or the administrator can perform this operation.")
|
||||||
|
unless $c->check_user_roles('admin') || $c->user->username eq $project->owner;
|
||||||
|
|
||||||
|
if ($subcommand eq "edit") {
|
||||||
|
$c->stash->{template} = 'edit-releaseset.tt';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif ($subcommand eq "submit") {
|
||||||
|
$c->model('DB')->schema->txn_do(sub {
|
||||||
|
updateReleaseSet($c, $releaseSet);
|
||||||
|
});
|
||||||
|
return $c->res->redirect($c->uri_for("/releases", $projectName, $releaseSet->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
else { return error($c, "Unknown subcommand."); }
|
||||||
|
}
|
||||||
|
|
||||||
$c->stash->{template} = 'releases.tt';
|
$c->stash->{template} = 'releases.tt';
|
||||||
|
|
||||||
my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseName);
|
|
||||||
|
|
||||||
my @primaryBuilds = $project->builds->search(
|
my @primaryBuilds = $project->builds->search(
|
||||||
{ attrname => $primaryJob->job, finished => 1 },
|
{ attrname => $primaryJob->job, finished => 1 },
|
||||||
{ join => 'resultInfo', order_by => "timestamp DESC"
|
{ join => 'resultInfo', order_by => "timestamp DESC"
|
||||||
|
@ -287,10 +321,10 @@ sub releases :Local {
|
||||||
|
|
||||||
|
|
||||||
sub release :Local {
|
sub release :Local {
|
||||||
my ($self, $c, $projectName, $releaseName, $releaseId) = @_;
|
my ($self, $c, $projectName, $releaseSetName, $releaseId) = @_;
|
||||||
$c->stash->{template} = 'release.tt';
|
$c->stash->{template} = 'release.tt';
|
||||||
|
|
||||||
my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseName);
|
my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseSetName);
|
||||||
|
|
||||||
# Note: we don't actually check whether $releaseId is a primary
|
# Note: we don't actually check whether $releaseId is a primary
|
||||||
# build, but who cares?
|
# build, but who cares?
|
||||||
|
@ -463,7 +497,7 @@ sub project :Local {
|
||||||
$c->model('DB')->schema->txn_do(sub {
|
$c->model('DB')->schema->txn_do(sub {
|
||||||
updateProject($c, $project);
|
updateProject($c, $project);
|
||||||
});
|
});
|
||||||
return $c->res->redirect($c->uri_for("/project", trim $c->request->params->{name}));
|
return $c->res->redirect($c->uri_for("/project", $project->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ($subcommand eq "delete" && $isPosted) {
|
elsif ($subcommand eq "delete" && $isPosted) {
|
||||||
|
|
25
src/Hydra/root/edit-releaseset.tt
Normal file
25
src/Hydra/root/edit-releaseset.tt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
[% WRAPPER layout.tt title="Release Sets ‘$curProject.name:$releaseSet.name’" %]
|
||||||
|
[% PROCESS common.tt %]
|
||||||
|
[% USE HTML %]
|
||||||
|
|
||||||
|
<h1>Release Set <tt>[% curProject.name %]:[% releaseSet.name %]</tt></h1>
|
||||||
|
|
||||||
|
<form action="[% IF create %][% ELSE %][% c.uri_for('/releases' curProject.name releaseSet.name 'submit') %][% END %]" method="post">
|
||||||
|
|
||||||
|
<table class="layoutTable">
|
||||||
|
<tr>
|
||||||
|
<th>Identifier:</th>
|
||||||
|
<td><input type="text" class="string" name="name" [% HTML.attributes(value => releaseSet.name) %] /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Description:</th>
|
||||||
|
<td><input type="text" class="string" name="description" [% HTML.attributes(value => releaseSet.description) %] /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p><button type="submit"><img src="/static/images/success.gif" />[%IF create %]Create[% ELSE %]Apply changes[% END %]</button></p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
[% END %]
|
|
@ -7,7 +7,10 @@
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
[% FOREACH releaseSet IN releaseSets %]
|
[% FOREACH releaseSet IN releaseSets %]
|
||||||
<li><a href="[% c.uri_for('/releases' curProject.name releaseSet.name) %]"><tt>[% releaseSet.name %]</tt></a></li>
|
<li>
|
||||||
|
<a href="[% c.uri_for('/releases' curProject.name releaseSet.name) %]"><tt>[% releaseSet.name %]</tt></a>
|
||||||
|
(<a href="[% c.uri_for('/releases' curProject.name releaseSet.name "edit") %]">edit</a>)
|
||||||
|
</li>
|
||||||
[% END %]
|
[% END %]
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -328,6 +328,13 @@ create trigger cascadeReleaseSetDelete
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
create trigger cascadeReleaseSetUpdate
|
||||||
|
update of name on ReleaseSets
|
||||||
|
for each row begin
|
||||||
|
update ReleaseSetJobs set release = new.name where project = old.project and release = old.name;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
create table ReleaseSetJobs (
|
create table ReleaseSetJobs (
|
||||||
project text not null,
|
project text not null,
|
||||||
release text not null,
|
release text not null,
|
||||||
|
|
Loading…
Reference in a new issue