Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// This file is part of InvenioRDM
// Copyright (C) 2025.
// Copyright (C) 2026 KTH Royal Institute of Technology.
//
// Invenio RDM Records is free software; you can redistribute it and/or modify it
// under the terms of the MIT License; see LICENSE file for more details.

import { i18next } from "@translations/invenio_app_rdm/i18next";
import { i18next } from "@translations/invenio_rdm_records/i18next";
import PropTypes from "prop-types";
import React, { useState } from "react";
import { Button, Icon, Popup } from "semantic-ui-react";
Expand Down
14 changes: 6 additions & 8 deletions invenio_rdm_records/oaiserver/services/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2022-2023 Graz University of Technology.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -27,9 +28,8 @@ def __init__(self, query_arguments):
"""Initialise error."""
super().__init__(
description=_(
"A set where {query_arguments} does not exist.".format(
query_arguments=query_arguments
)
"A set where %(query_arguments)s does not exist.",
query_arguments=query_arguments,
)
)

Expand All @@ -39,9 +39,7 @@ class OAIPMHSetIDDoesNotExistError(OAIPMHError):

def __init__(self, id):
"""Initialise error."""
super().__init__(
description=_("A set with id {id} does not exist.".format(id=id))
)
super().__init__(description=_("A set with id %(id)s does not exist.", id=id))


class OAIPMHSetSpecAlreadyExistsError(OAIPMHError):
Expand All @@ -50,7 +48,7 @@ class OAIPMHSetSpecAlreadyExistsError(OAIPMHError):
def __init__(self, spec):
"""Initialise error."""
super().__init__(
description=_("A set with spec '{spec}' already exists.".format(spec=spec))
description=_("A set with spec '%(spec)s' already exists.", spec=spec)
)


Expand All @@ -60,5 +58,5 @@ class OAIPMHSetNotEditable(OAIPMHError):
def __init__(self, id):
"""Initialise error."""
super().__init__(
description=_("The set with id {id} is not editable.".format(id=id))
description=_("The set with id %(id)s is not editable.", id=id)
)
15 changes: 11 additions & 4 deletions invenio_rdm_records/requests/quota_increase.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2026 CERN.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.

"""Quota increase request."""

from invenio_access.permissions import system_identity
from invenio_i18n import gettext
from invenio_i18n import lazy_gettext as _
from invenio_requests.customizations import actions
from marshmallow import fields
Expand All @@ -22,10 +24,15 @@ class CreateAction(actions.CreateAction):
def execute(self, identity, uow):
"""Verify request preconditions and create the request."""
record = self.request.topic.resolve()

self.request["title"] = _('Quota increase request for "{record_title}"').format(
record_title=record.metadata.get("title", "Empty draft title")
)
record_title = record.metadata.get("title")

if record_title:
self.request["title"] = gettext(
'Quota increase request for "%(record_title)s"',
record_title=record_title,
)
else:
self.request["title"] = gettext("Quota increase request")

super().execute(identity, uow)

Expand Down
7 changes: 5 additions & 2 deletions invenio_rdm_records/requests/record_deletion.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2025-2026 CERN.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.

"""Record deletion request."""

from invenio_access.permissions import system_identity
from invenio_i18n import gettext
from invenio_i18n import lazy_gettext as _
from invenio_notifications.services.uow import NotificationOp
from invenio_pidstore.errors import PIDDoesNotExistError
Expand Down Expand Up @@ -39,8 +41,9 @@ def execute(self, identity, uow):
)

self._verify_removal_reason()
self.request["title"] = _('Deletion request for "{record_title}"').format(
record_title=record.metadata["title"]
self.request["title"] = gettext(
'Deletion request for "%(record_title)s"',
record_title=record.metadata["title"],
)

super().execute(identity, uow)
Expand Down
9 changes: 8 additions & 1 deletion invenio_rdm_records/secret_links/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

"""Errors for secret links."""

from invenio_i18n import gettext as _


class SecretLinkError(Exception):
"""Base exception for secret links errors."""
Expand All @@ -19,4 +21,9 @@ class InvalidPermissionLevelError(SecretLinkError):

def __init__(self, permission_level):
"""Initialise error."""
super().__init__(f"Invalid permission level: {permission_level}")
super().__init__(
_(
"Invalid permission level: %(permission_level)s",
permission_level=permission_level,
)
)
4 changes: 2 additions & 2 deletions invenio_rdm_records/services/pids/errors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021-2024 CERN.
# Copyright (C) 2024 KTH Royal Institute of Technology.
# Copyright (C) 2024-2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -19,7 +19,7 @@ class PIDSchemeNotSupportedError(RDMRecordsException):
def __init__(self, schemes):
"""Initialise error."""
super().__init__(
_("No configuration defined for PIDs {schemes}".format(schemes=schemes))
_("No configuration defined for PIDs %(schemes)s", schemes=schemes)
)


Expand Down
10 changes: 5 additions & 5 deletions invenio_rdm_records/services/pids/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _validate_identifiers(self, pids, errors):
errors.append(
{
"field": f"pids.{scheme}",
"messages": [_("Invalid {scheme}").format(scheme=label)],
"messages": [_("Invalid %(scheme)s", scheme=label)],
}
)
else:
Expand Down Expand Up @@ -159,8 +159,8 @@ def create(self, draft, scheme, identifier=None, provider_name=None):
else:
if draft.pids.get(scheme):
raise ValidationError(
message=_("A PID already exists for type {scheme}").format(
scheme=scheme
message=_(
"A PID already exists for type %(scheme)s", scheme=scheme
),
field_name=f"pids.{scheme}",
)
Expand Down Expand Up @@ -201,7 +201,7 @@ def update(self, record, scheme, url=None):
pid_attrs = record.pids.get(scheme, None)
if not pid_attrs:
raise ValidationError(
message=_("PID not found for type {scheme}").format(scheme=scheme),
message=_("PID not found for type %(scheme)s", scheme=scheme),
field_name="pids",
)

Expand All @@ -227,7 +227,7 @@ def register(self, record, scheme, url):
pid_attrs = record.pids.get(scheme, None)
if not pid_attrs:
raise ValidationError(
message=_("PID not found for type {scheme}").format(scheme=scheme),
message=_("PID not found for type %(scheme)s", scheme=scheme),
field_name="pids",
)

Expand Down
8 changes: 5 additions & 3 deletions invenio_rdm_records/services/pids/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Copyright (C) 2021 CERN.
# Copyright (C) 2021-2024 Graz University of Technology.
# Copyright (C) 2024 KTH Royal Institute of Technology.
# Copyright (C) 2024-2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -173,8 +173,10 @@ def validate(self, record, identifier=None, provider=None, **kwargs):
{
"field": f"pids.{self.pid_type}",
"messages": [
_("{pid_type}:{identifier} already exists.").format(
pid_type=self.pid_type, identifier=identifier
_(
"%(pid_type)s:%(identifier)s already exists.",
pid_type=self.pid_type,
identifier=identifier,
)
],
}
Expand Down
9 changes: 6 additions & 3 deletions invenio_rdm_records/services/pids/providers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (C) 2021 CERN.
# Copyright (C) 2023 Northwestern University.
# Copyright (C) 2023-2024 Graz University of Technology.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -42,8 +43,10 @@ def __call__(self, record, identifier, provider, errors):
if identifier.startswith(p):
errors.append(
_(
"The prefix '{prefix}' is managed by {sitename}. Please supply an external DOI or select 'No' to have a DOI generated for you."
).format(prefix=p, sitename=current_app.config["THEME_SITENAME"])
"The prefix '%(prefix)s' is managed by %(sitename)s. Please supply an external DOI or select 'No' to have a DOI generated for you.",
prefix=p,
sitename=current_app.config["THEME_SITENAME"],
)
)
# Bail early
return
Expand Down Expand Up @@ -88,7 +91,7 @@ def validate(self, record, identifier=None, provider=None, client=None, **kwargs
if not identifier:
self._insert_pid_type_error_msg(
errors,
_("Missing {scheme} for required field.").format(scheme=self.label),
_("Missing %(scheme)s for required field.", scheme=self.label),
)

for v in self._validators:
Expand Down
6 changes: 4 additions & 2 deletions invenio_rdm_records/services/schemas/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Copyright (C) 2020-2021 Northwestern University.
# Copyright (C) 2021 TU Wien.
# Copyright (C) 2021-2025 Graz University of Technology.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -64,8 +65,9 @@ def validate_protection_value(self, value, field_name):
"""Check that the protection value is valid."""
if value not in ["public", "restricted"]:
raise ValidationError(
_("'{field_name}' must be either 'public' or 'restricted'").format(
field_name=field_name
_(
"'%(field_name)s' must be either 'public' or 'restricted'",
field_name=field_name,
),
"record",
)
Expand Down
8 changes: 4 additions & 4 deletions invenio_rdm_records/services/schemas/community_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Copyright (C) 2023 CERN.
# Copyright (C) 2025 Graz University of Technology.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -33,9 +34,8 @@ def validate_records(self, value):
if max_number < len(value):
raise ValidationError(
_(
"Too many records passed, {max_number} max allowed.".format(
max_number=max_number
)
"Too many records passed, %(max_number)s max allowed.",
max_number=max_number,
)
)

Expand All @@ -50,5 +50,5 @@ def validate_records(self, value):

if duplicated:
raise ValidationError(
_("Duplicated records {rec_ids}.".format(rec_ids=duplicated))
_("Duplicated records %(rec_ids)s.", rec_ids=duplicated)
)
5 changes: 3 additions & 2 deletions invenio_rdm_records/services/schemas/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (C) 2020-2025 CERN.
# Copyright (C) 2020 Northwestern University.
# Copyright (C) 2021-2025 Graz University of Technology.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -90,11 +91,11 @@ class PersonOrOrganizationSchema(Schema):
required=True,
validate=validate.OneOf(
choices=NAMES,
error=_("Invalid value. Choose one of {NAMES}.").format(NAMES=NAMES),
error=_("Invalid value. Choose one of %(names)s.", names=NAMES),
),
error_messages={
# [] needed to mirror error message above
"required": [_("Invalid value. Choose one of {NAMES}.").format(NAMES=NAMES)]
"required": [_("Invalid value. Choose one of %(names)s.", names=NAMES)]
},
)
name = SanitizedUnicode()
Expand Down
3 changes: 2 additions & 1 deletion invenio_rdm_records/services/schemas/parent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Copyright (C) 2021 TU Wien.
# Copyright (C) 2021-2024 CERN.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -25,7 +26,7 @@ def validate_scheme(scheme):
"""Validate a PID scheme."""
if scheme not in current_app.config["RDM_PARENT_PERSISTENT_IDENTIFIERS"]:
raise ValidationError(
_("Invalid persistent identifier scheme {scheme}.".format(scheme=scheme))
_("Invalid persistent identifier scheme %(scheme)s.", scheme=scheme)
)


Expand Down
8 changes: 4 additions & 4 deletions invenio_rdm_records/services/schemas/record_communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Copyright (C) 2023 CERN.
# Copyright (C) 2025 Graz University of Technology.
# Copyright (C) 2026 KTH Royal Institute of Technology.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -36,9 +37,8 @@ def validate_communities(self, value):
if max_number < len(value):
raise ValidationError(
_(
"Too many communities passed, {max_number} max allowed.".format(
max_number=max_number
)
"Too many communities passed, %(max_number)s max allowed.",
max_number=max_number,
)
)

Expand All @@ -53,5 +53,5 @@ def validate_communities(self, value):

if duplicated:
raise ValidationError(
_("Duplicated communities {com_ids}.".format(com_ids=duplicated))
_("Duplicated communities %(com_ids)s.", com_ids=duplicated)
)
Loading