Skip to content

Commit

Permalink
fix: use correct imports in Palm
Browse files Browse the repository at this point in the history
  • Loading branch information
Agrendalath committed Nov 7, 2023
1 parent 909d4ae commit 7c3f251
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Change Log
Unreleased
**********

[0.4.1] - 2023-11-07
********************

Fixed
=======

* Compatibility of ``compat`` imports with Palm.

[0.4.0] - 2023-05-18
********************
Expand Down
2 changes: 1 addition & 1 deletion section_to_course/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Factors sections from Open edX courses into their own new course.
"""

__version__ = '0.4.0'
__version__ = '0.4.1'
18 changes: 14 additions & 4 deletions section_to_course/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ def duplicate_block(
Duplicate a block using the upstream function.
"""
try:
# Quince and newer
from cms.djangoapps.contentstore.utils import duplicate_block as upstream_duplicate_block
except ImportError:
# This is no longer needed in Palm.
from cms.djangoapps.contentstore.views.item import duplicate_block as upstream_duplicate_block
try:
# Palm
from cms.djangoapps.contentstore.views.block import duplicate_block as upstream_duplicate_block
except ModuleNotFoundError:
# Nutmeg
from cms.djangoapps.contentstore.views.item import duplicate_block as upstream_duplicate_block
return upstream_duplicate_block(
parent_usage_key=destination_course.location,
duplicate_source_usage_key=source_block_usage_key,
Expand All @@ -115,10 +120,15 @@ def update_from_source(
Update a block's attributes from a source block. See upstream function.
"""
try:
# Quince and newer
from cms.djangoapps.contentstore.utils import update_from_source as upstream_update_from_source
except ImportError:
# This is no longer needed in Palm.
from cms.djangoapps.contentstore.views.item import update_from_source as upstream_update_from_source
try:
# Palm
from cms.djangoapps.contentstore.views.block import update_from_source as upstream_update_from_source
except ModuleNotFoundError:
# Nutmeg
from cms.djangoapps.contentstore.views.item import update_from_source as upstream_update_from_source
upstream_update_from_source(
source_block=source_block, destination_block=destination_block, user_id=user.id,
)
Expand Down

0 comments on commit 7c3f251

Please sign in to comment.