KXGOUX7PH4BOXPJRYRGDS4RY7RTXYWUXCRAB5JR3BLVS62PVKOQAC
$c->stash->{template} = 'create-release.tt';
requireProjectOwner($c, $c->stash->{project});
my $releaseName = $c->request->params->{name};
my $release;
txn_do($c->model('DB')->schema, sub {
# Note: $releaseName is validated in updateRelease, which will
# abort the transaction if the name isn't valid.
$release = $c->stash->{project}->releases->create(
{ name => $releaseName
, timestamp => time
});
Hydra::Controller::Release::updateRelease($c, $release);
});
$c->res->redirect($c->uri_for($c->controller('Release')->action_for('view'),
[$c->stash->{project}->name, $release->name]));
package Hydra::Controller::Release;
use strict;
use warnings;
use base 'Catalyst::Controller';
use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
sub release : Chained('/') PathPart('release') CaptureArgs(2) {
my ($self, $c, $projectName, $releaseName) = @_;
#$c->stash->{project} = $project;
#$c->stash->{release} = $view;
}
sub view : Chained('release') PathPart('') Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'release.tt';
}
sub updateRelease {
my ($c, $release) = @_;
my $releaseName = trim $c->request->params->{name};
error($c, "Invalid release name: $releaseName")
unless $releaseName =~ /^[[:alpha:]][\w\-]*$/;
$release->update(
{ name => $releaseName
, description => trim $c->request->params->{description}
});
}
1;
package Hydra::Schema::ReleaseMembers;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("Core");
__PACKAGE__->table("ReleaseMembers");
__PACKAGE__->add_columns(
"project",
{
data_type => "text",
default_value => undef,
is_foreign_key => 1,
is_nullable => 0,
size => undef,
},
"release_",
{
data_type => "text",
default_value => undef,
is_foreign_key => 1,
is_nullable => 0,
size => undef,
},
"build",
{
data_type => "integer",
default_value => undef,
is_foreign_key => 1,
is_nullable => 0,
size => undef,
},
"description",
{
data_type => "text",
default_value => undef,
is_nullable => 1,
size => undef,
},
);
__PACKAGE__->set_primary_key("project", "release_", "build");
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" });
__PACKAGE__->belongs_to(
"release",
"Hydra::Schema::Releases",
{ name => "release_", project => "project" },
);
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" });
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 17:40:21
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wBLLjLvDq9RWmybMfJiDtQ
# You can replace this text with custom content, and it will be preserved on regeneration
1;
package Hydra::Schema::Releases;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("Core");
__PACKAGE__->table("Releases");
__PACKAGE__->add_columns(
"project",
{
data_type => "text",
default_value => undef,
is_foreign_key => 1,
is_nullable => 0,
size => undef,
},
"name",
{
data_type => "text",
default_value => undef,
is_nullable => 0,
size => undef,
},
"timestamp",
{
data_type => "integer",
default_value => undef,
is_nullable => 0,
size => undef,
},
"description",
{
data_type => "text",
default_value => undef,
is_nullable => 1,
size => undef,
},
);
__PACKAGE__->set_primary_key("project", "name");
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" });
__PACKAGE__->has_many(
"releasemembers",
"Hydra::Schema::ReleaseMembers",
{
"foreign.project" => "self.project",
"foreign.release_" => "self.name",
},
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-21 17:40:21
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:udsx/5Ic4ul6vDoR6IwFAg
# You can replace this text with custom content, and it will be preserved on regeneration
1;
[% WRAPPER layout.tt title=(create ? "New Release" : "Edit Release") %]
[% PROCESS common.tt %]
[% USE HTML %]
<h1>New Release</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">
<table class="layoutTable">
<tr>
<th>Identifier:</th>
<td><input type="text" class="string" name="name" [% HTML.attributes(value => release.name) %] /></td>
</tr>
<tr>
<th>Description:</th>
<td><input type="text" class="string" name="description" [% HTML.attributes(value => release.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 %]