added hide feature for project/jobset
This commit is contained in:
@ -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) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
|
@ -26,7 +26,7 @@ sub view : Chained('project') PathPart('') Args(0) {
|
||||
#getBuildStats($c, scalar $c->stash->{project}->builds);
|
||||
|
||||
$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"
|
||||
, "+select" => [
|
||||
"(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) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
|
@ -26,7 +26,7 @@ sub begin :Private {
|
||||
sub index :Path :Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$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 })];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user