Fix dummy_data
This commit is contained in:
parent
992b9945e5
commit
486a92a9a4
|
|
@ -258,11 +258,13 @@ class ContentBlockFactory(BasePageFactory):
|
|||
@classmethod
|
||||
def stream_field_magic(cls, module, kwargs, stream_field_name):
|
||||
user = get_user_model().objects.first()
|
||||
logger.debug(f"stream_field_name {stream_field_name}")
|
||||
logger.debug(kwargs)
|
||||
# logger.debug(f"stream_field_name {stream_field_name}")
|
||||
# logger.debug(kwargs)
|
||||
# if there already is something like `contents__0__text_block__text`, do nothing, as the whole block is already assumed to be defined
|
||||
if any(stream_field_name in s for s in kwargs.keys()):
|
||||
if any(f"{stream_field_name}__" in s for s in kwargs.keys()):
|
||||
logger.debug("doing nothing")
|
||||
logger.debug(kwargs.keys())
|
||||
logger.debug(kwargs["contents"])
|
||||
return
|
||||
if stream_field_name in kwargs:
|
||||
"""
|
||||
|
|
@ -283,6 +285,7 @@ class ContentBlockFactory(BasePageFactory):
|
|||
owner=user,
|
||||
module=module,
|
||||
)
|
||||
logger.debug("creating assignment")
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, idx, block_type, "assignment_id"
|
||||
|
|
@ -298,7 +301,7 @@ class ContentBlockFactory(BasePageFactory):
|
|||
)
|
||||
] = survey
|
||||
else:
|
||||
logger.debug("inner else")
|
||||
# logger.debug("inner else")
|
||||
for jdx, field in enumerate(value):
|
||||
if block_type == "text_block":
|
||||
kwargs[
|
||||
|
|
@ -342,7 +345,7 @@ class ContentBlockFactory(BasePageFactory):
|
|||
logger.debug(f"deleting {stream_field_name}")
|
||||
del kwargs[stream_field_name]
|
||||
else: # random contents from generator
|
||||
logger.debug("outer else")
|
||||
# logger.debug("outer else")
|
||||
for i in range(0, random.randint(3, 7)):
|
||||
block_type = random.choice(block_types)
|
||||
if block_type == "text_block":
|
||||
|
|
@ -364,6 +367,7 @@ class ContentBlockFactory(BasePageFactory):
|
|||
owner=user,
|
||||
module=module,
|
||||
)
|
||||
logger.debug("randomly creating assignment")
|
||||
kwargs[
|
||||
"{}__{}__{}__{}".format(
|
||||
stream_field_name, i, "assignment_id", assignment
|
||||
|
|
@ -391,9 +395,9 @@ class ContentBlockFactory(BasePageFactory):
|
|||
|
||||
@classmethod
|
||||
def create(cls, module, **kwargs):
|
||||
logger.debug("before magic")
|
||||
logger.debug(kwargs)
|
||||
# logger.debug("before magic")
|
||||
# logger.debug(kwargs)
|
||||
cls.stream_field_magic(module, kwargs, "contents")
|
||||
logger.debug("after magic")
|
||||
logger.debug(kwargs)
|
||||
# logger.debug("after magic")
|
||||
# logger.debug(kwargs)
|
||||
return cls._generate(CREATE_STRATEGY, kwargs)
|
||||
|
|
|
|||
Loading…
Reference in New Issue