Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parent record to draft file profile and using it for html links #11

Merged
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
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
Loading