Admin controller: Use PathPart, not Path

Chaining paths only works properly when PathPart is used. Before this
fix, the affected URIs bypassed the top-level 'admin' sub.

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2013-03-14 19:22:02 -04:00
parent c96e427ec0
commit 94382bd8f0

View file

@ -32,21 +32,21 @@ sub machines : Chained('admin') PathPart('machines') Args(0) {
}
sub clear_queue_non_current : Chained('admin') Path('clear-queue-non-current') Args(0) {
sub clear_queue_non_current : Chained('admin') PathPart('clear-queue-non-current') Args(0) {
my ($self, $c) = @_;
$c->model('DB::Builds')->search({finished => 0, iscurrent => 0, busy => 0})->update({ finished => 1, buildstatus => 4, timestamp => time});
$c->res->redirect($c->request->referer // "/admin");
}
sub clearfailedcache : Chained('admin') Path('clear-failed-cache') Args(0) {
sub clearfailedcache : Chained('admin') PathPart('clear-failed-cache') Args(0) {
my ($self, $c) = @_;
my $r = `nix-store --clear-failed-paths '*'`;
$c->res->redirect($c->request->referer // "/admin");
}
sub clearvcscache : Chained('admin') Path('clear-vcs-cache') Args(0) {
sub clearvcscache : Chained('admin') PathPart('clear-vcs-cache') Args(0) {
my ($self, $c) = @_;
print "Clearing path cache\n";
@ -65,7 +65,7 @@ sub clearvcscache : Chained('admin') Path('clear-vcs-cache') Args(0) {
}
sub managenews : Chained('admin') Path('news') Args(0) {
sub managenews : Chained('admin') PathPart('news') Args(0) {
my ($self, $c) = @_;
$c->stash->{newsItems} = [$c->model('DB::NewsItems')->search({}, {order_by => 'createtime DESC'})];
@ -74,7 +74,7 @@ sub managenews : Chained('admin') Path('news') Args(0) {
}
sub news_submit : Chained('admin') Path('news/submit') Args(0) {
sub news_submit : Chained('admin') PathPart('news/submit') Args(0) {
my ($self, $c) = @_;
requirePost($c);
@ -92,7 +92,7 @@ sub news_submit : Chained('admin') Path('news/submit') Args(0) {
}
sub news_delete : Chained('admin') Path('news/delete') Args(1) {
sub news_delete : Chained('admin') PathPart('news/delete') Args(1) {
my ($self, $c, $id) = @_;
txn_do($c->model('DB')->schema, sub {