Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4.15.0 #532

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
Changes
=======

Version 4.15.0 (2023-10-20)

- base: add possibility to override search options class

Version 4.14.1 (2023-10-19)

- sort: fallback safely to sort_options
Expand Down
2 changes: 1 addition & 1 deletion invenio_records_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

from .ext import InvenioRecordsResources

__version__ = "4.14.1"
__version__ = "4.15.0"

__all__ = ("__version__", "InvenioRecordsResources")
16 changes: 14 additions & 2 deletions invenio_records_resources/services/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,21 @@ class FromConfigSearchOptions:
"""Data descriptor for search options configuration."""

def __init__(
self, config_key, sort_key, facet_key, default=None, search_option_cls=None
self,
config_key,
sort_key,
facet_key,
default=None,
search_option_cls=None,
search_option_cls_key=None,
):
"""Constructor for data descriptor."""
self.config_key = config_key
self.sort_key = sort_key
self.facet_key = facet_key
self.default = default or {}
self.search_option_cls = search_option_cls
self.search_option_cls_key = search_option_cls_key

def __get__(self, obj, objtype=None):
"""Return value that was grafted on obj (descriptor protocol)."""
Expand All @@ -259,5 +266,10 @@ def __get__(self, obj, objtype=None):
sort=sort_opts,
facets=facet_opts,
)
_search_option_cls = self.search_option_cls

return self.search_option_cls.customize(search_config)
if self.search_option_cls_key:
_search_option_cls = obj._app.config.get(
self.search_option_cls_key, _search_option_cls
)
return _search_option_cls.customize(search_config)
Loading