*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit a94f63b5 authored by Moser, Maximilian's avatar Moser, Maximilian
Browse files

Chase reworked "shared_with_me" draft search parameter

* the name and behaviour of the upstream draft search parameter class
  have changed, and the UI has been reworked
* we extend the default behaviour to yield more results for admins in
  the "shared with me" tab
parent f168bc0c
No related branches found
No related tags found
No related merge requests found
......@@ -16,13 +16,30 @@ initialized, and thus we can rely on them being already available.
from logging import ERROR
from logging.handlers import SMTPHandler
from invenio_rdm_records.services.search_params import MyDraftsParam
from invenio_administration.permissions import administration_permission
from invenio_rdm_records.services.search_params import SharedOrMyDraftsParam
from invenio_requests.proxies import current_request_type_registry
from invenio_search.engine import dsl
from ..curations import TUWCurationRequest
from ..logs import DetailedFormatter
class TUWSharedOrMyDraftsParm(SharedOrMyDraftsParam):
"""Variant of the "shared_with_me" interpreter that gives more results to admins."""
def _generate_shared_with_me_query(self, identity):
"""Generate the "shared_with_me" query.
For admins, this matches all records.
For normal users, this typically involves records with access grants.
"""
if administration_permission.allows(identity):
return dsl.Q("match_all")
return super()._generate_shared_with_me_query(identity)
def register_smtp_error_handler(app):
"""Register email error handler to the application."""
handler_name = "invenio-config-tuw-smtp-error-handler"
......@@ -88,7 +105,12 @@ def override_search_drafts_options(app):
# cf. https://github.com/inveniosoftware/invenio-rdm-records/blob/maint-10.x/invenio_rdm_records/services/config.py#L327-L332
try:
service = app.extensions["invenio-rdm-records"].records_service
service.config.search_drafts.params_interpreters_cls.remove(MyDraftsParam)
service.config.search_drafts.params_interpreters_cls.remove(
SharedOrMyDraftsParam
)
service.config.search_drafts.params_interpreters_cls.append(
TUWSharedOrMyDraftsParm
)
except ValueError:
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment