Skip to content

Commit

Permalink
Added parent record to draft file profile and using it for html links (
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus authored Jul 2, 2024
1 parent 3ca7886 commit 10b2ee6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions build-tests/thesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ record:
presets: ['authenticated']
use:
- invenio
resource-config:
base-html-url: /docs/

files:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def process_links(self, datatype, section: Section, **kwargs):
]

ui_prefix = url_prefix2link(
datatype.definition["resource-config"]["base-html-url"]
datatype.parent_record.definition["resource-config"]["base-html-url"]
)
ui_prefix = f"{ui_prefix}{{id}}/"

Expand Down Expand Up @@ -129,6 +129,7 @@ def before_model_prepare(self, datatype, *, context, **kwargs):

draft_record_datatype: DataType = context["draft_record"]
datatype.draft_record = draft_record_datatype
datatype.parent_record = context["parent_record"]

set_default(datatype, "json-schema-settings", {}).setdefault("skip", True)
set_default(datatype, "record-dumper", {}).setdefault("skip", True)
Expand Down
2 changes: 2 additions & 0 deletions oarepo_model_builder_drafts_files/profiles/draft_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def build(
# allocated)
draft_record = model.get_schema_section("draft", model_path[:-1] + ["draft"])
file_record = model.get_schema_section("files", model_path[:-1] + ["files"])
parent_record = model.get_schema_section("record", model_path[:-1])

draft_file_profile = dict_get(model.schema, model_path)
draft_file_profile.setdefault("type", "draft_files")
Expand All @@ -40,6 +41,7 @@ def build(
context={
"draft_record": draft_record,
"file_record": file_record,
"parent_record": parent_record,
"profile": "draft_files",
"profile_module": "files",
"switch_profile": True,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder-drafts-files
version = 4.0.12
version = 4.0.13
description =
authors = Ronald Krist <[email protected]>
readme = README.md
Expand Down

0 comments on commit 10b2ee6

Please sign in to comment.