Skip to content

Commit

Permalink
GCMD Keywords can return their children
Browse files Browse the repository at this point in the history
  • Loading branch information
lomky committed Mar 5, 2018
1 parent 3ab4d38 commit 20b6dc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Tuba.pm
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ sub startup {
$r->resource('organization_alternate_name');

$r->resource('gcmd_keyword');
$r->get('/gcmd_keyword/:gcmd_keyword/children')->to('gcmd_keyword#children');
$r->resource('region');
$report->get('/region')->to('region#list')->name('list_report_regions');
$r->resource('dataset');
Expand Down
13 changes: 13 additions & 0 deletions lib/Tuba/GcmdKeyword.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ sub show {
$c->SUPER::show(@_);
}

sub children {
my $c = shift;
my $gcmd_keyword = $c->stash('gcmd_keyword');

my $obj = GcmdKeyword->new(
identifier => $gcmd_keyword,
)->load(speculative => 1) or return $c->reply->not_found;
my $keywords = $obj->gcmd_keywords;
$c->stash(objects => $keywords);
$c->stash(extra_cols => [qw/label/]);
$c->SUPER::list();
}

sub _guess_object_class {
return 'Tuba::DB::Object::GcmdKeyword';
}
Expand Down

0 comments on commit 20b6dc8

Please sign in to comment.