forked from lix-project/hydra
Cleanup Project model
Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
ee8275cfdb
commit
78dcd3e619
|
@ -12,20 +12,10 @@ sub projectChain :Chained('/') :PathPart('project') :CaptureArgs(1) {
|
|||
my ($self, $c, $projectName) = @_;
|
||||
$c->stash->{params}->{name} //= $projectName;
|
||||
|
||||
$c->stash->{project} = $c->model('DB::Projects')->find($projectName, { columns => [
|
||||
"me.name",
|
||||
"me.displayname",
|
||||
"me.description",
|
||||
"me.enabled",
|
||||
"me.hidden",
|
||||
"me.homepage",
|
||||
"owner.username",
|
||||
"owner.fullname",
|
||||
"releases.name",
|
||||
"releases.timestamp",
|
||||
"jobsets.name",
|
||||
"jobsets.enabled",
|
||||
], join => [ 'owner', 'releases', 'jobsets' ], order_by => { -desc => "releases.timestamp" }, collapse => 1 });
|
||||
$c->stash->{project} = $c->model('DB::Projects')->find($projectName, {
|
||||
join => [ 'releases' ],
|
||||
order_by => { -desc => "releases.timestamp" },
|
||||
});
|
||||
|
||||
notFound($c, "Project ‘$projectName’ doesn't exist.")
|
||||
if !$c->stash->{project} && !($c->action->name eq "project" and $c->request->method eq "PUT");
|
||||
|
|
|
@ -284,13 +284,24 @@ __PACKAGE__->many_to_many("usernames", "projectmembers", "username");
|
|||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-14 15:46:29
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PdNQ2mf5azBB6nI+iAm8fQ
|
||||
# These lines were loaded from '/home/rbvermaa/src/hydra/src/lib/Hydra/Schema/Projects.pm' found in @INC.
|
||||
# They are now part of the custom portion of this file
|
||||
# for you to hand-edit. If you do not either delete
|
||||
# this section or remove that file from @INC, this section
|
||||
# will be repeated redundantly when you re-create this
|
||||
# file again via Loader! See skip_load_external to disable
|
||||
# this feature.
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
my %hint = (
|
||||
columns => [
|
||||
"name",
|
||||
"displayname",
|
||||
"description",
|
||||
"enabled",
|
||||
"hidden",
|
||||
"owner"
|
||||
],
|
||||
relations => {
|
||||
releases => "name",
|
||||
jobsets => "name"
|
||||
}
|
||||
);
|
||||
|
||||
sub json_hint {
|
||||
return \%hint;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use LWP::UserAgent;
|
||||
use JSON;
|
||||
use Test::Simple tests => 4;
|
||||
use Test::Simple tests => 7;
|
||||
#use Test::Simple tests => 15;
|
||||
|
||||
my $ua = LWP::UserAgent->new;
|
||||
|
@ -29,8 +29,6 @@ $user = decode_json(request_json({ uri => "/current-user" })->content());
|
|||
ok($user->{username} eq "root", "The current user is named root");
|
||||
ok($user->{userroles}->[0] eq "admin", "The current user is an admin");
|
||||
|
||||
=begin comment
|
||||
|
||||
ok(request_json({ uri => '/project/sample' })->code() == 404, "Non-existent projects don't exist");
|
||||
|
||||
$result = request_json({ uri => '/project/sample', method => 'PUT', data => { displayname => "Sample", enabled => "1", } });
|
||||
|
@ -40,6 +38,8 @@ my $project = decode_json(request_json({ uri => '/project/sample' })->content())
|
|||
|
||||
ok((not @{$project->{jobsets}}), "A new project has no jobsets");
|
||||
|
||||
=begin comment
|
||||
|
||||
$result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", inputs => { "my-src" => { type => "path", values => "/run/jobset" } }, enabled => "1", checkinterval => "3600"} });
|
||||
ok($result->code() == 201, "PUTting a new jobset creates it");
|
||||
|
||||
|
|
Loading…
Reference in a new issue