Skip to content

Commit 8e6a56a

Browse files
committed
Do inheritance skipping properly.
1 parent cb0e61b commit 8e6a56a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

contentcuration/contentcuration/tests/test_exportchannel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def setUp(self):
6969
super(ExportChannelTestCase, self).setUp()
7070
self.content_channel = channel()
7171

72+
# Make a ricecooker channel to test inheritance behaviour
73+
self.content_channel.ricecooker_version = "0.7.1"
74+
self.content_channel.save()
75+
7276
# Add some incomplete nodes to ensure they don't get published.
7377
new_node = create_node({'kind_id': 'topic', 'title': 'Incomplete topic', 'children': []})
7478
new_node.complete = False

contentcuration/contentcuration/utils/publish.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,10 @@ def map_nodes(self):
226226

227227
def _gather_inherited_metadata(self, node, inherited_fields):
228228
metadata = {}
229-
if not self.inherit_metadata:
230-
return metadata
231229

232230
for field in inheritable_map_fields:
233231
metadata[field] = {}
234-
inherited_keys = (inherited_fields.get(field) or {}).keys()
232+
inherited_keys = (inherited_fields.get(field) or {}).keys() if self.inherit_metadata else []
235233
own_keys = (getattr(node, field) or {}).keys()
236234
# Get a list of all keys in reverse order of length so we can remove any less specific values
237235
all_keys = sorted(set(inherited_keys).union(set(own_keys)), key=len, reverse=True)
@@ -240,7 +238,7 @@ def _gather_inherited_metadata(self, node, inherited_fields):
240238
metadata[field][key] = True
241239

242240
for field in inheritable_simple_value_fields:
243-
if field in inherited_fields:
241+
if self.inherit_metadata and field in inherited_fields:
244242
metadata[field] = inherited_fields[field]
245243
if getattr(node, field):
246244
metadata[field] = getattr(node, field)

0 commit comments

Comments
 (0)