Skip to content

Commit

Permalink
feat!: rm link_to_upstream param; just assume True if applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Oct 7, 2024
1 parent 93856ec commit e23072b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
12 changes: 2 additions & 10 deletions cms/djangoapps/contentstore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ class StaticFileNotices:
error_files: list[str] = Factory(list)


def import_staged_content_from_user_clipboard(
parent_key: UsageKey, request, *, link_to_upstream: bool = False
) -> tuple[XBlock | None, StaticFileNotices]:
def import_staged_content_from_user_clipboard(parent_key: UsageKey, request) -> tuple[XBlock | None, StaticFileNotices]:
"""
Import a block (along with its children and any required static assets) from
the "staged" OLX in the user's clipboard.
Expand Down Expand Up @@ -294,7 +292,6 @@ def import_staged_content_from_user_clipboard(
slug_hint=user_clipboard.source_usage_key.block_id,
copied_from_block=str(user_clipboard.source_usage_key),
tags=user_clipboard.content.tags,
link_to_upstream=link_to_upstream,
)
# Now handle static files that need to go into Files & Uploads:
notices = _import_files_into_course(
Expand All @@ -318,8 +315,6 @@ def _import_xml_node_to_parent(
copied_from_block: str | None = None,
# Content tags applied to the source XBlock(s)
tags: dict[str, str] | None = None,
*,
link_to_upstream: bool = False,
) -> XBlock:
"""
Given an XML node representing a serialized XBlock (OLX), import it into modulestore 'store' as a child of the
Expand Down Expand Up @@ -385,15 +380,12 @@ def _import_xml_node_to_parent(
if copied_from_block:
# Store a reference to where this block was copied from, in the 'copied_from_block' field (AuthoringMixin)
temp_xblock.copied_from_block = copied_from_block
if copied_from_block and link_to_upstream:
if copied_from_block:
# If requested, link this block as a downstream of where it was copied from
temp_xblock.upstream = copied_from_block
try:
sync_from_upstream(temp_xblock, user, apply_updates=False)
except BadUpstream as exc:
log.exception(
"Pasting content with link_to_upstream=True, but copied content is not a valid upstream. Will not link."
)
temp_xblock.upstream = None

# Save the XBlock into modulestore. We need to save the block and its parent for this to work:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ def _create_block(request):
created_xblock, notices = import_staged_content_from_user_clipboard(
parent_key=usage_key,
request=request,
link_to_upstream=request.json.get("link_to_upstream"),
)
except Exception: # pylint: disable=broad-except
log.exception(
Expand Down

0 comments on commit e23072b

Please sign in to comment.