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

Switch v2 libraries to Learning Core data models #34066

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
eccfb0a
feat: convert v2 content libraries to use Learning Core models
ormsbee Oct 17, 2023
82d7a30
refactor: no need to spell out the app config when there's only one
ormsbee Feb 7, 2024
f79b3cd
chore: remove comment about libraries being blockstore-based
ormsbee Feb 7, 2024
21b7210
test: fix model tests for content_libraries
ormsbee Feb 7, 2024
8fd4718
test: remove unnecessary mixin layering of test; remove parent/child …
ormsbee Feb 7, 2024
ce2a10c
fix: fix the filtering test case (requires change from openedx-learning)
ormsbee Feb 7, 2024
d9ba5be
test: remove links-related tests (we no longer have them)
ormsbee Feb 7, 2024
952a3c3
test: remove tests regarding library-type conversion (we're no longer…
ormsbee Feb 7, 2024
a560c0c
test: more text patching
ormsbee Feb 7, 2024
cdb7a9f
fix: fix default xblock title behavior and adjust more tests
ormsbee Feb 8, 2024
5de9d46
fix: deleted blocks should 404 instead of 500
ormsbee Feb 8, 2024
3f6fcbc
feat!: remove blockstore lib import to learning core
ormsbee Feb 9, 2024
cbd3fe7
refactor: adjust openedx-learning usage to match 0.6.0 changes
ormsbee Feb 9, 2024
1583c25
test: fix content_tagging tests to remove blockstore collection use
ormsbee Feb 9, 2024
0b7ccac
test: remove test for v2 lib child block functionality (now unsupported)
ormsbee Feb 9, 2024
e0dca2a
test: remove blockstore usage from clipboard paste test
ormsbee Feb 9, 2024
7ce6bfc
fix: remove atomic decorator from views
ormsbee Feb 12, 2024
f52a332
refactor: shift library search logic from view to api
ormsbee Feb 12, 2024
51d69e5
fix: force content libraries views to be nonatomic
ormsbee Feb 13, 2024
cad1521
refactor: remove unnecessary imports
ormsbee Feb 13, 2024
706fa13
fix: have field data properly track changed fields (and simplify the …
ormsbee Feb 13, 2024
2168c5e
fix: remove error log that I was only using for debugging purposes
ormsbee Feb 13, 2024
78c8b48
refactor: cleanups, comments
ormsbee Feb 14, 2024
10ae9c5
refactor: more comment tweaks
ormsbee Feb 14, 2024
f96ef5f
refactor: more cleanup of config and removing debug comments
ormsbee Feb 14, 2024
c05ed88
refactor: more cleanup
ormsbee Feb 14, 2024
44af99a
refactor: remove unused imports
ormsbee Feb 14, 2024
cfe5a26
refactor: update comments
ormsbee Feb 14, 2024
6157bea
refactor: remove unnecessary atomic block
ormsbee Feb 14, 2024
1b6ebbe
refactor: add comments to api calls, remove unused function
ormsbee Feb 14, 2024
bb3cdfd
refactor: changes in response to Kyle's review
ormsbee Feb 14, 2024
3ba8479
refactor: consolidate get_component_from_usage_key implementations
ormsbee Feb 14, 2024
c4de68a
refactor: comment
ormsbee Feb 14, 2024
2cf37f7
refactor: remove get_block_display_name
ormsbee Feb 14, 2024
5cfbbd1
refactor: remove unnecessary config value for OPENEDX_LEARNING
ormsbee Feb 14, 2024
1eb2363
refactor: remove ENABLE_LIBRARY_AUTHORING_MICROFRONTEND from devstack…
ormsbee Feb 14, 2024
0baee71
fix: make schema migration more backwards-compatible
ormsbee Feb 14, 2024
746e0ee
fix: add LC models to keyword overrides (I'm checking now if this is …
ormsbee Feb 14, 2024
4e1205b
fix: address linter errors
ormsbee Feb 14, 2024
d5481bc
fix: more linter fixes
ormsbee Feb 14, 2024
cf1aed9
fix: more linter fixes
ormsbee Feb 14, 2024
e5e2a94
fix: all the linter things
ormsbee Feb 14, 2024
f2b3ac5
fix: spacing
ormsbee Feb 14, 2024
11e802f
fix: more linter fixes for indentation/spacing
ormsbee Feb 14, 2024
42670a0
fix: all the sytax linter stuff, I think...
ormsbee Feb 14, 2024
8c43d7c
fix: remove entries from db_keyword_overrides (no longer necessary)
ormsbee Feb 15, 2024
2ef2652
chore: mypy thinks it's a BaseManager and not a ContentLibraryManager
ormsbee Feb 15, 2024
53f0a33
fix: skip the libraries test cases under LMS (signals won't get sent)
ormsbee Feb 15, 2024
0f36be2
refactor: re-order skip and ddt decorators in case that makes any dif…
ormsbee Feb 15, 2024
8c19357
refactor: address some minor review comments
kdmccormick Feb 16, 2024
1582c30
refactor: get_library_block_olx -> get_block_draft_olx
kdmccormick Feb 16, 2024
21caa2e
test: use OpenEdxEventsTestMixin to fix content_libraries event testing
kdmccormick Feb 16, 2024
1787959
fix: raise a ValueError if block is set to OLX with the wrong XML tag
kdmccormick Feb 16, 2024
de72774
fix: wrap _create_component_for_block in a transaction
kdmccormick Feb 16, 2024
da3a49c
test: use non-ascii characters in library org, slug, and block id
kdmccormick Feb 16, 2024
0d8ecb1
refactor: don't import MediaType from models
kdmccormick Feb 16, 2024
12f138b
fix: fall back to type-defined block name if display_name missing
kdmccormick Feb 16, 2024
47cd922
fix: typo in get_block_display_name
kdmccormick Feb 20, 2024
2b95faf
test: fix non-ascii content_libraries tests
kdmccormick Feb 20, 2024
9ffa28d
refactor: component_already_exists -> _component_exists
kdmccormick Feb 21, 2024
60563aa
docs: add TODO comments - draft vs published, and deserialization
kdmccormick Feb 21, 2024
be1cacc
Merge remote-tracking branch 'upstream/master' into learning-core-lib…
kdmccormick Feb 21, 2024
3b48aa2
feat: allow non-ascii block ids
kdmccormick Feb 21, 2024
c4a2c5c
feat!: rm get_library_blocks
kdmccormick Feb 21, 2024
7f65299
Merge remote-tracking branch 'upstream/master' into learning-core-lib…
kdmccormick Feb 21, 2024
47756a5
fix: typo -- left something commented out while testing
kdmccormick Feb 21, 2024
76f8778
fix: `only` was conflicting with `select_related`
kdmccormick Feb 21, 2024
9829f60
fix: final review comments
kdmccormick Feb 21, 2024
4e3cdd4
Merge branch 'master' into learning-core-libs-readwrite-runtime
kdmccormick Feb 22, 2024
2932ae8
Merge branch 'master' into learning-core-libs-readwrite-runtime
kdmccormick Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading