diff --git a/oarepo_requests/types/publish_draft.py b/oarepo_requests/types/publish_draft.py index 8bc07d5..aab5c9b 100644 --- a/oarepo_requests/types/publish_draft.py +++ b/oarepo_requests/types/publish_draft.py @@ -108,19 +108,22 @@ def validate_topic(cls, identity: Identity, topic: Record) -> None: """ topic_service = get_record_service_for_record(topic) topic_service.validate_draft(identity, topic["id"]) - can_toggle_files = topic_service.check_permission( - identity, "manage_files", record=topic - ) - draft_files = topic.files # type: ignore - if draft_files.enabled and not draft_files.items(): - if can_toggle_files: - my_message = _( - "Missing uploaded files. To disable files for this record please mark it as metadata-only." - ) - else: - my_message = _("Missing uploaded files.") - - raise ma.ValidationError({"files.enabled": [my_message]}) + + # if files support is enabled for this topic, check if there are any files + if hasattr(topic, "files"): + can_toggle_files = topic_service.check_permission( + identity, "manage_files", record=topic + ) + draft_files = topic.files # type: ignore + if draft_files.enabled and not draft_files.items(): + if can_toggle_files: + my_message = _( + "Missing uploaded files. To disable files for this record please mark it as metadata-only." + ) + else: + my_message = _("Missing uploaded files.") + + raise ma.ValidationError({"files.enabled": [my_message]}) @classmethod def is_applicable_to( diff --git a/setup.cfg b/setup.cfg index 14eea6f..3add489 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-requests -version = 2.3.3 +version = 2.3.4 description = authors = Ronald Krist readme = README.md