Skip to content

Commit

Permalink
changes for recent Mojolicious
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Duggan committed Feb 26, 2015
1 parent 0ad50e0 commit 945f55e
Show file tree
Hide file tree
Showing 28 changed files with 66 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ my $builder = Module::Build::Database->new(
'LWP::UserAgent' => 0,
'Number::Bytes::Human' => 0,
'Mojolicious::Plugin::YamlConfig' => 0,
'Mojolicious' => '5.16',
'Mojolicious' => '5.82',
'Number::Format' => 0,
'YAML::Syck' => 0,
'YAML::XS' => 0,
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba.pm
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ sub startup {
$r->post('/calculate_url' => sub {
my $c = shift;
my $for = $c->param('_route_name');
my $route = $c->app->routes->lookup($for) or return $c->render_not_found;
my $route = $c->app->routes->lookup($for) or return $c->reply->not_found;
my $params = $c->req->params->to_hash;
delete $params->{_route_name};
my $got = $c->url_for($for, $params);
Expand Down
6 changes: 3 additions & 3 deletions lib/Tuba/Array.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sub show {
my $meta = Array->meta;
my $object = Array->new( identifier => $identifier )
->load( speculative => 1, with => [qw/tables/] )
or return $c->render_not_found;
or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => $meta);
$c->SUPER::show(@_);
Expand All @@ -49,7 +49,7 @@ sub update_rel_form {

sub update_rel {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$object->meta->error_mode('return');
$c->stash(object => $object);
$c->stash(meta => $object->meta);
Expand Down Expand Up @@ -120,7 +120,7 @@ sub _process_rows {

sub update {
my $c = shift;
my $obj = $c->_this_object or return $c->render_not_found;
my $obj = $c->_this_object or return $c->reply->not_found;
if (my $in = $c->_process_rows) {
if (ref $in eq 'ARRAY') {
$c->stash(computed_params => { rows => $in } );
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/Article.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sub doi {
my $doi = $c->stash('doi');
my $object =
Article->new( doi => $doi )->load( speculative => 1)
or return $c->render_not_found;
or return $c->reply->not_found;
$c->redirect_to('show_article' => { article_identifier => $object->identifier } );
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/Book.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sub update_rel_form {
sub update {
my $c = shift;
$c->stash(tab => 'update_form');
my $book = $c->_this_object or return $c->render_not_found;
my $book = $c->_this_object or return $c->reply->not_found;
if ($c->param('convert_into_report')) {
return $c->update_error("Not converting because this book has an ISBN, and reports don't have ISBNs.") if $book->isbn && length($book->isbn);
my $report = Report->new(
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/Contributor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use Tuba::DB::Objects qw/-nicknames/;
sub show {
my $c = shift;
my $con = Contributor->new( id => scalar $c->stash('contributor_identifier') )->load( speculative => 1)
or return $c->render_not_found;
or return $c->reply->not_found;
my $format = $c->stash('format');
if (my $p = $con->person) {
my $uri = $p->uri($c);
Expand Down
30 changes: 15 additions & 15 deletions lib/Tuba/Controller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ sub set_title {
sub show {
my $c = shift;

my $object = $c->stash('object') or return $c->render_not_found;
my $object = $c->stash('object') or return $c->reply->not_found;
my $meta = $c->stash('meta') || $object->meta;
$c->stash(meta => $meta) unless $c->stash('meta');
my $table = $meta->table;
Expand Down Expand Up @@ -301,7 +301,7 @@ sub render_not_found_or_redirect {
$sql .= " and " if $sql;
$sql .= " row_data->'$name' = \$".@bind;
}
return $c->render_not_found unless $identifier;
return $c->reply->not_found unless $identifier;

my $sth = $c->db->dbh->prepare(<<SQL, { pg_placeholder_dollaronly => 1 });
select changed_fields->'$identifier_column'
Expand All @@ -312,10 +312,10 @@ select changed_fields->'$identifier_column'
SQL
my $got = $sth->execute(@bind);
my $rows = $sth->fetchall_arrayref;
return $c->render_not_found unless $rows && @$rows;
return $c->reply->not_found unless $rows && @$rows;
my $replacement = $rows->[0][0];
my $url = $c->req->url;
$url =~ s{/$table_name/$identifier(?=/|$|\.)}{/$table_name/$replacement} or return $c->render_not_found;
$url =~ s{/$table_name/$identifier(?=/|$|\.)}{/$table_name/$replacement} or return $c->reply->not_found;
return $c->redirect_to($url);
}

Expand Down Expand Up @@ -575,7 +575,7 @@ sub update_form {
my $c = shift;
my $controls = $c->stash('controls') || {};
$c->stash(controls => { $c->_default_controls, %$controls } );
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => $object->meta);
$c->stash(cols => $c->_order_columns(meta => $object->meta));
Expand Down Expand Up @@ -608,7 +608,7 @@ Generic update_prov_form.

sub update_prov_form {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => $object->meta);
my $pub = $object->get_publication(autocreate => 1) or return $c->render(text => $object->meta->table.' is not a publication');
Expand All @@ -635,7 +635,7 @@ Update the provenance for this object.

sub update_prov {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->stash(tab => 'update_prov_form');
$c->stash(object => $object);
$c->stash(meta => $object->meta);
Expand Down Expand Up @@ -727,7 +727,7 @@ be on this page, e.g.

sub update_rel_form {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
my $controls = $c->stash('controls') || {};
$c->stash(controls => { $c->_default_rel_controls, %$controls } );
my $meta = $object->meta;
Expand All @@ -746,7 +746,7 @@ Form for updating files.

sub update_files_form {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => $object->meta);
$c->render("update_files_form");
Expand All @@ -760,7 +760,7 @@ Form for updating contributors.

sub update_contributors_form {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => $object->meta);
$c->render("update_contributors_form");
Expand All @@ -775,7 +775,7 @@ Update the files.

sub update_files {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->stash(tab => "update_files_form");

my $pub = $object->get_publication(autocreate => 1) or
Expand Down Expand Up @@ -989,7 +989,7 @@ sub update_contributors {
sub _update_pub_many {
my $c = shift;
my $what = shift;
my $obj = $c->_this_object or return $c->render_not_found;
my $obj = $c->_this_object or return $c->reply->not_found;
my $pub = $obj->get_publication(autocreate => 1);
my $cwhat = "Tuba::DB::Object::$what";
my $dwhat = decamelize($what);
Expand Down Expand Up @@ -1158,7 +1158,7 @@ sub can_set_replacement {

sub update {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
my $next = $object->uri($c,{tab => 'update_form'});
my %pk_changes;
my %new_attrs;
Expand Down Expand Up @@ -1270,7 +1270,7 @@ Generic delete

sub remove {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$object->meta->error_mode('return');
$object->delete or return $c->render_exception($object->error);
return $c->render(text => 'ok');
Expand Down Expand Up @@ -1306,7 +1306,7 @@ Generic history of changes to an object.

sub history {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
my $pk = $object->meta->primary_key;
my @columns = $pk->column_names;

Expand Down
4 changes: 2 additions & 2 deletions lib/Tuba/Exterm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sub find {
context => $c->stash('context'),
term => $c->stash('term'),
);
$term->load(speculative => 1) or return $c->render_not_found;
$term->load(speculative => 1) or return $c->reply->not_found;
my $gcid = $term->gcid;
$c->res->headers->location($gcid);
$c->respond_to(
Expand All @@ -62,7 +62,7 @@ sub remove {
context => $c->stash('context'),
term => $c->stash('term'),
);
$term->load(speculative => 1) or return $c->render_not_found;
$term->load(speculative => 1) or return $c->reply->not_found;
$term->delete or return $c->render_exception($term->error);
return $c->render(text => 'ok');
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Tuba/Figure.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sub show {
if (!$c->stash('chapter_identifier') && $object->chapter_identifier) {
$c->stash(chapter_identifier => $object->chapter_identifier);
}
return $c->render_not_found unless $c->verify_consistent_chapter($object);
return $c->reply->not_found unless $c->verify_consistent_chapter($object);

$c->stash(object => $object);
$c->stash(meta => Figure->meta);
Expand All @@ -87,8 +87,8 @@ sub show {

sub update_form {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
$c->verify_consistent_chapter($object) or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->verify_consistent_chapter($object) or return $c->reply->not_found;
$c->SUPER::update_form(@_);
}

Expand All @@ -109,7 +109,7 @@ sub update_rel_form {

sub update_rel {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->stash(tab => "update_rel_form");
my $json = $c->req->json;

Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use Tuba::DB::Objects qw/-nicknames/;

sub list {
my $c = shift;
return $c->render_not_found;
return $c->reply->not_found;
$c->stash(objects => Files->get_objects(with_objects => 'publications', page => $c->page));
my $count = Files->get_objects_count;
$c->set_pages($count);
Expand Down
8 changes: 4 additions & 4 deletions lib/Tuba/Finding.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ sub set_title {

sub update_form {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
$c->verify_consistent_chapter($object) or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$c->verify_consistent_chapter($object) or return $c->reply->not_found;
$c->SUPER::update_form(@_);
}

Expand All @@ -78,12 +78,12 @@ sub show {
return $c->redirect_to($object->uri_with_format($c)) if $object;
};

return $c->render_not_found unless $object;
return $c->reply->not_found unless $object;

if (!$c->stash('chapter_identifier') && $object->chapter_identifier) {
$c->stash(chapter_identifier => $object->chapter_identifier);
}
return $c->render_not_found unless $c->verify_consistent_chapter($object);
return $c->reply->not_found unless $c->verify_consistent_chapter($object);

$c->stash(object => $object);
$c->SUPER::show(@_);
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/GcmdKeyword.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sub list {

sub show {
my $c = shift;
my $kw = $c->_this_object or $c->render_not_found;
my $kw = $c->_this_object or $c->reply->not_found;
$c->stash(object => $kw);
$c->SUPER::show(@_);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/Generic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sub show {
my $identifier = $c->stash('generic_identifier');
my $object =
Generic->new( identifier => $identifier )->load( speculative => 1)
or return $c->render_not_found;
or return $c->reply->not_found;
$c->stash(object => $object);
$c->SUPER::show(@_);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/Image.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sub update_rel_form {

sub update_rel {
my $c = shift;
my $object = $c->_this_object or return $c->render_not_found;
my $object = $c->_this_object or return $c->reply->not_found;
$object->meta->error_mode('return');
$c->stash(object => $object);
$c->stash(meta => $object->meta);
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/Instrument.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sub show {
my $identifier = $c->stash('instrument_identifier');
my $meta = Instrument->meta;
my $object = Instrument->new( identifier => $identifier ) ->load( speculative => 1 )
or return $c->render_not_found;
or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => $meta);
$c->SUPER::show(@_);
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/InstrumentInstance.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sub show {
platform_identifier => $platform_identifier,
instrument_identifier => $instrument_identifier
)->load(speculative => 1)
or return $c->render_not_found;
or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => $object->meta);
$c->SUPER::show(@_);
Expand Down
2 changes: 1 addition & 1 deletion lib/Tuba/Model.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sub show {
my $identifier = $c->stash('model_identifier');
my $object = Model->new( identifier => $identifier )
->load( speculative => 1 )
or return $c->render_not_found;
or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => Model->meta);
$c->SUPER::show(@_);
Expand Down
4 changes: 2 additions & 2 deletions lib/Tuba/ModelRun.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sub show {
my $identifier = $c->stash('model_run_identifier');
my $object = ModelRun->new( identifier => $identifier )
->load( speculative => 1 )
or return $c->render_not_found;
or return $c->reply->not_found;
$c->stash(object => $object);
$c->stash(meta => ModelRun->meta);
$c->SUPER::show(@_);
Expand Down Expand Up @@ -73,7 +73,7 @@ sub lookup {
return $c->redirect_with_error( show => $error );
}
$run->load( speculative => 1 ) or do {
return $c->render_not_found;
return $c->reply->not_found;
};
return $c->redirect_to("/model_run/".$run->identifier);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Tuba/Organization.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ sub update_form {

sub lookup_name {
my $c = shift;
my $name = $c->req->json->{name} or return $c->render_not_found;
my $name = $c->req->json->{name} or return $c->reply->not_found;
my $org = Organization->new(name => $name)->load(speculative => 1);
if ($org) {
my $uri = $org->uri($c);
return $c->redirect_to($uri);
}
return $c->render_not_found;
return $c->reply->not_found;
}

sub merge {
Expand Down Expand Up @@ -196,7 +196,7 @@ sub contributions {
map [ $_->stringify(short => 1), $_ ], @objs;
$c->stash(objs => \@objs);

my $roletype = RoleType->new(identifier => $role_identifier)->load(speculative => 1) or return $c->render_not_found;
my $roletype = RoleType->new(identifier => $role_identifier)->load(speculative => 1) or return $c->reply->not_found;
$c->stash(role => $roletype );
$c->respond_to(
json => { json => [ map $_->as_tree(c => $c, bonsai => 1), @objs ] },
Expand Down
Loading

0 comments on commit 945f55e

Please sign in to comment.