Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
1e2f28c7
Commit
1e2f28c7
authored
Aug 01, 2015
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize publication endpoint by checking Waffle switch earlier.
parent
bbba590c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
ecommerce/extensions/api/serializers.py
+14
-14
No files found.
ecommerce/extensions/api/serializers.py
View file @
1e2f28c7
...
@@ -187,6 +187,15 @@ class AtomicPublicationSerializer(serializers.Serializer): # pylint: disable=ab
...
@@ -187,6 +187,15 @@ class AtomicPublicationSerializer(serializers.Serializer): # pylint: disable=ab
products
=
self
.
validated_data
[
'products'
]
products
=
self
.
validated_data
[
'products'
]
try
:
try
:
if
not
waffle
.
switch_is_active
(
'publish_course_modes_to_lms'
):
message
=
(
u'Course [{course_id}] was not published to LMS '
u'because the switch [publish_course_modes_to_lms] is disabled. '
u'To avoid ghost SKUs, data has not been saved.'
)
.
format
(
course_id
=
course_id
)
raise
Exception
(
message
)
# Explicitly delimit operations which will be rolled back if an exception is raised.
# Explicitly delimit operations which will be rolled back if an exception is raised.
with
transaction
.
atomic
():
with
transaction
.
atomic
():
course
,
created
=
Course
.
objects
.
get_or_create
(
id
=
course_id
)
course
,
created
=
Course
.
objects
.
get_or_create
(
id
=
course_id
)
...
@@ -217,22 +226,13 @@ class AtomicPublicationSerializer(serializers.Serializer): # pylint: disable=ab
...
@@ -217,22 +226,13 @@ class AtomicPublicationSerializer(serializers.Serializer): # pylint: disable=ab
credit_hours
=
credit_hours
,
credit_hours
=
credit_hours
,
)
)
if
waffle
.
switch_is_active
(
'publish_course_modes_to_lms'
):
published
=
course
.
publish_to_lms
()
published
=
course
.
publish_to_lms
()
if
published
:
if
published
:
return
created
,
None
,
None
return
created
,
None
,
None
else
:
message
=
(
u'An error occurred while publishing [{course_id}] to LMS. '
u'No data has been saved or published.'
)
.
format
(
course_id
=
course_id
)
raise
Exception
(
message
)
else
:
else
:
message
=
(
message
=
(
u'Course [{course_id}] was not published to LMS '
u'An error occurred while publishing [{course_id}] to LMS. '
u'because the switch [publish_course_modes_to_lms] is disabled. '
u'No data has been saved or published.'
u'To avoid ghost SKUs, data has not been saved.'
)
.
format
(
course_id
=
course_id
)
)
.
format
(
course_id
=
course_id
)
raise
Exception
(
message
)
raise
Exception
(
message
)
...
...
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