@@ -3,7 +3,7 @@ from pkg_resources import resource_string
|
||||
from xmodule.x_module import XModule
|
||||
from xmodule.raw_module import RawDescriptor
|
||||
from xmodule.editing_module import MetadataOnlyEditingDescriptor
|
||||
from xblock.fields import String, Scope
|
||||
from xblock.fields import String, Scope, UNIQUE_ID
|
||||
from uuid import uuid4
|
||||
|
||||
# Make '_' a no-op so we can scrape strings
|
||||
@@ -15,7 +15,7 @@ class DiscussionFields(object):
|
||||
display_name=_("Discussion Id"),
|
||||
help=_("The id is a unique identifier for the discussion. It is non editable."),
|
||||
scope=Scope.settings,
|
||||
default="$$GUID$$")
|
||||
default=UNIQUE_ID)
|
||||
display_name = String(
|
||||
display_name=_("Display Name"),
|
||||
help=_("Display name for this module"),
|
||||
@@ -73,13 +73,6 @@ class DiscussionModule(DiscussionFields, XModule):
|
||||
|
||||
class DiscussionDescriptor(DiscussionFields, MetadataOnlyEditingDescriptor, RawDescriptor):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DiscussionDescriptor, self).__init__(*args, **kwargs)
|
||||
# is this too late? i.e., will it get persisted and stay static w/ the first value
|
||||
# any code references. I believe so.
|
||||
if self.discussion_id == '$$GUID$$':
|
||||
self.discussion_id = uuid4().hex
|
||||
|
||||
module_class = DiscussionModule
|
||||
# The discussion XML format uses `id` and `for` attributes,
|
||||
# but these would overload other module attributes, so we prefix them
|
||||
|
||||
@@ -8,7 +8,7 @@ import uuid
|
||||
import mock
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
from xblock.fields import Reference, ReferenceList, ReferenceValueDict
|
||||
from xblock.fields import Reference, ReferenceList, ReferenceValueDict, UNIQUE_ID
|
||||
from xmodule.modulestore.split_migrator import SplitMigrator
|
||||
from xmodule.modulestore.tests.test_split_w_old_mongo import SplitWMongoCourseBoostrapper
|
||||
|
||||
@@ -164,7 +164,14 @@ class TestMigration(SplitWMongoCourseBoostrapper):
|
||||
self.assertEqual(presplit_dag_root.location.block_id, split_dag_root.location.block_id)
|
||||
# compare all fields but references
|
||||
for name, field in presplit_dag_root.fields.iteritems():
|
||||
if not isinstance(field, (Reference, ReferenceList, ReferenceValueDict)):
|
||||
# fields generated from UNIQUE_IDs are unique to an XBlock's scope,
|
||||
# so if such a field is unset on an XBlock, we don't expect it
|
||||
# to persist across courses
|
||||
field_generated_from_unique_id = not field.is_set_on(presplit_dag_root) and field.default == UNIQUE_ID
|
||||
should_check_field = not (
|
||||
field_generated_from_unique_id or isinstance(field, (Reference, ReferenceList, ReferenceValueDict))
|
||||
)
|
||||
if should_check_field:
|
||||
self.assertEqual(
|
||||
getattr(presplit_dag_root, name),
|
||||
getattr(split_dag_root, name),
|
||||
|
||||
Reference in New Issue
Block a user