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
53e7b0a4
Commit
53e7b0a4
authored
Jun 26, 2017
by
Simon Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark the courseRun.save with signature from refresh_course_metadata LEARNER-1606
parent
8426ff80
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
7 deletions
+17
-7
course_discovery/apps/course_metadata/data_loaders/api.py
+4
-3
course_discovery/apps/course_metadata/data_loaders/marketing_site.py
+3
-3
course_discovery/apps/course_metadata/models.py
+4
-1
course_discovery/apps/course_metadata/tests/test_models.py
+6
-0
No files found.
course_discovery/apps/course_metadata/data_loaders/api.py
View file @
53e7b0a4
...
...
@@ -141,7 +141,7 @@ class CoursesApiDataLoader(AbstractDataLoader):
def
update_course_run
(
self
,
course_run
,
body
):
validated_data
=
self
.
format_course_run_data
(
body
)
self
.
_update_instance
(
course_run
,
validated_data
)
self
.
_update_instance
(
course_run
,
validated_data
,
suppress_publication
=
True
)
logger
.
info
(
'Processed course run with UUID [
%
s].'
,
course_run
.
uuid
)
...
...
@@ -181,10 +181,11 @@ class CoursesApiDataLoader(AbstractDataLoader):
return
course
def
_update_instance
(
self
,
instance
,
validated_data
):
def
_update_instance
(
self
,
instance
,
validated_data
,
**
kwargs
):
for
attr
,
value
in
validated_data
.
items
():
setattr
(
instance
,
attr
,
value
)
instance
.
save
()
instance
.
save
(
**
kwargs
)
def
format_course_run_data
(
self
,
body
,
course
=
None
):
defaults
=
{
...
...
course_discovery/apps/course_metadata/data_loaders/marketing_site.py
View file @
53e7b0a4
...
...
@@ -363,7 +363,7 @@ class CourseMarketingSiteDataLoader(AbstractMarketingSiteDataLoader):
def
update_course_run
(
self
,
course_run
,
data
):
validated_data
=
self
.
format_course_run_data
(
data
,
course_run
.
course
)
self
.
_update_instance
(
course_run
,
validated_data
)
self
.
_update_instance
(
course_run
,
validated_data
,
suppress_publication
=
True
)
self
.
set_course_run_staff
(
course_run
,
data
)
self
.
set_course_run_transcript_languages
(
course_run
,
data
)
...
...
@@ -402,10 +402,10 @@ class CourseMarketingSiteDataLoader(AbstractMarketingSiteDataLoader):
return
course
def
_update_instance
(
self
,
instance
,
validated_data
):
def
_update_instance
(
self
,
instance
,
validated_data
,
**
kwargs
):
for
attr
,
value
in
validated_data
.
items
():
setattr
(
instance
,
attr
,
value
)
instance
.
save
()
instance
.
save
(
**
kwargs
)
def
format_course_run_data
(
self
,
data
,
course
):
uuid
=
data
[
'uuid'
]
...
...
course_discovery/apps/course_metadata/models.py
View file @
53e7b0a4
...
...
@@ -602,9 +602,12 @@ class CourseRun(TimeStampedModel):
return
'{key}: {title}'
.
format
(
key
=
self
.
key
,
title
=
self
.
title
)
def
save
(
self
,
*
args
,
**
kwargs
):
suppress_publication
=
kwargs
.
pop
(
'suppress_publication'
,
False
)
is_publishable
=
(
self
.
course
.
partner
.
has_marketing_site
and
waffle
.
switch_is_active
(
'publish_course_runs_to_marketing_site'
)
waffle
.
switch_is_active
(
'publish_course_runs_to_marketing_site'
)
and
# Pop to clean the kwargs for the base class save call below
not
suppress_publication
)
if
is_publishable
:
...
...
course_discovery/apps/course_metadata/tests/test_models.py
View file @
53e7b0a4
...
...
@@ -291,6 +291,12 @@ class CourseRunTests(TestCase):
assert
mock_init
.
call_count
==
0
toggle_switch
(
'publish_course_runs_to_marketing_site'
)
with
mock
.
patch
.
object
(
CourseRunMarketingSitePublisher
,
'__init__'
)
as
mock_init
:
# Make sure if the save comes from refresh_course_metadata, we don't actually publish
self
.
course_run
.
save
(
suppress_publication
=
True
)
assert
mock_init
.
call_count
==
0
self
.
course_run
.
course
.
partner
.
marketing_site_url_root
=
''
self
.
course_run
.
course
.
partner
.
save
()
...
...
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