Skip to content

Commit

Permalink
fixed code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducica committed Jan 20, 2025
1 parent a014fb1 commit 3c05f68
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions oarepo_requests/resolvers/interface.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

from typing import Any, TYPE_CHECKING
import logging
from typing import TYPE_CHECKING, Any

from invenio_pidstore.errors import PersistentIdentifierError

from oarepo_requests.resolvers.ui import resolve
import logging

if TYPE_CHECKING:
from invenio_requests.records import Request
Expand All @@ -27,7 +27,6 @@ def resolve_entity(entity: str, obj: Request, ctx: dict[str, Any]) -> dict:
reference_dict: dict = entity_field_value.reference_dict

key = entity_context_key(reference_dict)

if key in ctx:
return ctx[key]
try:
Expand All @@ -45,6 +44,7 @@ def resolve_entity(entity: str, obj: Request, ctx: dict[str, Any]) -> dict:


def entity_context_key(reference_dict: dict) -> str:
"""Create a key for the entity context cache."""
return "entity:" + ":".join(
f"{x[0]}:{x[1]}" for x in sorted(reference_dict.items())
)
18 changes: 18 additions & 0 deletions oarepo_requests/services/oarepo/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,21 @@ def read(self, identity: Identity, id_: str, expand: bool = False) -> RequestIte
"""Retrieve a request."""
api_request = super().read(identity, id_, expand)
return api_request

@unit_of_work()
def update(
self,
identity: Identity,
id_: str,
data: dict,
revision_id: int | None = None,
uow: UnitOfWork | None = None,
expand: bool = False,
) -> RequestItem:
"""Update a request."""
assert uow is not None
result = super().update(
identity, id_, data, revision_id=revision_id, uow=uow, expand=expand
)
uow.register(IndexRefreshOp(indexer=self.indexer, index=self.record_cls.index))
return result
1 change: 1 addition & 0 deletions oarepo_requests/ui/components/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def form_config(
form: dict | list = getattr(type_, "form", None) # type: ignore
if not form:
return

if isinstance(form, dict):
# it is just a single field
form = [{"section": "", "fields": [form]}]
Expand Down
4 changes: 1 addition & 3 deletions oarepo_requests/ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
from invenio_records_resources.services.errors import PermissionDeniedError
from invenio_requests import current_request_type_registry
from oarepo_runtime.services.custom_fields import CustomFields, InlinedCustomFields
from oarepo_ui.resources.components import (
AllowedHtmlTagsComponent,
)
from oarepo_ui.resources.components import AllowedHtmlTagsComponent
from oarepo_ui.resources.config import FormConfigResourceConfig, UIResourceConfig
from oarepo_ui.resources.links import UIRecordLink

Expand Down

0 comments on commit 3c05f68

Please sign in to comment.