Skip to content

Commit

Permalink
temp: switch downstream_customized from Set to List
Browse files Browse the repository at this point in the history
TODO details

FAILED xmodule/tests/test_library_tools.py::ContentLibraryToolsTest::test_update_children_for_v2_lib -
bson.errors.InvalidDocument: cannot encode object: {'display_name'}, of type: <class 'set'>
  • Loading branch information
kdmccormick committed Sep 23, 2024
1 parent cfab256 commit 3d64e0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cms/lib/xblock/test/test_upstream_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_sync_to_unmodified_content(self):
"""
downstream = self.store.get_item(self.downstream_key)
assert downstream.upstream_display_name == "original upstream title"
assert downstream.downstream_customized == set()
assert downstream.downstream_customized == []
assert downstream.display_name == "original upstream title"
assert downstream.data == "\n<p>original upstream content</p>\n" # @@TODO newlines??

Expand All @@ -75,7 +75,7 @@ def test_sync_to_unmodified_content(self):

self.sync_service.sync_from_upstream(downstream, apply_updates=True)
assert downstream.upstream_display_name == "NEW upstream title"
assert downstream.downstream_customized == set()
assert downstream.downstream_customized == []
assert downstream.display_name == "NEW upstream title"
assert downstream.data == "\n<p>NEW upstream content</p>\n" # @@TODO newlines??

Expand All @@ -95,6 +95,6 @@ def test_sync_to_modified_contenet(self):

self.sync_service.sync_from_upstream(downstream, apply_updates=True)
assert downstream.upstream_display_name == "NEW upstream title"
assert downstream.downstream_customized == {"display_name"}
assert downstream.downstream_customized == ["display_name"]
assert downstream.display_name == "downstream OVERRIDE of the title"
assert downstream.data == "\n<p>NEW upstream content</p>\n" # @@TODO newlines??
8 changes: 4 additions & 4 deletions cms/lib/xblock/upstream_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from opaque_keys.edx.locator import LibraryUsageLocatorV2
from rest_framework.exceptions import NotFound
from xblock.exceptions import XBlockNotFoundError
from xblock.fields import Scope, String, Integer, Set
from xblock.fields import Scope, String, Integer, List
from xblock.core import XBlockMixin, XBlock

import openedx.core.djangoapps.xblock.api as xblock_api
Expand Down Expand Up @@ -168,13 +168,13 @@ class UpstreamSyncMixin(XBlockMixin):
),
default=None, scope=Scope.settings, hidden=True, enforce_type=True,
)
downstream_customized = Set(
downstream_customized = List(
help=(
"Names of the fields which have values set on the upstream block yet have been explicitly "
"overridden on this downstream block. Unless explicitly cleared by the user, these customizations "
"will persist even when updates are synced from the upstream."
),
default=set(), scope=Scope.settings, hidden=True, enforce_type=True,
default=[], scope=Scope.settings, hidden=True, enforce_type=True,
)

# Store upstream defaults for customizable fields.
Expand Down Expand Up @@ -214,7 +214,7 @@ def save(self, *args, **kwargs):
# If this field's value doesn't match the synced upstream value, then mark the field
# as customized so that we don't clobber it later when syncing.
if getattr(self, field_name) != getattr(self, restore_field_name):
self.downstream_customized.add(field_name)
self.downstream_customized.append(field_name)

super().save(*args, **kwargs)

Expand Down

0 comments on commit 3d64e0d

Please sign in to comment.