Update instrument dummy data
This commit is contained in:
parent
795e5a9ea0
commit
cd2e5c953e
|
|
@ -9,6 +9,7 @@ from wagtail.core.models import Page
|
||||||
from wagtail.core.rich_text import RichText
|
from wagtail.core.rich_text import RichText
|
||||||
|
|
||||||
from assignments.models import Assignment
|
from assignments.models import Assignment
|
||||||
|
from basicknowledge.models import BasicKnowledge
|
||||||
from books.blocks import BasicKnowledgeBlock, ImageUrlBlock, LinkBlock, AssignmentBlock, VideoBlock
|
from books.blocks import BasicKnowledgeBlock, ImageUrlBlock, LinkBlock, AssignmentBlock, VideoBlock
|
||||||
from books.models import Book, Topic, Module, Chapter, ContentBlock, TextBlock
|
from books.models import Book, Topic, Module, Chapter, ContentBlock, TextBlock
|
||||||
from core.factories import BasePageFactory, fake, DummyImageFactory, fake_paragraph, fake_title
|
from core.factories import BasePageFactory, fake, DummyImageFactory, fake_paragraph, fake_title
|
||||||
|
|
@ -69,9 +70,17 @@ class TextBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
model = TextBlock
|
model = TextBlock
|
||||||
|
|
||||||
|
|
||||||
|
class InstrumentFactory(BasePageFactory):
|
||||||
|
title = factory.LazyAttribute(fake_title)
|
||||||
|
type = factory.Iterator([BasicKnowledge.LANGUAGE_COMMUNICATION, BasicKnowledge.SOCIETY, BasicKnowledge.INTERDISCIPLINARY])
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = BasicKnowledge
|
||||||
|
|
||||||
|
|
||||||
class BasicKnowledgeBlockFactory(wagtail_factories.StructBlockFactory):
|
class BasicKnowledgeBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
description = factory.LazyAttribute(fake_paragraph)
|
description = factory.LazyAttribute(fake_paragraph)
|
||||||
url = factory.LazyAttribute(lambda x: fake.uri())
|
basic_knowledge = factory.SubFactory(InstrumentFactory)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BasicKnowledgeBlock
|
model = BasicKnowledgeBlock
|
||||||
|
|
@ -139,6 +148,11 @@ class ContentBlockFactory(BasePageFactory):
|
||||||
@classmethod
|
@classmethod
|
||||||
def stream_field_magic(cls, module, kwargs, stream_field_name):
|
def stream_field_magic(cls, module, kwargs, stream_field_name):
|
||||||
if stream_field_name in kwargs:
|
if stream_field_name in kwargs:
|
||||||
|
"""
|
||||||
|
stream_field_name is most likely 'contents'
|
||||||
|
this means: if there is a property named contents, us the defined ones in this block.
|
||||||
|
otherwise, go into the other block and randomize the contents
|
||||||
|
"""
|
||||||
for idx, resource in enumerate(kwargs[stream_field_name]):
|
for idx, resource in enumerate(kwargs[stream_field_name]):
|
||||||
value = resource['value']
|
value = resource['value']
|
||||||
block_type = resource['type']
|
block_type = resource['type']
|
||||||
|
|
@ -181,7 +195,7 @@ class ContentBlockFactory(BasePageFactory):
|
||||||
'{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = value[field]
|
'{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = value[field]
|
||||||
|
|
||||||
del kwargs[stream_field_name]
|
del kwargs[stream_field_name]
|
||||||
else:
|
else: # random contents from generator
|
||||||
for i in range(0, random.randint(3, 7)):
|
for i in range(0, random.randint(3, 7)):
|
||||||
block_type = random.choice(block_types)
|
block_type = random.choice(block_types)
|
||||||
if block_type == 'text_block':
|
if block_type == 'text_block':
|
||||||
|
|
|
||||||
|
|
@ -663,6 +663,10 @@ modules = [
|
||||||
intro,
|
intro,
|
||||||
module_1,
|
module_1,
|
||||||
module_2,
|
module_2,
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
other_modules = [
|
||||||
module_3,
|
module_3,
|
||||||
module_4
|
module_4
|
||||||
]
|
]
|
||||||
|
|
@ -680,8 +684,8 @@ data = [
|
||||||
{
|
{
|
||||||
'order': 2,
|
'order': 2,
|
||||||
'title': 'Berufliche Grundbildung',
|
'title': 'Berufliche Grundbildung',
|
||||||
'teaser': 'Yada yada bla bla',
|
'teaser': 'Ein Teaser',
|
||||||
'modules': ''
|
'modules': other_modules
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue