From 56a62c3d882faa7c1c82204bf299280200b4ce3d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 26 Feb 2013 17:36:49 +0100 Subject: [PATCH] Make jobset deletion consistent with project deletion --- src/lib/Hydra/Controller/Jobset.pm | 20 +++++--------------- src/lib/Hydra/Controller/Project.pm | 4 ++-- src/root/edit-jobset.tt | 12 ++++++++++++ src/root/topbar.tt | 12 ------------ 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 1cbed7e9..0352d656 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -131,6 +131,11 @@ sub submit : Chained('jobset') PathPart Args(0) { requireProjectOwner($c, $c->stash->{project}); requirePost($c); + if (($c->request->params->{submit} // "") eq "delete") { + $c->stash->{jobset}->delete; + return $c->res->redirect($c->uri_for($c->controller('Project')->action_for("view"), [$c->stash->{project}->name])); + } + txn_do($c->model('DB')->schema, sub { updateJobset($c, $c->stash->{jobset}); }); @@ -140,21 +145,6 @@ sub submit : Chained('jobset') PathPart Args(0) { } -sub delete : Chained('jobset') PathPart Args(0) { - my ($self, $c) = @_; - - requireProjectOwner($c, $c->stash->{project}); - requirePost($c); - - txn_do($c->model('DB')->schema, sub { - $c->stash->{jobset}->delete; - }); - - $c->res->redirect($c->uri_for($c->controller('Project')->action_for("view"), - [$c->stash->{project}->name])); -} - - sub nixExprPathFromParams { my ($c) = @_; diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index 9fe89be1..79de53a3 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -45,9 +45,9 @@ sub submit : Chained('project') PathPart Args(0) { requireProjectOwner($c, $c->stash->{project}); requirePost($c); - if (($c->request->params->{submit} || "") eq "delete") { + if (($c->request->params->{submit} // "") eq "delete") { $c->stash->{project}->delete; - $c->res->redirect($c->uri_for("/")); + return $c->res->redirect($c->uri_for("/")); } txn_do($c->model('DB')->schema, sub { diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index 75aa870a..b5886b6a 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -109,6 +109,18 @@
+ + [% IF !create %] + + + [% END %]
diff --git a/src/root/topbar.tt b/src/root/topbar.tt index a1f56455..1e95d873 100644 --- a/src/root/topbar.tt +++ b/src/root/topbar.tt @@ -82,18 +82,6 @@ [% IF c.user_exists %]
  • [% INCLUDE menuItem uri = c.uri_for('/jobset' project.name jobset.name 'edit') title="Edit" %] - - - - [% INCLUDE menuItem title="Delete" uri = "javascript:confirmDeleteJobset()" %] - [% INCLUDE menuItem uri = c.uri_for('/jobset' project.name jobset.name 'clone') title="Clone" %]