Skip to content

Commit

Permalink
feat!: Switch v2 libraries to Learning Core data models (#34066)
Browse files Browse the repository at this point in the history
This moves the Content Libraries V2 backend from Blockstore [1] over to
Learning Core [2] For high-level overview and rationale of this move, see
the Blockstore DEPR [3]. There are several follow-up tasks [4], most notably
adding support for static assets in libraries.

BREAKING CHANGE: Existing V2 libraries, backed by Blockstore, will stop
working. They will continue to be listed in Studio, but their content
will be unavailable. They need to be deleted (via Django admin) or manually
migrated to Learning Core. We do not expect production sites to be in
this situation, as the feature has never left "experimental" status.

[1] https://github.com/openedx-unsupported/blockstore
[2] https://github.com/openedx/openedx-learning/
[3] openedx/public-engineering#238
[4] #34283
  • Loading branch information
ormsbee authored Feb 22, 2024
1 parent 65ea55c commit 86f1e5e
Show file tree
Hide file tree
Showing 38 changed files with 1,208 additions and 3,005 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ def find_orgslug_libraryid_pairs() -> Set[Tuple[str, str]]:
Note that this only considers "version 1" (aka "legacy" or "modulestore-based")
content libraries.
We do not consider "version 2" (aka "blockstore-based") content libraries,
because those require a database-level link to their authoring organization,
and thus would not need backfilling via this command.
We do not consider "version 2" content libraries, because those require a
database-level link to their authoring organization, and thus would not need
backfilling via this command.
Returns: set[tuple[str, str]]
"""
Expand Down
5 changes: 2 additions & 3 deletions cms/djangoapps/contentstore/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,15 +922,14 @@ def _create_metadata(v1_library_key, collection_uuid):
library_license = '' # '' = ALL_RIGHTS_RESERVED
with atomic():
return v2contentlib_api.create_library(
collection,
library_type,
org,
slug,
title,
description,
allow_public_learning,
allow_public_read,
library_license
library_license,
library_type,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
APIs.
"""
import ddt
from django.test import LiveServerTestCase
from opaque_keys.edx.keys import UsageKey
from rest_framework.test import APIClient
from organizations.models import Organization
Expand All @@ -13,9 +12,7 @@
from xmodule.modulestore.tests.factories import BlockFactory, CourseFactory, ToyCourseFactory

from cms.djangoapps.contentstore.utils import reverse_usage_url
from openedx.core.lib.blockstore_api.tests.base import BlockstoreAppTestMixin
from openedx.core.djangoapps.content_libraries import api as library_api
from blockstore.apps import api as blockstore_api

CLIPBOARD_ENDPOINT = "/api/content-staging/v1/clipboard/"
XBLOCK_ENDPOINT = "/xblock/"
Expand Down Expand Up @@ -214,7 +211,7 @@ def test_paste_with_assets(self):
assert source_pic2_hash != dest_pic2_hash # Because there was a conflict, this file was unchanged.


class ClipboardLibraryContentPasteTestCase(BlockstoreAppTestMixin, LiveServerTestCase, ModuleStoreTestCase):
class ClipboardLibraryContentPasteTestCase(ModuleStoreTestCase):
"""
Test Clipboard Paste functionality with library content
"""
Expand All @@ -229,7 +226,6 @@ def setUp(self):
self.store = modulestore()
# Create a content library:
library = library_api.create_library(
collection_uuid=blockstore_api.create_collection("Collection").uuid,
library_type=library_api.COMPLEX,
org=Organization.objects.create(name="Test Org", short_name="CL-TEST"),
slug="lib",
Expand Down
6 changes: 6 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,13 @@

# alternative swagger generator for CMS API
'drf_spectacular',

'openedx_events',

# Learning Core Apps, used by v2 content libraries (content_libraries app)
"openedx_learning.core.components",
"openedx_learning.core.contents",
"openedx_learning.core.publishing",
]


Expand Down
8 changes: 7 additions & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
# and throws spurious errors. Therefore, we disable invalid-name checking.
# pylint: disable=invalid-name


import importlib.util
import sys
import os
Expand Down Expand Up @@ -3343,9 +3342,16 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring

# Notifications
'openedx.core.djangoapps.notifications',

'openedx_events',

# Learning Core Apps, used by v2 content libraries (content_libraries app)
"openedx_learning.core.components",
"openedx_learning.core.contents",
"openedx_learning.core.publishing",
]


######################### CSRF #########################################

# Forwards-compatibility with Django 1.7
Expand Down
5 changes: 2 additions & 3 deletions openedx/core/djangoapps/content_libraries/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ class ContentLibraryAdmin(admin.ModelAdmin):
"library_key",
"org",
"slug",
"bundle_uuid",
"allow_public_learning",
"allow_public_read",
"authorized_lti_configs",
)
list_display = ("slug", "org", "bundle_uuid")
list_display = ("slug", "org",)
inlines = (ContentLibraryPermissionInline, )

def get_readonly_fields(self, request, obj=None):
"""
Ensure that 'slug' and 'uuid' cannot be edited after creation.
"""
if obj:
return ["library_key", "org", "slug", "bundle_uuid"]
return ["library_key", "org", "slug"]
else:
return ["library_key", ]
Loading

0 comments on commit 86f1e5e

Please sign in to comment.