Subtitle not Description
This commit is contained in:
parent
a963111287
commit
ff9a07e187
|
|
@ -16,7 +16,7 @@ query RoomEntriesQuery($slug: String!) {
|
|||
id
|
||||
slug
|
||||
title
|
||||
description
|
||||
subtitle
|
||||
contents
|
||||
author {
|
||||
id
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ class BasicKnowledgeBlock(blocks.StructBlock):
|
|||
url = blocks.URLBlock()
|
||||
|
||||
|
||||
# 'image_url'
|
||||
class ImageUrlBlock(blocks.StructBlock):
|
||||
title = blocks.RichTextBlock()
|
||||
url = blocks.URLBlock()
|
||||
|
||||
|
||||
# 'student_entry'
|
||||
class StudentEntryBlock(blocks.StructBlock):
|
||||
task_text = blocks.RichTextBlock()
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import wagtail_factories
|
|||
from factory import CREATE_STRATEGY
|
||||
from wagtail.core.rich_text import RichText
|
||||
|
||||
from book.blocks import BasicKnowledgeBlock, StudentEntryBlock
|
||||
from book.blocks import BasicKnowledgeBlock, StudentEntryBlock, ImageUrlBlock
|
||||
from book.models import Book, Topic, Module, Chapter, ContentBlock, TextBlock
|
||||
from core.factories import BasePageFactory, fake, DummyImageFactory, fake_paragraph
|
||||
from core.factories import BasePageFactory, fake, DummyImageFactory, fake_paragraph, fake_title
|
||||
|
||||
|
||||
class BookFactory(BasePageFactory):
|
||||
|
|
@ -56,6 +56,14 @@ class BasicKnowledgeBlockFactory(wagtail_factories.StructBlockFactory):
|
|||
model = BasicKnowledgeBlock
|
||||
|
||||
|
||||
class ImageUrlBlockBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
title = fake_title()
|
||||
url = factory.LazyAttribute(lambda x: 'https://picsum.photos/200/300/?random')
|
||||
|
||||
class Meta:
|
||||
model = ImageUrlBlock
|
||||
|
||||
|
||||
class StudentEntryBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
|
||||
class Meta:
|
||||
|
|
@ -69,7 +77,6 @@ class ContentBlockFactory(BasePageFactory):
|
|||
class Meta:
|
||||
model = ContentBlock
|
||||
|
||||
# parent = factory.LazyAttribute(lambda x: Site.objects.get(is_default_site=True).root_page)
|
||||
type = factory.LazyAttribute(lambda x: random.choice(['plain', 'yellow', 'green', 'blue']))
|
||||
|
||||
contents = wagtail_factories.StreamFieldFactory({
|
||||
|
|
@ -93,9 +100,10 @@ class ContentBlockFactory(BasePageFactory):
|
|||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(value[field])
|
||||
elif block_type == 'image_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, 'image__title')] = fake_paragraph()
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'image_block', )] = fake_paragraph()
|
||||
#
|
||||
|
||||
# image file
|
||||
#
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'image_block', )] = fake_paragraph()
|
||||
|
||||
del kwargs[stream_field_name]
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ data = [
|
|||
'entries': [
|
||||
{
|
||||
'title': 'Ein neues Festival auf dem Gurten – und ich bin dabei!',
|
||||
'description': 'Endlich war es soweit. Zum ersten Mal fand am 2. und 3. Juli 1977 das 1. Internationale …',
|
||||
'subtitle': 'Endlich war es soweit. Zum ersten Mal fand am 2. und 3. Juli 1977 das 1. Internationale …',
|
||||
'contents': [
|
||||
{
|
||||
'type': 'image_block',
|
||||
|
|
@ -45,7 +45,7 @@ data = [
|
|||
},
|
||||
{
|
||||
'title': 'Mein Tagesblog',
|
||||
'description': 'https://blogger.com/cruel-festivals-around-the-world/',
|
||||
'subtitle': 'https://blogger.com/cruel-festivals-around-the-world/',
|
||||
'contents': [
|
||||
{
|
||||
'type': 'image_block',
|
||||
|
|
@ -71,7 +71,7 @@ data = [
|
|||
},
|
||||
{
|
||||
'title': 'Woodstock',
|
||||
'description': 'In Woodstock hat sich dem Mythos nach vor genau vierzig Jahren das Lebensgefühl …',
|
||||
'subtitle': 'In Woodstock hat sich dem Mythos nach vor genau vierzig Jahren das Lebensgefühl …',
|
||||
'contents': [
|
||||
{
|
||||
'type': 'image_block',
|
||||
|
|
@ -97,7 +97,7 @@ data = [
|
|||
},
|
||||
{
|
||||
'title': 'Das Festival',
|
||||
'description': 'www.meinblog.ch',
|
||||
'subtitle': 'www.meinblog.ch',
|
||||
'contents': [
|
||||
{
|
||||
'type': 'image_block',
|
||||
|
|
@ -129,13 +129,13 @@ data = [
|
|||
'entries': [
|
||||
{
|
||||
'title': 'Ich heisse Jan und habe am 01. August 2017 meine Ausbildung begonnen. Pünktlich zum …',
|
||||
'description': '',
|
||||
'subtitle': '',
|
||||
'contents': [
|
||||
{
|
||||
'type': 'image_block',
|
||||
'value': {
|
||||
'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||
# 'image': 'https://picsum.photos/200/300/?random',
|
||||
'image__title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
'path': 'https://picsum.photos/200/300/?random',
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -155,13 +155,13 @@ data = [
|
|||
},
|
||||
{
|
||||
'title': 'Mein Lehrbeginn',
|
||||
'description': 'Was war ich angespannt… und nervös. Das hat sich aber schnell gelegt.',
|
||||
'subtitle': 'Was war ich angespannt… und nervös. Das hat sich aber schnell gelegt.',
|
||||
'contents': [
|
||||
{
|
||||
'type': 'image_block',
|
||||
'type': 'image_url',
|
||||
'value': {
|
||||
'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||
# 'image': 'https://picsum.photos/200/300/?random',
|
||||
'title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
'url': 'https://picsum.photos/200/300/?random'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from django.contrib.auth import get_user_model
|
|||
from factory import CREATE_STRATEGY
|
||||
from wagtail.core.rich_text import RichText
|
||||
|
||||
from book.blocks import ImageUrlBlock
|
||||
from book.factories import TextBlockFactory
|
||||
from core.factories import fake, fake_paragraph
|
||||
from rooms.models import Room, RoomEntry
|
||||
|
|
@ -35,6 +36,7 @@ class RoomEntryFactory(factory.django.DjangoModelFactory):
|
|||
|
||||
contents = wagtail_factories.StreamFieldFactory({
|
||||
'text_block': TextBlockFactory,
|
||||
'image_url': ImageUrlBlock,
|
||||
'image_block': wagtail_factories.ImageChooserBlockFactory
|
||||
})
|
||||
|
||||
|
|
@ -47,9 +49,19 @@ class RoomEntryFactory(factory.django.DjangoModelFactory):
|
|||
block_type = resource['type']
|
||||
if block_type == 'text_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(value[field])
|
||||
elif block_type == 'image_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, 'image__title')] = fake_paragraph()
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'image_block', )] = fake_paragraph()
|
||||
|
||||
# if block_type == 'image_url':
|
||||
# if field == 'url':
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = value[field]
|
||||
# else:
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(value[field])
|
||||
#
|
||||
# elif block_type == 'image_block':
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, 'image__title')] = fake_paragraph()
|
||||
# if field == 'path':
|
||||
# field_value = value[field]
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, 'image__file')] = field_value
|
||||
# # kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'image_block', )] = fake_paragraph()
|
||||
|
||||
del kwargs[stream_field_name]
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in New Issue