From f7a1a9d990f62fdfedcaf90863ed1d130dc6bf0f Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Sun, 19 Oct 2025 17:28:42 -0400 Subject: [PATCH] feat!: remove version from library serializer The ContentLibraryMetadata used to hold a version field that was meant to represent the version of the library as a whole. This is a holdover from v1 libraries, where all changes to the library resulted in a new version of the content, and that version indicator was used by courses to know whether or not an update was available. This maps poorly to Learning Core backed libraries for a number of reasons: 1. LC-backed libraries have Draft and Published branches, meaning that a global "version" may be ambiguous. 2. LC-backed libraries have things like tagging and collections, where modifications are explicitly *not* versioned at all, and do not show up in either the publish log or the draft change log. 3. Courses that borrow content from LC-backed libraries track versioning at the level of the individual thing being borrowed, e.g. a single Component. This is in keeping with the goal to have very large libraries with many small bits of content to search and use. This commit removes the notion of a Library-global version entirely for v2 (LC-backed) libraries. This does not affect legacy v1 libraries that are backed by ModuleStore. --- .../content_libraries/api/libraries.py | 19 ------------------- .../content_libraries/rest_api/serializers.py | 1 - .../tests/test_content_libraries.py | 1 - 3 files changed, 21 deletions(-) diff --git a/openedx/core/djangoapps/content_libraries/api/libraries.py b/openedx/core/djangoapps/content_libraries/api/libraries.py index 658c55a0e4..8ad0930660 100644 --- a/openedx/core/djangoapps/content_libraries/api/libraries.py +++ b/openedx/core/djangoapps/content_libraries/api/libraries.py @@ -289,7 +289,6 @@ def get_metadata(queryset: QuerySet[ContentLibrary], text_search: str | None = N key=lib.library_key, title=lib.learning_package.title if lib.learning_package else "", description="", - version=0, allow_public_learning=lib.allow_public_learning, allow_public_read=lib.allow_public_read, @@ -352,22 +351,6 @@ def get_library(library_key: LibraryLocatorV2) -> ContentLibraryMetadata: has_unpublished_deletes = authoring_api.get_entities_with_unpublished_deletes(learning_package.id) \ .exists() - # Learning Core doesn't really have a notion of a global version number,but - # we can sort of approximate it by using the primary key of the last publish - # log entry, in the sense that it will be a monotonically increasing - # integer, though there will be large gaps. We use 0 to denote that nothing - # has been done, since that will never be a valid value for a PublishLog pk. - # - # That being said, we should figure out if we really even want to keep a top - # level version indicator for the Library as a whole. In the v1 libs - # implemention, this served as a way to know whether or not there was an - # updated version of content that a course could pull in. But more recently, - # we've decided to do those version references at the level of the - # individual blocks being used, since a Learning Core backed library is - # intended to be referenced in multiple course locations and not 1:1 like v1 - # libraries. The top level version stays for now because LegacyLibraryContentBlock - # uses it, but that should hopefully change before the Redwood release. - version = 0 if last_publish_log is None else last_publish_log.pk published_by = "" if last_publish_log and last_publish_log.published_by: published_by = last_publish_log.published_by.username @@ -377,7 +360,6 @@ def get_library(library_key: LibraryLocatorV2) -> ContentLibraryMetadata: title=learning_package.title, description=learning_package.description, num_blocks=num_blocks, - version=version, last_published=None if last_publish_log is None else last_publish_log.published_at, published_by=published_by, last_draft_created=last_draft_created, @@ -454,7 +436,6 @@ def create_library( title=title, description=description, num_blocks=0, - version=0, last_published=None, allow_public_learning=ref.allow_public_learning, allow_public_read=ref.allow_public_read, diff --git a/openedx/core/djangoapps/content_libraries/rest_api/serializers.py b/openedx/core/djangoapps/content_libraries/rest_api/serializers.py index 3b4dba09a1..56b8963b71 100644 --- a/openedx/core/djangoapps/content_libraries/rest_api/serializers.py +++ b/openedx/core/djangoapps/content_libraries/rest_api/serializers.py @@ -38,7 +38,6 @@ class ContentLibraryMetadataSerializer(serializers.Serializer): title = serializers.CharField() description = serializers.CharField(allow_blank=True) num_blocks = serializers.IntegerField(read_only=True) - version = serializers.IntegerField(read_only=True) last_published = serializers.DateTimeField(format=DATETIME_FORMAT, read_only=True) published_by = serializers.CharField(read_only=True) last_draft_created = serializers.DateTimeField(format=DATETIME_FORMAT, read_only=True) diff --git a/openedx/core/djangoapps/content_libraries/tests/test_content_libraries.py b/openedx/core/djangoapps/content_libraries/tests/test_content_libraries.py index c465fdd03e..644104462d 100644 --- a/openedx/core/djangoapps/content_libraries/tests/test_content_libraries.py +++ b/openedx/core/djangoapps/content_libraries/tests/test_content_libraries.py @@ -69,7 +69,6 @@ class ContentLibrariesTestCase(ContentLibrariesRestApiTest): "slug": "téstlꜟط", "title": "A Tést Lꜟطrary", "description": "Just Téstꜟng", - "version": 0, "license": CC_4_BY, "has_unpublished_changes": False, "has_unpublished_deletes": False,