This commit is contained in:
parent
ca1a6d1bdf
commit
a7d2f5382c
|
@ -324,6 +324,13 @@ sub releases :Local {
|
|||
return $c->res->redirect($c->uri_for("/releases", $projectName, $releaseSet->name));
|
||||
}
|
||||
|
||||
elsif ($subcommand eq "delete") {
|
||||
$c->model('DB')->schema->txn_do(sub {
|
||||
$releaseSet->delete;
|
||||
});
|
||||
return $c->res->redirect($c->uri_for("/releasesets", $projectName));
|
||||
}
|
||||
|
||||
else { return error($c, "Unknown subcommand."); }
|
||||
}
|
||||
|
||||
|
@ -342,6 +349,40 @@ sub releases :Local {
|
|||
}
|
||||
|
||||
|
||||
sub create_releaseset :Local {
|
||||
my ($self, $c, $projectName, $subcommand) = @_;
|
||||
|
||||
my $project = $c->model('DB::Projects')->find($projectName);
|
||||
die "Project $projectName doesn't exist." if !defined $project;
|
||||
$c->stash->{curProject} = $project;
|
||||
|
||||
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 (defined $subcommand && $subcommand eq "submit") {
|
||||
eval {
|
||||
my $releaseSetName = $c->request->params->{name};
|
||||
$c->model('DB')->schema->txn_do(sub {
|
||||
# Note: $releaseSetName is validated in updateProject,
|
||||
# which will abort the transaction if the name isn't
|
||||
# valid.
|
||||
my $releaseSet = $project->releasesets->create({name => $releaseSetName});
|
||||
updateReleaseSet($c, $releaseSet);
|
||||
return $c->res->redirect($c->uri_for("/releases", $projectName, $releaseSet->name));
|
||||
});
|
||||
};
|
||||
if ($@) {
|
||||
return error($c, $@);
|
||||
}
|
||||
}
|
||||
|
||||
$c->stash->{template} = 'edit-releaseset.tt';
|
||||
$c->stash->{create} = 1;
|
||||
}
|
||||
|
||||
|
||||
sub release :Local {
|
||||
my ($self, $c, $projectName, $releaseSetName, $releaseId) = @_;
|
||||
$c->stash->{template} = 'release.tt';
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[% WRAPPER layout.tt title="Release Sets ‘$curProject.name:$releaseSet.name’" %]
|
||||
[% WRAPPER layout.tt title=(create ? "New Release Set" : "Release Set ‘$curProject.name:$releaseSet.name’") %]
|
||||
[% PROCESS common.tt %]
|
||||
[% USE HTML %]
|
||||
|
||||
<h1>Release Set <tt>[% curProject.name %]:[% releaseSet.name %]</tt></h1>
|
||||
<h1>[% IF create %]New Release Set[% ELSE %]Release Set <tt>[% curProject.name %]:[% releaseSet.name %]</tt>[% END %]</h1>
|
||||
|
||||
|
||||
[% BLOCK renderJob %]
|
||||
|
@ -21,7 +21,7 @@
|
|||
[% END %]
|
||||
|
||||
|
||||
<form action="[% IF create %][% ELSE %][% c.uri_for('/releases' curProject.name releaseSet.name 'submit') %][% END %]" method="post">
|
||||
<form action="[% IF create %][% c.uri_for('/create_releaseset' curProject.name 'submit') %][% ELSE %][% c.uri_for('/releases' curProject.name releaseSet.name 'submit') %][% END %]" method="post">
|
||||
|
||||
<table class="layoutTable">
|
||||
<tr>
|
||||
|
@ -84,4 +84,19 @@
|
|||
</script>
|
||||
|
||||
|
||||
[% IF !create %]
|
||||
|
||||
<form action="[% c.uri_for('/releases' curProject.name releaseSet.name 'delete') %]" method="post">
|
||||
<p><button id="delete-project" type="submit"><img src="/static/images/failure.gif" />Delete this release set</button></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$("#delete-project").click(function() {
|
||||
return confirm("Are you sure you want to delete this release set?");
|
||||
});
|
||||
</script>
|
||||
|
||||
[% END %]
|
||||
|
||||
|
||||
[% END %]
|
||||
|
|
|
@ -14,4 +14,6 @@
|
|||
[% END %]
|
||||
</ul>
|
||||
|
||||
<p>[<a href="[% c.uri_for('/create_releaseset' curProject.name) %]">Create a new release set</a>]</p>
|
||||
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue