Implement ImageStreamField
This commit is contained in:
parent
1367a01ca7
commit
e9897911b3
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||
# Generated by Django 2.0.6 on 2018-09-04 13:55
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -12,8 +12,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('wagtailimages', '0021_image_file_hash'),
|
||||
('wagtailcore', '0040_page_draft_title'),
|
||||
('wagtailimages', '0021_image_file_hash'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ data = [
|
|||
'title': 'Ein neues Festival auf dem Gurten – und ich bin dabei!',
|
||||
'subtitle': 'Endlich war es soweit. Zum ersten Mal fand am 2. und 3. Juli 1977 das 1. Internationale …',
|
||||
'contents': [
|
||||
# {
|
||||
# 'type': 'image_block',
|
||||
# 'value': {
|
||||
# 'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||
# # 'image': 'https://picsum.photos/200/300/?random',
|
||||
# }
|
||||
# },
|
||||
{
|
||||
'type': 'image_url',
|
||||
'value': {
|
||||
'title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
'url': 'https://picsum.photos/200/300/?random'
|
||||
}
|
||||
},
|
||||
{
|
||||
'type': 'text_block',
|
||||
'value': {
|
||||
|
|
@ -47,13 +47,13 @@ data = [
|
|||
'title': 'Mein Tagesblog',
|
||||
'subtitle': 'https://blogger.com/cruel-festivals-around-the-world/',
|
||||
'contents': [
|
||||
# {
|
||||
# 'type': 'image_block',
|
||||
# 'value': {
|
||||
# 'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||
# # 'image': 'https://picsum.photos/200/300/?random',
|
||||
# }
|
||||
# },
|
||||
{
|
||||
'type': 'image_url',
|
||||
'value': {
|
||||
'title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
'url': 'https://picsum.photos/200/300/?random'
|
||||
}
|
||||
},
|
||||
{
|
||||
'type': 'text_block',
|
||||
'value': {
|
||||
|
|
@ -73,13 +73,13 @@ data = [
|
|||
'title': 'Woodstock',
|
||||
'subtitle': 'In Woodstock hat sich dem Mythos nach vor genau vierzig Jahren das Lebensgefühl …',
|
||||
'contents': [
|
||||
# {
|
||||
# 'type': 'image_block',
|
||||
# 'value': {
|
||||
# 'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||
# # 'image': 'https://picsum.photos/200/300/?random',
|
||||
# }
|
||||
# },
|
||||
{
|
||||
'type': 'image_url',
|
||||
'value': {
|
||||
'title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
'url': 'https://picsum.photos/200/300/?random'
|
||||
}
|
||||
},
|
||||
{
|
||||
'type': 'text_block',
|
||||
'value': {
|
||||
|
|
@ -99,13 +99,13 @@ data = [
|
|||
'title': 'Das Festival',
|
||||
'subtitle': 'www.meinblog.ch',
|
||||
'contents': [
|
||||
# {
|
||||
# 'type': 'image_block',
|
||||
# 'value': {
|
||||
# 'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||
# # 'image': 'https://picsum.photos/200/300/?random',
|
||||
# }
|
||||
# },
|
||||
{
|
||||
'type': 'image_url',
|
||||
'value': {
|
||||
'title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
'url': 'https://picsum.photos/200/300/?random'
|
||||
}
|
||||
},
|
||||
{
|
||||
'type': 'text_block',
|
||||
'value': {
|
||||
|
|
@ -131,13 +131,13 @@ data = [
|
|||
'title': 'Ich heisse Jan und habe am 01. August 2017 meine Ausbildung begonnen. Pünktlich zum …',
|
||||
'subtitle': '',
|
||||
'contents': [
|
||||
# {
|
||||
# 'type': 'image_block',
|
||||
# 'value': {
|
||||
# 'image__title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
# 'path': 'https://picsum.photos/200/300/?random',
|
||||
# }
|
||||
# },
|
||||
{
|
||||
'type': 'image_url',
|
||||
'value': {
|
||||
'title': 'Ein Bild sagt mehr als 1000 Worte',
|
||||
'url': 'https://picsum.photos/200/300/?random'
|
||||
}
|
||||
},
|
||||
{
|
||||
'type': 'text_block',
|
||||
'value': {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||
# Generated by Django 2.0.6 on 2018-09-04 13:55
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||
# Generated by Django 2.0.6 on 2018-09-04 13:55
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
|
@ -10,9 +10,9 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('book', '0001_initial'),
|
||||
('objectives', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -7,7 +7,7 @@ from factory import CREATE_STRATEGY
|
|||
from wagtail.core.rich_text import RichText
|
||||
|
||||
from book.blocks import ImageUrlBlock
|
||||
from book.factories import TextBlockFactory
|
||||
from book.factories import TextBlockFactory, BasicKnowledgeBlockFactory, ImageUrlBlockBlockFactory
|
||||
from core.factories import fake, fake_paragraph
|
||||
from rooms.models import Room, RoomEntry
|
||||
from user.models import UserGroup
|
||||
|
|
@ -36,7 +36,7 @@ class RoomEntryFactory(factory.django.DjangoModelFactory):
|
|||
|
||||
contents = wagtail_factories.StreamFieldFactory({
|
||||
'text_block': TextBlockFactory,
|
||||
'image_url': ImageUrlBlock,
|
||||
'image_url': ImageUrlBlockBlockFactory,
|
||||
'image_block': wagtail_factories.ImageChooserBlockFactory
|
||||
})
|
||||
|
||||
|
|
@ -47,15 +47,16 @@ class RoomEntryFactory(factory.django.DjangoModelFactory):
|
|||
value = resource['value']
|
||||
for jdx, field in enumerate(value):
|
||||
block_type = resource['type']
|
||||
|
||||
if block_type == 'text_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(value[field])
|
||||
|
||||
# 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])
|
||||
#
|
||||
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':
|
||||
|
|
@ -69,8 +70,9 @@ class RoomEntryFactory(factory.django.DjangoModelFactory):
|
|||
block_type = random.choice(block_types)
|
||||
if block_type == 'text_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'text_block', 'text')] = RichText(fake_paragraph())
|
||||
elif block_type == 'image_block':
|
||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'image_block', 'image__title')] = fake_paragraph()
|
||||
|
||||
# elif block_type == 'image_block':
|
||||
# kwargs['{}__{}__{}__{}'.format(stream_field_name, i, 'image_block', 'image__title')] = fake_paragraph()
|
||||
|
||||
@classmethod
|
||||
def create(cls, **kwargs):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||
# Generated by Django 2.0.6 on 2018-09-04 13:55
|
||||
|
||||
from django.db import migrations, models
|
||||
import django_extensions.db.fields
|
||||
|
|
@ -37,7 +37,7 @@ class Migration(migrations.Migration):
|
|||
('description', models.TextField(blank=True, null=True, verbose_name='description')),
|
||||
('slug', django_extensions.db.fields.AutoSlugField(blank=True, editable=False, populate_from='title', verbose_name='slug')),
|
||||
('subtitle', models.CharField(blank=True, max_length=255)),
|
||||
('contents', wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='doc-full')), ('image_block', wagtail.images.blocks.ImageChooserBlock(icon='image'))], blank=True, null=True)),
|
||||
('contents', wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='doc-full')), ('image_url', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.RichTextBlock()), ('url', wagtail.core.blocks.URLBlock())], icon='image')), ('image_block', wagtail.images.blocks.ImageChooserBlock(icon='image'))], blank=True, null=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Raumeintrag',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||
# Generated by Django 2.0.6 on 2018-09-04 13:55
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
|
@ -10,9 +10,9 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('user', '0001_initial'),
|
||||
('rooms', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('user', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -4,6 +4,7 @@ from django_extensions.db.models import TitleDescriptionModel, TitleSlugDescript
|
|||
from wagtail.core.fields import StreamField
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from book.blocks import ImageUrlBlock, BasicKnowledgeBlock
|
||||
from book.models import ContentBlock, TextBlock
|
||||
from user.models import UserGroup
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ class RoomEntry(TitleSlugDescriptionModel):
|
|||
|
||||
contents = StreamField([
|
||||
('text_block', TextBlock(icon='doc-full')),
|
||||
('image_url', ImageUrlBlock(icon='image')),
|
||||
('image_block', ImageChooserBlock(icon='image'))
|
||||
], null=True, blank=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||
# Generated by Django 2.0.6 on 2018-09-04 13:55
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.auth.models
|
||||
|
|
|
|||
Loading…
Reference in New Issue