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