Skip to content

Commit

Permalink
Makes bulk import configurable. Default (without entry in catmandu.lo…
Browse files Browse the repository at this point in the history
…cal.yml): bulk import is activated and unchanged. If switched off, import will only fetch one record and not save it in the db directly but show it in the edit form.
  • Loading branch information
petrakohorst committed Sep 13, 2018
1 parent 3bb5b79 commit 6080b8a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions config/catmandu.local.yml-example
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ request_copy:
# if set to 1 or omitted: use gravatar.
show_gravatar: 1

# Configure bulk import of records
# Allow bulk import, or restrict to only one record from source.
# If set to 0, import will show edit form instead of importing into db.
bulk_import: 1

# Default format to display dates
time_format: "%Y-%m-%dT%H:%M:%SZ"
Expand Down
17 changes: 13 additions & 4 deletions lib/LibreCat/App/Catalogue/Route/importer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,23 @@ post '/librecat/record/import' => sub {
$pub->{user_id} = session->{user_id};
$pub->{department} = $user->{department};

# Use config/hooks.yml to register functions
# that should run before/after importing publications
h->hook('import-new-' . $source)->fix_around(
if(h->config->{bulk_import} or !exists h->config->{bulk_import}){
# Use config/hooks.yml to register functions
# that should run before/after importing publications
h->hook('import-new-' . $source)->fix_around(
$pub,
sub {
publication->add($pub);
}
);
);
}
else {
my $type = $pub->{type} || 'journal_article';
my $templatepath = "backend/forms";
$pub->{new_record} = 1;

return template $templatepath . "/$type.tt", $pub;
}
}

return template "backend/add_new",
Expand Down

0 comments on commit 6080b8a

Please sign in to comment.