Skip to content

Commit

Permalink
refactor: remove hasattr and add editable studio to cms xblock modules
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVZ96 committed Nov 25, 2023
1 parent 536493f commit 5901e25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
11 changes: 5 additions & 6 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,12 +1051,11 @@ def duplicate_block(
)

children_handled = False
if hasattr(dest_block, "studio_post_duplicate"):
# Allow an XBlock to do anything fancy it may need to when duplicated from another block.
load_services_for_studio(source_item.runtime, user)
children_handled = dest_block.studio_post_duplicate(
store, source_item, store, user, duplication_function=duplicate_block, shallow=shallow
)
# Allow an XBlock to do anything fancy it may need to when duplicated from another block.
load_services_for_studio(source_item.runtime, user)
children_handled = dest_block.studio_post_duplicate(
store, source_item, store, user, duplication_function=duplicate_block, shallow=shallow
)

if not children_handled:
handle_children_duplication(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,11 @@ def _duplicate_block(
)

children_handled = False
if hasattr(dest_block, "studio_post_duplicate"):
# Allow an XBlock to do anything fancy it may need to when duplicated from another block.
load_services_for_studio(source_item.runtime, user)
children_handled = dest_block.studio_post_duplicate(
source_item, store, user, duplication_function=_duplicate_block, shallow=False
)
# Allow an XBlock to do anything fancy it may need to when duplicated from another block.
load_services_for_studio(source_item.runtime, user)
children_handled = dest_block.studio_post_duplicate(
source_item, store, user, duplication_function=_duplicate_block, shallow=False
)

if not children_handled:
handle_children_duplication(
Expand Down
2 changes: 2 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@
# Import after sys.path fixup
from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.x_module import XModuleMixin
from xmodule.studio_editable import StudioEditableBlock

# These are the Mixins that should be added to every XBlock.
# This should be moved into an XBlock Runtime/Application object
Expand All @@ -969,6 +970,7 @@
XModuleMixin,
EditInfoMixin,
AuthoringMixin,
StudioEditableBlock,
)
XBLOCK_EXTRA_MIXINS = ()

Expand Down

0 comments on commit 5901e25

Please sign in to comment.