Commit cb541449 by Clinton Blackburn Committed by Clinton Blackburn

Added additional logging for Drupal publisher

LEARNER-2458
parent 9d1520d0
...@@ -658,6 +658,7 @@ class CourseRun(TimeStampedModel): ...@@ -658,6 +658,7 @@ class CourseRun(TimeStampedModel):
super(CourseRun, self).save(*args, **kwargs) super(CourseRun, self).save(*args, **kwargs)
publisher.publish_obj(self, previous_obj=previous_obj) publisher.publish_obj(self, previous_obj=previous_obj)
else: else:
logger.info('Course run [%s] is not publishable.', self.key)
super(CourseRun, self).save(*args, **kwargs) super(CourseRun, self).save(*args, **kwargs)
......
import json import json
import logging
from urllib.parse import urljoin from urllib.parse import urljoin
import waffle import waffle
...@@ -17,6 +18,8 @@ from course_discovery.apps.course_metadata.exceptions import ( ...@@ -17,6 +18,8 @@ from course_discovery.apps.course_metadata.exceptions import (
) )
from course_discovery.apps.course_metadata.utils import MarketingSiteAPIClient from course_discovery.apps.course_metadata.utils import MarketingSiteAPIClient
logger = logging.getLogger(__name__)
class BaseMarketingSitePublisher: class BaseMarketingSitePublisher:
""" """
...@@ -327,18 +330,29 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher): ...@@ -327,18 +330,29 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
determine if publication is necessary. May not exist if the course run determine if publication is necessary. May not exist if the course run
is being saved for the first time. is being saved for the first time.
""" """
if previous_obj and obj.status != previous_obj.status: logger.info('Publishing course run [%s] to marketing site...', obj.key)
node_id = self.node_id(obj)
node_data = self.serialize_obj(obj) if previous_obj:
self.edit_node(node_id, node_data) if obj.status == previous_obj.status:
logger.info(
'The status of course run [%s] has not changed. It will NOT be published to the marketing site.',
obj.key)
else:
node_id = self.node_id(obj)
node_data = self.serialize_obj(obj)
self.edit_node(node_id, node_data)
elif not previous_obj and waffle.switch_is_active('auto_course_about_page_creation'): elif not previous_obj and waffle.switch_is_active('auto_course_about_page_creation'):
# This is a brand new course_run object # This is a brand new course_run object
# let's check if it exists on the marketing site # let's check if it exists on the marketing site
node_id = self.node_id(obj) node_id = self.node_id(obj)
if not node_id:
if node_id:
logger.info('Marketing site node [%s] already exists for course run [%s].', node_id, obj.key)
else:
node_data = self.serialize_obj(obj) node_data = self.serialize_obj(obj)
node_id = self.create_node(node_data) node_id = self.create_node(node_data)
logger.info('Created new marketing site node [%s] for course run [%s].', node_id, obj.key)
self.update_node_alias(obj, node_id, None) self.update_node_alias(obj, node_id, None)
def serialize_obj(self, obj): def serialize_obj(self, obj):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment