Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
cb541449
Commit
cb541449
authored
Oct 05, 2017
by
Clinton Blackburn
Committed by
Clinton Blackburn
Oct 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added additional logging for Drupal publisher
LEARNER-2458
parent
9d1520d0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
course_discovery/apps/course_metadata/models.py
+1
-0
course_discovery/apps/course_metadata/publishers.py
+19
-5
No files found.
course_discovery/apps/course_metadata/models.py
View file @
cb541449
...
...
@@ -658,6 +658,7 @@ class CourseRun(TimeStampedModel):
super
(
CourseRun
,
self
)
.
save
(
*
args
,
**
kwargs
)
publisher
.
publish_obj
(
self
,
previous_obj
=
previous_obj
)
else
:
logger
.
info
(
'Course run [
%
s] is not publishable.'
,
self
.
key
)
super
(
CourseRun
,
self
)
.
save
(
*
args
,
**
kwargs
)
...
...
course_discovery/apps/course_metadata/publishers.py
View file @
cb541449
import
json
import
logging
from
urllib.parse
import
urljoin
import
waffle
...
...
@@ -17,6 +18,8 @@ from course_discovery.apps.course_metadata.exceptions import (
)
from
course_discovery.apps.course_metadata.utils
import
MarketingSiteAPIClient
logger
=
logging
.
getLogger
(
__name__
)
class
BaseMarketingSitePublisher
:
"""
...
...
@@ -327,18 +330,29 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
determine if publication is necessary. May not exist if the course run
is being saved for the first time.
"""
if
previous_obj
and
obj
.
status
!=
previous_obj
.
status
:
node_id
=
self
.
node_id
(
obj
)
node_data
=
self
.
serialize_obj
(
obj
)
self
.
edit_node
(
node_id
,
node_data
)
logger
.
info
(
'Publishing course run [
%
s] to marketing site...'
,
obj
.
key
)
if
previous_obj
:
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'
):
# This is a brand new course_run object
# let's check if it exists on the marketing site
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_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
)
def
serialize_obj
(
self
,
obj
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment