Fix assignment creation in dummy data
This commit is contained in:
parent
cb1a6fda19
commit
17e061892a
|
|
@ -4,6 +4,7 @@ import factory
|
||||||
import wagtail_factories
|
import wagtail_factories
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from factory import CREATE_STRATEGY
|
from factory import CREATE_STRATEGY
|
||||||
|
from wagtail.core import blocks
|
||||||
from wagtail.core.models import Page
|
from wagtail.core.models import Page
|
||||||
from wagtail.core.rich_text import RichText
|
from wagtail.core.rich_text import RichText
|
||||||
|
|
||||||
|
|
@ -96,6 +97,17 @@ class AssignmentBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AssignmentBlock
|
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):
|
class VideoBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
url = factory.LazyAttribute(lambda x: 'https://www.youtube.com/watch?v=lO9d-AJai8Q')
|
url = factory.LazyAttribute(lambda x: 'https://www.youtube.com/watch?v=lO9d-AJai8Q')
|
||||||
|
|
@ -139,7 +151,7 @@ class ContentBlockFactory(BasePageFactory):
|
||||||
owner=user,
|
owner=user,
|
||||||
module=module
|
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:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,19 @@ module_1_chapter_1 = {
|
||||||
'title': '1.1 Lehrbeginn',
|
'title': '1.1 Lehrbeginn',
|
||||||
'description': 'Wie sieht Ihr Konsumverhalten aus?',
|
'description': 'Wie sieht Ihr Konsumverhalten aus?',
|
||||||
'content_blocks': [
|
'content_blocks': [
|
||||||
|
{
|
||||||
|
'type': 'normal',
|
||||||
|
'title': 'Assignment',
|
||||||
|
'contents': [
|
||||||
|
{
|
||||||
|
'type': 'assignment',
|
||||||
|
'value': {
|
||||||
|
'assignment': 'Ein Auftrag',
|
||||||
|
'title': 'Ein Auftragstitel'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'type': 'task',
|
'type': 'task',
|
||||||
'title': 'Auftrag 1',
|
'title': 'Auftrag 1',
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ class RoomsQuery(object):
|
||||||
|
|
||||||
|
|
||||||
class ModuleRoomsQuery(object):
|
class ModuleRoomsQuery(object):
|
||||||
|
|
||||||
module_room = graphene.Field(RoomNode, slug=graphene.String(), class_id=graphene.ID())
|
module_room = graphene.Field(RoomNode, slug=graphene.String(), class_id=graphene.ID())
|
||||||
|
|
||||||
def resolve_module_room(self, info, **kwargs):
|
def resolve_module_room(self, info, **kwargs):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue