Skip to content

Commit

Permalink
openaccess: make mark optional
Browse files Browse the repository at this point in the history
  • Loading branch information
utnapischtim committed Jan 12, 2025
1 parent c7dc665 commit e814aea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 9 additions & 1 deletion invenio_workflows_tugraz/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022-2024 Graz University of Technology.
# Copyright (C) 2022-2025 Graz University of Technology.
#
# invenio-workflows-tugraz is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
Expand Down Expand Up @@ -85,3 +85,11 @@
"""See corresponding varaible in invenio-pure."""

WORKFLOWS_PURE_FILTER_RECORDS = openaccess_filter()

WORKFLOWS_PURE_MARK_EXPORTED = False
"""It enables to configure if imported records should be marked as exported.
In production this should be enabled but for testing purpose it is practical to
have this flag. it enables the option to import multiple times without changing
the record in pure.
"""
12 changes: 7 additions & 5 deletions invenio_workflows_tugraz/openaccess/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""Open Access Workflow."""


from flask import current_app
from flask_principal import Identity
from invenio_pure import PureRuntimeError
from invenio_pure.records.models import PureRESTError
Expand Down Expand Up @@ -97,11 +98,12 @@ def import_func(
msg = f"ERROR: PureImport ValidationError pure_id: {pure_id}, error: {error}"
raise RuntimeError(msg) from error

try:
change_to_exported(pure_record)
pure_service.mark_as_exported(identity, pure_id, pure_record)
except PureRESTError as error:
raise RuntimeError(str(error)) from error
if current_app.config.get("WORKFLOWS_PURE_MARK_EXPORTED", False):
try:
change_to_exported(pure_record)
pure_service.mark_as_exported(identity, pure_id, pure_record)
except PureRESTError as error:
raise RuntimeError(str(error)) from error

# since the valid import has been checked directly after creating the draft
# the publish should work without errors.
Expand Down

0 comments on commit e814aea

Please sign in to comment.