Hydra/20: Jobset clone feature
This commit is contained in:
@ -252,4 +252,49 @@ sub updateJobset {
|
||||
}
|
||||
|
||||
|
||||
sub clone : Chained('jobset') PathPart('clone') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
my $jobset = $c->stash->{jobset};
|
||||
requireProjectOwner($c, $jobset->project);
|
||||
|
||||
$c->stash->{template} = 'clone-jobset.tt';
|
||||
}
|
||||
|
||||
sub clone_submit : Chained('jobset') PathPart('clone/submit') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
my $jobset = $c->stash->{jobset};
|
||||
requireProjectOwner($c, $jobset->project);
|
||||
requirePost($c);
|
||||
|
||||
my $newjobsetName = trim $c->request->params->{"newjobset"};
|
||||
error($c, "Invalid jobset name: $newjobsetName") unless $newjobsetName =~ /^[[:alpha:]][\w\-]*$/;
|
||||
|
||||
my $newjobset;
|
||||
txn_do($c->model('DB')->schema, sub {
|
||||
$newjobset = $jobset->project->jobsets->create(
|
||||
{ name => $newjobsetName
|
||||
, description => $jobset->description
|
||||
, nixexprpath => $jobset->nixexprpath
|
||||
, nixexprinput => $jobset->nixexprinput
|
||||
, enabled => 0
|
||||
, enableemail => $jobset->enableemail
|
||||
, emailoverride => $jobset->emailoverride
|
||||
});
|
||||
|
||||
foreach my $input ($jobset->jobsetinputs) {
|
||||
my $newinput = $newjobset->jobsetinputs->create({name => $input->name, type => $input->type});
|
||||
foreach my $inputalt ($input->jobsetinputalts) {
|
||||
$newinput->jobsetinputalts->create({altnr => $inputalt->altnr, value => $inputalt->value});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$c->res->redirect($c->uri_for($c->controller('Jobset')->action_for("edit"), [$jobset->project->name, $newjobsetName]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user