diff --git a/contentcuration/contentcuration/tests/test_exportchannel.py b/contentcuration/contentcuration/tests/test_exportchannel.py index 000ce58243..71b09bda94 100644 --- a/contentcuration/contentcuration/tests/test_exportchannel.py +++ b/contentcuration/contentcuration/tests/test_exportchannel.py @@ -69,6 +69,10 @@ def setUp(self): super(ExportChannelTestCase, self).setUp() self.content_channel = channel() + # Make a ricecooker channel to test inheritance behaviour + self.content_channel.ricecooker_version = "0.7.1" + self.content_channel.save() + # Add some incomplete nodes to ensure they don't get published. new_node = create_node({'kind_id': 'topic', 'title': 'Incomplete topic', 'children': []}) new_node.complete = False diff --git a/contentcuration/contentcuration/utils/publish.py b/contentcuration/contentcuration/utils/publish.py index 9751675e59..dfe8249c4a 100644 --- a/contentcuration/contentcuration/utils/publish.py +++ b/contentcuration/contentcuration/utils/publish.py @@ -226,12 +226,10 @@ def map_nodes(self): def _gather_inherited_metadata(self, node, inherited_fields): metadata = {} - if not self.inherit_metadata: - return metadata for field in inheritable_map_fields: metadata[field] = {} - inherited_keys = (inherited_fields.get(field) or {}).keys() + inherited_keys = (inherited_fields.get(field) or {}).keys() if self.inherit_metadata else [] own_keys = (getattr(node, field) or {}).keys() # Get a list of all keys in reverse order of length so we can remove any less specific values 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): metadata[field][key] = True for field in inheritable_simple_value_fields: - if field in inherited_fields: + if self.inherit_metadata and field in inherited_fields: metadata[field] = inherited_fields[field] if getattr(node, field): metadata[field] = getattr(node, field)