forked from lix-project/hydra
* Editing releases.
This commit is contained in:
parent
851a4dff4d
commit
d1bea30cfc
|
@ -9,8 +9,12 @@ use Hydra::Helper::CatalystUtils;
|
|||
|
||||
sub release : Chained('/') PathPart('release') CaptureArgs(2) {
|
||||
my ($self, $c, $projectName, $releaseName) = @_;
|
||||
#$c->stash->{project} = $project;
|
||||
#$c->stash->{release} = $view;
|
||||
|
||||
$c->stash->{project} = $c->model('DB::Projects')->find($projectName)
|
||||
or notFound($c, "Project $projectName doesn't exist.");
|
||||
|
||||
$c->stash->{release} = $c->stash->{project}->releases->find({name => $releaseName})
|
||||
or notFound($c, "Release $releaseName doesn't exist.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +29,7 @@ sub updateRelease {
|
|||
|
||||
my $releaseName = trim $c->request->params->{name};
|
||||
error($c, "Invalid release name: $releaseName")
|
||||
unless $releaseName =~ /^[[:alpha:]][\w\-]*$/;
|
||||
unless $releaseName =~ /^$relNameRE$/;
|
||||
|
||||
$release->update(
|
||||
{ name => $releaseName
|
||||
|
@ -34,4 +38,33 @@ sub updateRelease {
|
|||
}
|
||||
|
||||
|
||||
sub edit : Chained('release') PathPart('edit') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
requireProjectOwner($c, $c->stash->{project});
|
||||
$c->stash->{template} = 'edit-release.tt';
|
||||
}
|
||||
|
||||
|
||||
sub submit : Chained('release') PathPart('submit') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
requireProjectOwner($c, $c->stash->{project});
|
||||
txn_do($c->model('DB')->schema, sub {
|
||||
updateRelease($c, $c->stash->{release});
|
||||
});
|
||||
$c->res->redirect($c->uri_for($self->action_for("view"),
|
||||
[$c->stash->{project}->name, $c->stash->{release}->name]));
|
||||
}
|
||||
|
||||
|
||||
sub delete : Chained('release') PathPart('delete') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
requireProjectOwner($c, $c->stash->{project});
|
||||
txn_do($c->model('DB')->schema, sub {
|
||||
$c->stash->{release}->delete;
|
||||
});
|
||||
$c->res->redirect($c->uri_for($c->controller('Project')->action_for('releases'),
|
||||
[$c->stash->{project}->name]));
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
@ -129,7 +129,8 @@ sub delete : Chained('view') PathPart('delete') Args(0) {
|
|||
txn_do($c->model('DB')->schema, sub {
|
||||
$c->stash->{view}->delete;
|
||||
});
|
||||
$c->res->redirect($c->uri_for($c->controller('Project')->action_for('view'), [$c->stash->{project}->name]));
|
||||
$c->res->redirect($c->uri_for($c->controller('Project')->action_for('view'),
|
||||
[$c->stash->{project}->name]));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ our @EXPORT = qw(
|
|||
error notFound
|
||||
requireLogin requireProjectOwner requireAdmin requirePost
|
||||
trim
|
||||
$pathCompRE $relPathRE
|
||||
$pathCompRE $relPathRE $relNameRE
|
||||
);
|
||||
|
||||
|
||||
|
@ -133,6 +133,7 @@ sub trim {
|
|||
# Security checking of filenames.
|
||||
Readonly::Scalar our $pathCompRE => "(?:[A-Za-z0-9-\+][A-Za-z0-9-\+\._]*)";
|
||||
Readonly::Scalar our $relPathRE => "(?:$pathCompRE(?:\/$pathCompRE)*)";
|
||||
Readonly::Scalar our $relNameRE =>"(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)";
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
[% PROCESS common.tt %]
|
||||
[% USE HTML %]
|
||||
|
||||
<h1>New Release</h1>
|
||||
<h1>[% IF create %]New Release[% ELSE %]Release <tt>[% release.name %]</tt>[% END %]</h1>
|
||||
|
||||
<form action="[% IF create %][% c.uri_for('/project' project.name 'create-release/submit') %][% ELSE %][% c.uri_for('/project' project.name 'release' release.name 'submit') %][% END %]" method="post">
|
||||
<form action="[% IF create %][% c.uri_for('/project' project.name 'create-release/submit') %][% ELSE %][% c.uri_for('/release' project.name release.name 'submit') %][% END %]" method="post">
|
||||
|
||||
<table class="layoutTable">
|
||||
<tr>
|
||||
|
@ -21,4 +21,18 @@
|
|||
|
||||
</form>
|
||||
|
||||
[% IF !create %]
|
||||
|
||||
<form action="[% c.uri_for('/release' project.name release.name 'delete') %]" method="post">
|
||||
<p><button id="delete-release" type="submit"><img src="/static/images/failure.gif" />Delete this release</button></p>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#delete-release").click(function() {
|
||||
return confirm("Are you sure you want to delete this release?");
|
||||
});
|
||||
</script>
|
||||
|
||||
[% END %]
|
||||
|
||||
[% END %]
|
||||
|
|
10
src/root/release.tt
Normal file
10
src/root/release.tt
Normal file
|
@ -0,0 +1,10 @@
|
|||
[% WRAPPER layout.tt title="Release ‘$release.name’" %]
|
||||
[% PROCESS common.tt %]
|
||||
[% USE HTML %]
|
||||
|
||||
<h1>Release <tt>[% release.name %]</tt> <a
|
||||
class="smallLink" href="[% c.uri_for('/release' project.name release.name "edit") %]">[Edit]</a></h1>
|
||||
|
||||
<p><em>Released on [% INCLUDE renderDateTime timestamp = release.timestamp %].</em></p>
|
||||
|
||||
[% END %]
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<ul>
|
||||
[% FOREACH release IN releases %]
|
||||
<li><tt>[% release.name %]</tt></li>
|
||||
<li><a href="[% c.uri_for('/release' project.name release.name) %]"><tt>[% release.name %]</tt></a></li>
|
||||
[% END %]
|
||||
</ul>
|
||||
|
||||
|
|
Loading…
Reference in a new issue