forked from lix-project/hydra
added hide feature for project/jobset
This commit is contained in:
parent
b25761d7b2
commit
5f7ebaad37
|
@ -135,6 +135,32 @@ sub submit : Chained('jobset') PathPart Args(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub hide : Chained('jobset') PathPart Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
|
txn_do($c->model('DB')->schema, sub {
|
||||||
|
$c->stash->{jobset}->update({ hidden => 1, enabled => 0 });
|
||||||
|
});
|
||||||
|
|
||||||
|
$c->res->redirect($c->uri_for($c->controller('Project')->action_for("view"),
|
||||||
|
[$c->stash->{project}->name]));
|
||||||
|
}
|
||||||
|
|
||||||
|
sub unhide : Chained('jobset') PathPart Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
|
txn_do($c->model('DB')->schema, sub {
|
||||||
|
$c->stash->{jobset}->update({ hidden => 0 });
|
||||||
|
});
|
||||||
|
|
||||||
|
$c->res->redirect($c->uri_for($c->controller('Project')->action_for("view"),
|
||||||
|
[$c->stash->{project}->name]));
|
||||||
|
}
|
||||||
|
|
||||||
sub delete : Chained('jobset') PathPart Args(0) {
|
sub delete : Chained('jobset') PathPart Args(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ sub view : Chained('project') PathPart('') Args(0) {
|
||||||
#getBuildStats($c, scalar $c->stash->{project}->builds);
|
#getBuildStats($c, scalar $c->stash->{project}->builds);
|
||||||
|
|
||||||
$c->stash->{views} = [$c->stash->{project}->views->all];
|
$c->stash->{views} = [$c->stash->{project}->views->all];
|
||||||
$c->stash->{jobsets} = [$c->stash->{project}->jobsets->search({},
|
$c->stash->{jobsets} = [$c->stash->{project}->jobsets->search( isProjectOwner($c, $c->stash->{project}->name) ? {} : { hidden => 0 },
|
||||||
{ order_by => "name"
|
{ order_by => "name"
|
||||||
, "+select" => [
|
, "+select" => [
|
||||||
"(SELECT COUNT(*) FROM Builds AS a NATURAL JOIN BuildSchedulingInfo WHERE me.project = a.project AND me.name = a.jobset AND a.isCurrent = 1 )"
|
"(SELECT COUNT(*) FROM Builds AS a NATURAL JOIN BuildSchedulingInfo WHERE me.project = a.project AND me.name = a.jobset AND a.isCurrent = 1 )"
|
||||||
|
@ -63,6 +63,30 @@ sub submit : Chained('project') PathPart Args(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub hide : Chained('project') PathPart Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
|
txn_do($c->model('DB')->schema, sub {
|
||||||
|
$c->stash->{project}->update({ hidden => 1, enabled => 0 });
|
||||||
|
});
|
||||||
|
|
||||||
|
$c->res->redirect($c->uri_for("/"));
|
||||||
|
}
|
||||||
|
|
||||||
|
sub unhide : Chained('project') PathPart Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
|
txn_do($c->model('DB')->schema, sub {
|
||||||
|
$c->stash->{project}->update({ hidden => 0 });
|
||||||
|
});
|
||||||
|
|
||||||
|
$c->res->redirect($c->uri_for("/"));
|
||||||
|
}
|
||||||
|
|
||||||
sub delete : Chained('project') PathPart Args(0) {
|
sub delete : Chained('project') PathPart Args(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ sub begin :Private {
|
||||||
sub index :Path :Args(0) {
|
sub index :Path :Args(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
$c->stash->{template} = 'overview.tt';
|
$c->stash->{template} = 'overview.tt';
|
||||||
$c->stash->{projects} = [$c->model('DB::Projects')->search({}, {order_by => 'name'})];
|
$c->stash->{projects} = [$c->model('DB::Projects')->search(isAdmin($c) ? {} : {hidden => 0}, {order_by => 'name'})];
|
||||||
$c->stash->{newsItems} = [$c->model('DB::NewsItems')->search({}, { order_by => ['createtime DESC'], rows => 5 })];
|
$c->stash->{newsItems} = [$c->model('DB::NewsItems')->search({}, { order_by => ['createtime DESC'], rows => 5 })];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
getBuild getPreviousBuild getPreviousSuccessfulBuild getBuildStats joinWithResultInfo getChannelData
|
getBuild getPreviousBuild getPreviousSuccessfulBuild getBuildStats joinWithResultInfo getChannelData
|
||||||
error notFound
|
error notFound
|
||||||
requireLogin requireProjectOwner requireAdmin requirePost
|
requireLogin requireProjectOwner requireAdmin requirePost isAdmin isProjectOwner
|
||||||
trim
|
trim
|
||||||
$pathCompRE $relPathRE $relNameRE $jobNameRE $systemRE
|
$pathCompRE $relPathRE $relNameRE $jobNameRE $systemRE
|
||||||
);
|
);
|
||||||
|
@ -134,6 +134,11 @@ sub requireLogin {
|
||||||
$c->detach; # doesn't return
|
$c->detach; # doesn't return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub isProjectOwner {
|
||||||
|
my ($c, $project) = @_;
|
||||||
|
|
||||||
|
return $c->user_exists && ($c->check_user_roles('admin') || $c->user->username eq $project->owner->username || defined $c->model('DB::ProjectMembers')->find({ project => $project, userName => $c->user->username }));
|
||||||
|
}
|
||||||
|
|
||||||
sub requireProjectOwner {
|
sub requireProjectOwner {
|
||||||
my ($c, $project) = @_;
|
my ($c, $project) = @_;
|
||||||
|
@ -141,17 +146,23 @@ sub requireProjectOwner {
|
||||||
requireLogin($c) if !$c->user_exists;
|
requireLogin($c) if !$c->user_exists;
|
||||||
|
|
||||||
error($c, "Only the project members or administrators can perform this operation.")
|
error($c, "Only the project members or administrators can perform this operation.")
|
||||||
unless $c->check_user_roles('admin') || $c->user->username eq $project->owner->username || defined $c->model('DB::ProjectMembers')->find({ project => $project, userName => $c->user->username });
|
unless isProjectOwner($c, $project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub isAdmin {
|
||||||
|
my ($c) = @_;
|
||||||
|
|
||||||
|
return $c->user_exists && $c->check_user_roles('admin');
|
||||||
|
}
|
||||||
|
|
||||||
sub requireAdmin {
|
sub requireAdmin {
|
||||||
my ($c) = @_;
|
my ($c) = @_;
|
||||||
|
|
||||||
requireLogin($c) if !$c->user_exists;
|
requireLogin($c) if !$c->user_exists;
|
||||||
|
|
||||||
error($c, "Only administrators can perform this operation.")
|
error($c, "Only administrators can perform this operation.")
|
||||||
unless $c->check_user_roles('admin');
|
unless isAdmin($c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,13 @@ __PACKAGE__->table("Jobsets");
|
||||||
is_nullable: 0
|
is_nullable: 0
|
||||||
size: undef
|
size: undef
|
||||||
|
|
||||||
|
=head2 hidden
|
||||||
|
|
||||||
|
data_type: integer
|
||||||
|
default_value: 0
|
||||||
|
is_nullable: 0
|
||||||
|
size: undef
|
||||||
|
|
||||||
=head2 emailoverride
|
=head2 emailoverride
|
||||||
|
|
||||||
data_type: text
|
data_type: text
|
||||||
|
@ -165,6 +172,8 @@ __PACKAGE__->add_columns(
|
||||||
{ data_type => "integer", default_value => 1, is_nullable => 0, size => undef },
|
{ data_type => "integer", default_value => 1, is_nullable => 0, size => undef },
|
||||||
"enableemail",
|
"enableemail",
|
||||||
{ data_type => "integer", default_value => 1, is_nullable => 0, size => undef },
|
{ data_type => "integer", default_value => 1, is_nullable => 0, size => undef },
|
||||||
|
"hidden",
|
||||||
|
{ data_type => "integer", default_value => 0, is_nullable => 0, size => undef },
|
||||||
"emailoverride",
|
"emailoverride",
|
||||||
{
|
{
|
||||||
data_type => "text",
|
data_type => "text",
|
||||||
|
@ -271,7 +280,7 @@ __PACKAGE__->has_many(
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-03-05 13:07:46
|
# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-06-04 16:32:43
|
||||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Z0HutYxnzYVuQc3W51mq5Q
|
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aQ+7TLIXnNDjjulPNqLq7A
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -47,6 +47,13 @@ __PACKAGE__->table("Projects");
|
||||||
is_nullable: 0
|
is_nullable: 0
|
||||||
size: undef
|
size: undef
|
||||||
|
|
||||||
|
=head2 hidden
|
||||||
|
|
||||||
|
data_type: integer
|
||||||
|
default_value: 0
|
||||||
|
is_nullable: 0
|
||||||
|
size: undef
|
||||||
|
|
||||||
=head2 owner
|
=head2 owner
|
||||||
|
|
||||||
data_type: text
|
data_type: text
|
||||||
|
@ -88,6 +95,8 @@ __PACKAGE__->add_columns(
|
||||||
},
|
},
|
||||||
"enabled",
|
"enabled",
|
||||||
{ data_type => "integer", default_value => 1, is_nullable => 0, size => undef },
|
{ data_type => "integer", default_value => 1, is_nullable => 0, size => undef },
|
||||||
|
"hidden",
|
||||||
|
{ data_type => "integer", default_value => 0, is_nullable => 0, size => undef },
|
||||||
"owner",
|
"owner",
|
||||||
{
|
{
|
||||||
data_type => "text",
|
data_type => "text",
|
||||||
|
@ -245,8 +254,8 @@ __PACKAGE__->has_many(
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-04-20 11:21:42
|
# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-06-04 16:32:43
|
||||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1VZpwwaEdEJzrrV31ErPzw
|
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:b6DRXQBuBX5/tm+3VPO9yA
|
||||||
# These lines were loaded from '/home/rbvermaa/src/hydra/src/lib/Hydra/Schema/Projects.pm' found in @INC.
|
# 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
|
# They are now part of the custom portion of this file
|
||||||
# for you to hand-edit. If you do not either delete
|
# for you to hand-edit. If you do not either delete
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
|
[% IF c.check_user_roles('admin') %]<th>Options</th>[% END %]
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -29,6 +30,16 @@
|
||||||
<td>[% INCLUDE renderProjectName project = p.name %]</td>
|
<td>[% INCLUDE renderProjectName project = p.name %]</td>
|
||||||
<td>[% HTML.escape(p.displayname) %]</td>
|
<td>[% HTML.escape(p.displayname) %]</td>
|
||||||
<td>[% WRAPPER maybeLink uri=p.homepage %][% HTML.escape(p.description) %][% END %]</td>
|
<td>[% WRAPPER maybeLink uri=p.homepage %][% HTML.escape(p.description) %][% END %]</td>
|
||||||
|
[% IF c.check_user_roles('admin') %]
|
||||||
|
<td>
|
||||||
|
[ [% IF p.hidden %]
|
||||||
|
[% INCLUDE maybeLink uri = c.uri_for('/project' p.name 'unhide') content = "Unhide" %]
|
||||||
|
[% ELSE %]
|
||||||
|
[% INCLUDE maybeLink uri = c.uri_for('/project' p.name 'hide') content = "Hide" %]
|
||||||
|
[% END %]
|
||||||
|
]
|
||||||
|
</td>
|
||||||
|
[% END %]
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -78,7 +78,14 @@
|
||||||
<div class="[% class %]">[% j.get_column('nrsucceeded') %]/[% j.get_column('nrtotal') %]</div>
|
<div class="[% class %]">[% j.get_column('nrsucceeded') %]/[% j.get_column('nrtotal') %]</div>
|
||||||
</td>
|
</td>
|
||||||
[% IF c.check_user_roles('admin') %]
|
[% IF c.check_user_roles('admin') %]
|
||||||
<td>[ [% INCLUDE maybeLink uri = c.uri_for(c.controller('Admin').action_for('force_eval'), project.name, j.name) content = "Evaluate" confirmmsg = ("Are you sure you want to force evaluation of jobset " _ project.name _ ":" _ j.name _ "?") %] ]</td>
|
<td>[ [% INCLUDE maybeLink uri = c.uri_for(c.controller('Admin').action_for('force_eval'), project.name, j.name) content = "Evaluate" confirmmsg = ("Are you sure you want to force evaluation of jobset " _ project.name _ ":" _ j.name _ "?") %]
|
||||||
|
| [% IF j.hidden %]
|
||||||
|
[% INCLUDE maybeLink uri = c.uri_for('/jobset' project.name j.name 'unhide') content = "Unhide" %]
|
||||||
|
[% ELSE %]
|
||||||
|
[% INCLUDE maybeLink uri = c.uri_for('/jobset' project.name j.name 'hide') content = "Hide" %]
|
||||||
|
[% END %]
|
||||||
|
]
|
||||||
|
</td>
|
||||||
[% END%]
|
[% END%]
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
|
@ -20,6 +20,7 @@ create table Projects (
|
||||||
displayName text not null, -- display name (e.g. "PatchELF")
|
displayName text not null, -- display name (e.g. "PatchELF")
|
||||||
description text,
|
description text,
|
||||||
enabled integer not null default 1,
|
enabled integer not null default 1,
|
||||||
|
hidden integer not null default 0,
|
||||||
owner text not null,
|
owner text not null,
|
||||||
homepage text, -- URL for the project
|
homepage text, -- URL for the project
|
||||||
foreign key (owner) references Users(userName) on update cascade
|
foreign key (owner) references Users(userName) on update cascade
|
||||||
|
@ -48,6 +49,7 @@ create table Jobsets (
|
||||||
lastCheckedTime integer, -- last time the evaluator looked at this jobset
|
lastCheckedTime integer, -- last time the evaluator looked at this jobset
|
||||||
enabled integer not null default 1,
|
enabled integer not null default 1,
|
||||||
enableEmail integer not null default 1,
|
enableEmail integer not null default 1,
|
||||||
|
hidden integer not null default 0,
|
||||||
emailOverride text not null,
|
emailOverride text not null,
|
||||||
primary key (project, name),
|
primary key (project, name),
|
||||||
foreign key (project) references Projects(name) on delete cascade on update cascade
|
foreign key (project) references Projects(name) on delete cascade on update cascade
|
||||||
|
|
Loading…
Reference in a new issue