Skip to content

Commit

Permalink
records: added link template for read_many calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromumo committed Sep 13, 2023
1 parent 192f9b1 commit 4441e5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions invenio_records_resources/services/base/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def preprocess_vars(vars):
class LinksTemplate:
"""Templates for generating links for an object."""

def __init__(self, links, context=None):
def __init__(self, links=None, context=None):
"""Initialize the link templates."""
self._links = links
self._links = links or {}
self._context = context or {}

@property
Expand Down
9 changes: 8 additions & 1 deletion invenio_records_resources/services/records/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,14 @@ def read_many(self, identity, ids, fields=None, **kwargs):

results = self._read_many(identity, query, fields, len(ids), **kwargs)

return self.result_list(self, identity, results)
links_item = getattr(self.config, "links_item", None)

return self.result_list(
self,
identity,
results,
links_item_tpl=LinksTemplate(links_item),
)

def read_all(self, identity, fields, max_records=150, **kwargs):
"""Search for records matching the querystring."""
Expand Down

0 comments on commit 4441e5b

Please sign in to comment.