Skip to content

Commit

Permalink
Krist/be 503 new version request user is not redirected to the new (#234
Browse files Browse the repository at this point in the history
)

* added get_record_service_for_record

* version bump

* pagination html links

* linked to __init__ and correcte typing

---------

Co-authored-by: Ronald Krist <[email protected]>
  • Loading branch information
SilvyPuzzlewell and Ronald Krist authored Dec 4, 2024
1 parent 161818b commit 608713f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
8 changes: 6 additions & 2 deletions oarepo_runtime/datastreams/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ def get_record_service_for_record(record):
if not record:
return None
if "OAREPO_PRIMARY_RECORD_SERVICE" in current_app.config:
service_id = current_app.config["OAREPO_PRIMARY_RECORD_SERVICE"][type(record)]
return current_service_registry.get(service_id)
return get_record_service_for_record_class(type(record))
else:
return get_record_service_for_record_deprecated(record)


def get_record_service_for_record_class(record_cls):
service_id = current_app.config["OAREPO_PRIMARY_RECORD_SERVICE"][record_cls]
return current_service_registry.get(service_id)


@deprecated(
version="1.5.43", reason="Please recompile model to remove this deprecation warning"
)
Expand Down
3 changes: 3 additions & 0 deletions oarepo_runtime/services/records/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .links import pagination_links_html

__all__ = ("pagination_links_html",)
21 changes: 21 additions & 0 deletions oarepo_runtime/services/records/links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from invenio_records_resources.services.base.links import Link

def pagination_links_html(tpl: str)->dict[str, Link]:
"""Create pagination links (prev/selv/next) from the same template."""
return {
"prev_html": Link(
tpl,
when=lambda pagination, ctx: pagination.has_prev,
vars=lambda pagination, vars: vars["args"].update(
{"page": pagination.prev_page.page}
),
),
"self_html": Link(tpl),
"next_html": Link(
tpl,
when=lambda pagination, ctx: pagination.has_next,
vars=lambda pagination, vars: vars["args"].update(
{"page": pagination.next_page.page}
),
),
}
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-runtime
version = 1.5.74
version = 1.5.75
description = A set of runtime extensions of Invenio repository
authors = Alzbeta Pokorna
readme = README.md
Expand Down

0 comments on commit 608713f

Please sign in to comment.