Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds Library Content button to Studio Unit page [FC-0062] #35670

Prev Previous commit
Next Next commit
fix: remove unused code
navinkarkera committed Oct 19, 2024
commit 3ca4afd5db2f4528b98990218e990995202bb99a
37 changes: 1 addition & 36 deletions cms/djangoapps/contentstore/helpers.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
from django.contrib.auth import get_user_model
from django.utils.translation import gettext as _
from opaque_keys.edx.keys import AssetKey, CourseKey, UsageKey
from opaque_keys.edx.locator import DefinitionLocator, LibraryUsageLocatorV2, LocalId
from opaque_keys.edx.locator import DefinitionLocator, LocalId
from xblock.core import XBlock
from xblock.fields import ScopeIds
from xblock.runtime import IdGenerator
@@ -305,41 +305,6 @@ def import_staged_content_from_user_clipboard(parent_key: UsageKey, request) ->
return new_xblock, notices


def import_from_library_content(parent_key: UsageKey, content_key: LibraryUsageLocatorV2, request) -> XBlock:
"""
Import a block (along with its children) from a library content block.

Does not deal with permissions or REST stuff - do that before calling this.
"""

from cms.djangoapps.contentstore.views.preview import _load_preview_block
from openedx.core.djangoapps.content_libraries import api as library_api
from openedx.core.lib.xblock_serializer.api import serialize_xblock_to_olx
import openedx.core.djangoapps.xblock.api as xblock_api

library_component = library_api.get_library_block(content_key)
xblock = xblock_api.load_block(content_key, user=request.user)

xblock_data = serialize_xblock_to_olx(xblock)
node = etree.fromstring(xblock_data.olx_str)
store = modulestore()
with store.bulk_operations(parent_key.course_key):
parent_descriptor = store.get_item(parent_key)
# Some blocks like drag-and-drop only work here with the full XBlock runtime loaded:
parent_xblock = _load_preview_block(request, parent_descriptor)
new_xblock = _import_xml_node_to_parent(
node,
parent_xblock,
store,
user=request.user,
slug_hint=content_key.block_id,
copied_from_block=str(content_key),
copied_from_version_num=library_component.published_version_num,
tags=xblock_data.tags,
)
return new_xblock


def _import_xml_node_to_parent(
node,
parent_xblock: XBlock,
6 changes: 0 additions & 6 deletions cms/djangoapps/contentstore/views/component.py
Original file line number Diff line number Diff line change
@@ -464,12 +464,6 @@ def create_support_legend_dict():
if advanced_component_templates['templates']:
component_templates.insert(0, advanced_component_templates)

# component_templates.append({
# "type": "abc",
# "templates": "abc",
# "display_name": "ABC",
# "support_legend": create_support_legend_dict()
# })
return component_templates


Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
)
from edx_proctoring.exceptions import ProctoredExamNotFoundException
from help_tokens.core import HelpUrlExpert
from opaque_keys.edx.locator import LibraryUsageLocator, LibraryUsageLocatorV2
from opaque_keys.edx.locator import LibraryUsageLocator
from pytz import UTC
from xblock.core import XBlock
from xblock.fields import Scope
@@ -77,7 +77,6 @@
from .create_xblock import create_xblock
from .xblock_helpers import usage_key_with_run
from ..helpers import (
import_from_library_content,
get_parent_xblock,
import_staged_content_from_user_clipboard,
is_unit,