Fix assignment creation in dummy data
This commit is contained in:
parent
cb1a6fda19
commit
17e061892a
|
|
@ -4,6 +4,7 @@ import factory
|
|||
import wagtail_factories
|
||||
from django.contrib.auth import get_user_model
|
||||
from factory import CREATE_STRATEGY
|
||||
from wagtail.core import blocks
|
||||
from wagtail.core.models import Page
|
||||
from wagtail.core.rich_text import RichText
|
||||
|
||||
|
|
@ -96,6 +97,17 @@ class AssignmentBlockFactory(wagtail_factories.StructBlockFactory):
|
|||
class Meta:
|
||||
model = AssignmentBlock
|
||||
|
||||
@classmethod
|
||||
def _build(cls, model_class, *args, **kwargs):
|
||||
block = model_class()
|
||||
return blocks.StructValue(
|
||||
block,
|
||||
# todo: build in a more generic fashion
|
||||
[
|
||||
(name, kwargs['assignment']) for name, child_block in block.child_blocks.items()
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class VideoBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
url = factory.LazyAttribute(lambda x: 'https://www.youtube.com/watch?v=lO9d-AJai8Q')
|
||||
|
|
@ -139,7 +151,7 @@ class ContentBlockFactory(BasePageFactory):
|
|||
owner=user,
|
||||
module=module
|
||||
)
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, 'assignment_id')] = assignment.id
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, 'assignment')] = assignment
|
||||
|
||||
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -49,6 +49,19 @@ module_1_chapter_1 = {
|
|||
'title': '1.1 Lehrbeginn',
|
||||
'description': 'Wie sieht Ihr Konsumverhalten aus?',
|
||||
'content_blocks': [
|
||||
{
|
||||
'type': 'normal',
|
||||
'title': 'Assignment',
|
||||
'contents': [
|
||||
{
|
||||
'type': 'assignment',
|
||||
'value': {
|
||||
'assignment': 'Ein Auftrag',
|
||||
'title': 'Ein Auftragstitel'
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'type': 'task',
|
||||
'title': 'Auftrag 1',
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ class RoomsQuery(object):
|
|||
|
||||
|
||||
class ModuleRoomsQuery(object):
|
||||
|
||||
module_room = graphene.Field(RoomNode, slug=graphene.String(), class_id=graphene.ID())
|
||||
|
||||
def resolve_module_room(self, info, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in New Issue