diff --git a/integrated_channels/integrated_channel/exporters/content_metadata.py b/integrated_channels/integrated_channel/exporters/content_metadata.py index 2337994da3..634500f155 100644 --- a/integrated_channels/integrated_channel/exporters/content_metadata.py +++ b/integrated_channels/integrated_channel/exporters/content_metadata.py @@ -511,8 +511,7 @@ def export(self, **kwargs): self._log_info(f'diff items_to_update: {items_to_update}') self._log_info(f'diff items_to_delete: {items_to_delete}') - content_keys_filter = list(items_to_create.keys()) + list(items_to_update.keys()) + \ - list(items_to_delete.keys()) + content_keys_filter = list(items_to_create.keys()) + list(items_to_update.keys()) if content_keys_filter: content_metadata_items = self.enterprise_catalog_api.get_content_metadata( self.enterprise_customer, @@ -537,11 +536,9 @@ def export(self, **kwargs): update_payload[key] = item for key, item in items_to_delete.items(): - self._sanitize_and_set_item_metadata(item, key_to_content_metadata_mapping[key], IC_DELETE_ACTION) - # Sanity check - item.enterprise_customer_catalog_uuid = enterprise_customer_catalog.uuid + metadata = self._apply_delete_transformation(item.channel_metadata) + item.channel_metadata = metadata item.save() - delete_payload[key] = item # If we're not at the max payload count, we can check for orphaned content and shove it in the delete payload @@ -582,6 +579,14 @@ def export(self, **kwargs): # collections of ContentMetadataItemTransmission objects return create_payload, update_payload, delete_payload + def _apply_delete_transformation(self, item): + """ + Base implementation of a delete transformation method. This method is designed to be a NOOP as it is up to the + individual channel to define specific transformations for the channel metadata payload of transmissions + intended for deletion. + """ + return item + def _transform_exec_ed_content(self, content): """ Transform only executive education course type content to add executive education identifying tags to both the diff --git a/integrated_channels/sap_success_factors/exporters/content_metadata.py b/integrated_channels/sap_success_factors/exporters/content_metadata.py index ba9897073e..0f8f9f6c23 100644 --- a/integrated_channels/sap_success_factors/exporters/content_metadata.py +++ b/integrated_channels/sap_success_factors/exporters/content_metadata.py @@ -47,6 +47,21 @@ class SapSuccessFactorsContentMetadataExporter(ContentMetadataExporter): 'price': 'price', } + def _apply_delete_transformation(self, metadata): + """ + Specific transformations required for "deleting" a course on a SAP external service. + """ + # Applying the metadata payload update to "delete" the course on SAP instances + metadata['status'] = 'INACTIVE' + + # Sanity check as we've seen issues with schedule structure + metadata_schedule = metadata.get('schedule') + if metadata_schedule: + schedule = metadata_schedule[0] + if not schedule.get('startDate') or not schedule.get('endDate'): + metadata['schedule'] = [] + return metadata + def transform_provider_id(self, content_metadata_item): # pylint: disable=unused-argument """ Return the provider ID from the integrated channel configuration.