Skip to content

Commit 5731b5c

Browse files
committed
WIP: dynamic base path
1 parent 2e49e2a commit 5731b5c

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

app/models/concerns/standard_edition/child_document.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ module StandardEdition::ChildDocument
1616
def is_child_document?
1717
parent_edition.present?
1818
end
19+
20+
def child_document_base_path_override
21+
return unless is_child_document?
22+
23+
parent_path = parent_edition.base_path
24+
fixed_path = type_instance.settings["fixed_path"]
25+
26+
fixed_path.sub("$INHERITED", parent_path)
27+
end
1928
end

app/models/configurable_document_types/topical_event_about_page.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
}
5151
},
5252
"settings": {
53-
"base_path_prefix": "/fixme",
53+
"fixed_path": "$INHERITED/about",
5454
"publishing_api_schema_name": "topical_event_about_page",
5555
"publishing_api_document_type": "topical_event_about_page",
5656
"rendering_app": "frontend",

app/models/standard_edition.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ def change_note_required?
104104
end
105105

106106
def base_path
107-
"#{type_instance.settings['base_path_prefix']}/#{slug}"
107+
# Bit of a hack - would be nice to restrict all of the child document logic
108+
# to the ChildDocuments concern, but we can't override base_path in there and
109+
# fall back to the generic implementation here.
110+
child_document_base_path_override || "#{type_instance.settings['base_path_prefix']}/#{slug}"
108111
end
109112

110113
def type_instance

0 commit comments

Comments
 (0)