Add contents to Room Entries, upgrade wagtail, reset migrations
This commit is contained in:
parent
160abd75be
commit
b28346d297
2
Pipfile
2
Pipfile
|
|
@ -24,7 +24,7 @@ django-extensions = "==1.9.8"
|
||||||
graphene-django = "==2.0.0"
|
graphene-django = "==2.0.0"
|
||||||
django-filter = "==2.0.0.dev1"
|
django-filter = "==2.0.0.dev1"
|
||||||
pillow = "==5.0.0"
|
pillow = "==5.0.0"
|
||||||
wagtail = "==2.2.1"
|
wagtail = "==2.2.2"
|
||||||
django-cors-headers = "==2.2.0"
|
django-cors-headers = "==2.2.0"
|
||||||
django-storages = "*"
|
django-storages = "*"
|
||||||
boto3 = "*"
|
boto3 = "*"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "0d48e033748d0c12a04cd38b966bbaca73413801dc5032abec628c5e4b259795"
|
"sha256": "0313ae3eba93a9c5712508539682881c11aeec5f240c2ba8832498f36d99a5b0"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
|
@ -33,25 +33,25 @@
|
||||||
},
|
},
|
||||||
"boto3": {
|
"boto3": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:ab9c7261fc30a99e3c3009ab599209001af311c94b8f6cb3b35ccd5369db07f8",
|
"sha256:03067dc8ac0b16cf7ef1e016a08135c82a75e330bdbddea970e4c60ea9e4f699",
|
||||||
"sha256:c8381411249716aaa9f64f98be4a96818004ebf80daa7673a3db07d021c46594"
|
"sha256:061595d40ea97e4aae8beb9a2eebfe7b1851f40c3c779529d43ad4f8abe5b3d7"
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==1.7.83"
|
"version": "==1.8.6"
|
||||||
},
|
},
|
||||||
"botocore": {
|
"botocore": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:aeb54fd5f9a01399593e77612e7cdcf53e90a7d623378225685e599b989792d6",
|
"sha256:bd85f6491207b632c76fc6ca3e74b5d75a48c7f06f68ae5e98e794e6be10bc06",
|
||||||
"sha256:ce14556d139fa0641ca7f1973ed68d19ba70691490f3840bd2c6d906e4a99fc8"
|
"sha256:dc28453285802c1a2db0be8085e99631394fd1e833265d53a4071ef8c7c2415a"
|
||||||
],
|
],
|
||||||
"version": "==1.10.83"
|
"version": "==1.11.6"
|
||||||
},
|
},
|
||||||
"certifi": {
|
"certifi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:4c1d68a1408dd090d2f3a869aa94c3947cc1d967821d1ed303208c9f41f0f2f4",
|
"sha256:376690d6f16d32f9d1fe8932551d80b23e9d393a8578c5633a2ed39a64861638",
|
||||||
"sha256:b6e8b28b2b7e771a41ecdd12d4d43262ecab52adebbafa42c77d6b57fb6ad3a4"
|
"sha256:456048c7e371c089d0a77a5212fb37a2c2dce1e24146e3b7e0261736aaeaa22a"
|
||||||
],
|
],
|
||||||
"version": "==2018.8.13"
|
"version": "==2018.8.24"
|
||||||
},
|
},
|
||||||
"chardet": {
|
"chardet": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
@ -136,11 +136,11 @@
|
||||||
},
|
},
|
||||||
"django-storages": {
|
"django-storages": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:7339070cf0c8042f5a885783a0a909175a8dbb68e7f5697d597571c830a460c4",
|
"sha256:9e0f3423cdf8fabe74c174380de6cd65b9343b5c83c08f35ace57213f17fb083",
|
||||||
"sha256:f1dd5668a4df9a23aff56c8321ea3aac3fda23d9d17473158d308d1b13e5363e"
|
"sha256:e021ae94c0ca39c683260fa0065cae0df041d795dd79fee8f7bf4ba31798640d"
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==1.6.6"
|
"version": "==1.7"
|
||||||
},
|
},
|
||||||
"django-taggit": {
|
"django-taggit": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
@ -455,11 +455,11 @@
|
||||||
},
|
},
|
||||||
"typing": {
|
"typing": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:3a887b021a77b292e151afb75323dea88a7bc1b3dfa92176cff8e44c8b68bddf",
|
"sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d",
|
||||||
"sha256:b2c689d54e1144bbcfd191b0832980a21c2dbcf7b5ff7a66248a60c90e951eb8",
|
"sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4",
|
||||||
"sha256:d400a9344254803a2368533e4533a4200d21eb7b6b729c173bc38201a74db3f2"
|
"sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a"
|
||||||
],
|
],
|
||||||
"version": "==3.6.4"
|
"version": "==3.6.6"
|
||||||
},
|
},
|
||||||
"unidecode": {
|
"unidecode": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
@ -477,11 +477,11 @@
|
||||||
},
|
},
|
||||||
"wagtail": {
|
"wagtail": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:27d27242bbc88b64d433702c409569408485b4dd9a352f938f3987a857929413",
|
"sha256:5813b303a2f7e82f614d2a1301c5bbe1c88c829ba16101b2f9dbf945ce6bf8f7",
|
||||||
"sha256:67b0fce3487e9dc2378e8ecdbc6ee8469d1baddcdf1061b35f41ad54ca98268d"
|
"sha256:ea3913bcab30ea22ab6914210f9612083c8702255a408059ae246eddd229cd49"
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==2.2.1"
|
"version": "==2.2.2"
|
||||||
},
|
},
|
||||||
"wagtail-factories": {
|
"wagtail-factories": {
|
||||||
"git": "https://github.com/mvantellingen/wagtail-factories.git",
|
"git": "https://github.com/mvantellingen/wagtail-factories.git",
|
||||||
|
|
@ -521,11 +521,11 @@
|
||||||
},
|
},
|
||||||
"awscli": {
|
"awscli": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:24e5491e1a54007588316230bdf925e8f176fdc3e7934b59540107f918857d58",
|
"sha256:5929010baf1dcaa443465906020df7a8b813390c04811eab29f85a48125f5e65",
|
||||||
"sha256:d325646ae1bd6669bae85407b4be2d4fbfeed7433a4b219e04dba1b94cb52c92"
|
"sha256:e6a55a8c41fa3c9fed8e3884126d1fa477a478eac5192befa464de12a267a33c"
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==1.15.84"
|
"version": "==1.16.6"
|
||||||
},
|
},
|
||||||
"backcall": {
|
"backcall": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
@ -536,10 +536,10 @@
|
||||||
},
|
},
|
||||||
"botocore": {
|
"botocore": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:aeb54fd5f9a01399593e77612e7cdcf53e90a7d623378225685e599b989792d6",
|
"sha256:bd85f6491207b632c76fc6ca3e74b5d75a48c7f06f68ae5e98e794e6be10bc06",
|
||||||
"sha256:ce14556d139fa0641ca7f1973ed68d19ba70691490f3840bd2c6d906e4a99fc8"
|
"sha256:dc28453285802c1a2db0be8085e99631394fd1e833265d53a4071ef8c7c2415a"
|
||||||
],
|
],
|
||||||
"version": "==1.10.83"
|
"version": "==1.11.6"
|
||||||
},
|
},
|
||||||
"colorama": {
|
"colorama": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|
@ -718,6 +718,13 @@
|
||||||
],
|
],
|
||||||
"version": "==4.3.2"
|
"version": "==4.3.2"
|
||||||
},
|
},
|
||||||
|
"urllib3": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
|
||||||
|
"sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"
|
||||||
|
],
|
||||||
|
"version": "==1.23"
|
||||||
|
},
|
||||||
"wcwidth": {
|
"wcwidth": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
|
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,6 @@ import random
|
||||||
|
|
||||||
import factory
|
import factory
|
||||||
import wagtail_factories
|
import wagtail_factories
|
||||||
|
|
||||||
from factory import CREATE_STRATEGY
|
from factory import CREATE_STRATEGY
|
||||||
from wagtail.core.rich_text import RichText
|
from wagtail.core.rich_text import RichText
|
||||||
|
|
||||||
|
|
@ -70,6 +69,7 @@ class ContentBlockFactory(BasePageFactory):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ContentBlock
|
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']))
|
type = factory.LazyAttribute(lambda x: random.choice(['plain', 'yellow', 'green', 'blue']))
|
||||||
|
|
||||||
contents = wagtail_factories.StreamFieldFactory({
|
contents = wagtail_factories.StreamFieldFactory({
|
||||||
|
|
@ -86,7 +86,17 @@ class ContentBlockFactory(BasePageFactory):
|
||||||
for idx, resource in enumerate(kwargs[stream_field_name]):
|
for idx, resource in enumerate(kwargs[stream_field_name]):
|
||||||
value = resource['value']
|
value = resource['value']
|
||||||
for jdx, field in enumerate(value):
|
for jdx, field in enumerate(value):
|
||||||
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, resource['type'], field)] = RichText(value[field])
|
block_type = resource['type']
|
||||||
|
if block_type == 'text_block':
|
||||||
|
kwargs['{}__{}__{}__{}'.format(stream_field_name, idx, block_type, field)] = RichText(value[field])
|
||||||
|
if block_type == 'task':
|
||||||
|
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
|
||||||
|
|
||||||
del kwargs[stream_field_name]
|
del kwargs[stream_field_name]
|
||||||
else:
|
else:
|
||||||
for i in range(0, random.randint(3, 7)):
|
for i in range(0, random.randint(3, 7)):
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-23 11:48
|
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ from wagtail.images import get_image_model
|
||||||
fake = Faker('de_DE')
|
fake = Faker('de_DE')
|
||||||
|
|
||||||
|
|
||||||
def fake_title(x=None):
|
def fake_title(x=None, min_words=2, max_words=4):
|
||||||
return fake.sentence(nb_words=random.randint(2, 4)).replace('.', '')
|
return fake.sentence(nb_words=random.randint(min_words, max_words)).replace('.', '')
|
||||||
|
|
||||||
|
|
||||||
def fake_paragraph(x=None):
|
def fake_paragraph(x=None):
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import shutil
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.core.management import BaseCommand
|
from django.core.management import BaseCommand
|
||||||
|
from wagtail.core.models import Site
|
||||||
|
|
||||||
from rooms.factories import RoomFactory, RoomEntryFactory
|
from rooms.factories import RoomFactory, RoomEntryFactory
|
||||||
from rooms.models import Room
|
from rooms.models import Room
|
||||||
|
|
@ -18,28 +19,108 @@ data = [
|
||||||
'entries': [
|
'entries': [
|
||||||
{
|
{
|
||||||
'title': 'Ein neues Festival auf dem Gurten – und ich bin dabei!',
|
'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 …'
|
'description': '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': 'text_block',
|
||||||
|
'value': {
|
||||||
|
'text': """<p>Das folgende Interview bezieht sich auf Jugendliche, die Ihre Lehre im Sommer begonnen haben. Lesen Sie das Interview durch und bearbeiten Sie anschliessend die Aufgaben.</p>
|
||||||
|
<p>Aufgaben zum Interview «Das ist ein ganz markanter Wechsel»</p>"""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'text_block',
|
||||||
|
'value': {
|
||||||
|
'text': '<p>Erklären Sie, welche Informationen den Leserinnen und Lesern in der Einleitung vermittelt werden.</p>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'title': 'Mein Tagesblog',
|
'title': 'Mein Tagesblog',
|
||||||
'description': 'https://blogger.com/cruel-festivals-around-the-world/'
|
'description': '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': 'text_block',
|
||||||
|
'value': {
|
||||||
|
'text': """<p>Das folgende Interview bezieht sich auf Jugendliche, die Ihre Lehre im Sommer begonnen haben. Lesen Sie das Interview durch und bearbeiten Sie anschliessend die Aufgaben.</p>
|
||||||
|
<p>Aufgaben zum Interview «Das ist ein ganz markanter Wechsel»</p>"""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'task',
|
||||||
|
'value': {
|
||||||
|
'text': '<p>Erklären Sie, welche Informationen den Leserinnen und Lesern in der Einleitung vermittelt werden.</p>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'title': 'Woodstock',
|
'title': 'Woodstock',
|
||||||
'description': 'In Woodstock hat sich dem Mythos nach vor genau vierzig Jahren das Lebensgefühl …'
|
'description': 'In Woodstock hat sich dem Mythos nach vor genau vierzig Jahren das Lebensgefühl …',
|
||||||
},
|
'contents': [
|
||||||
{
|
{
|
||||||
'title': 'Ein neues Festival auf dem Gurten – und ich bin dabei!',
|
'type': 'image_block',
|
||||||
'description': 'Endlich war es soweit. Zum ersten Mal fand am 2. und 3. Juli 1977 das 1. Internationale …'
|
'value': {
|
||||||
|
'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||||
|
# 'image': 'https://picsum.photos/200/300/?random',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'text_block',
|
||||||
|
'value': {
|
||||||
|
'text': """<p>Das folgende Interview bezieht sich auf Jugendliche, die Ihre Lehre im Sommer begonnen haben. Lesen Sie das Interview durch und bearbeiten Sie anschliessend die Aufgaben.</p>
|
||||||
|
<p>Aufgaben zum Interview «Das ist ein ganz markanter Wechsel»</p>"""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'task',
|
||||||
|
'value': {
|
||||||
|
'text': '<p>Erklären Sie, welche Informationen den Leserinnen und Lesern in der Einleitung vermittelt werden.</p>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'title': 'Das Festival',
|
'title': 'Das Festival',
|
||||||
'description': 'www.meinblog.ch'
|
'description': 'www.meinblog.ch',
|
||||||
},
|
'contents': [
|
||||||
{
|
{
|
||||||
'title': '',
|
'type': 'image_block',
|
||||||
'description': ''
|
'value': {
|
||||||
},
|
'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||||
|
# 'image': 'https://picsum.photos/200/300/?random',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'text_block',
|
||||||
|
'value': {
|
||||||
|
'text': """<p>Das folgende Interview bezieht sich auf Jugendliche, die Ihre Lehre im Sommer begonnen haben. Lesen Sie das Interview durch und bearbeiten Sie anschliessend die Aufgaben.</p>
|
||||||
|
<p>Aufgaben zum Interview «Das ist ein ganz markanter Wechsel»</p>"""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'task',
|
||||||
|
'value': {
|
||||||
|
'text': '<p>Erklären Sie, welche Informationen den Leserinnen und Lesern in der Einleitung vermittelt werden.</p>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -48,11 +129,55 @@ data = [
|
||||||
'entries': [
|
'entries': [
|
||||||
{
|
{
|
||||||
'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 …',
|
||||||
'description': ''
|
'description': '',
|
||||||
|
'contents': [
|
||||||
|
{
|
||||||
|
'type': 'image_block',
|
||||||
|
'value': {
|
||||||
|
'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||||
|
# 'image': 'https://picsum.photos/200/300/?random',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'text_block',
|
||||||
|
'value': {
|
||||||
|
'text': """<p>Das folgende Interview bezieht sich auf Jugendliche, die Ihre Lehre im Sommer begonnen haben. Lesen Sie das Interview durch und bearbeiten Sie anschliessend die Aufgaben.</p>
|
||||||
|
<p>Aufgaben zum Interview «Das ist ein ganz markanter Wechsel»</p>"""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'task',
|
||||||
|
'value': {
|
||||||
|
'text': '<p>Erklären Sie, welche Informationen den Leserinnen und Lesern in der Einleitung vermittelt werden.</p>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'title': 'Mein Lehrbeginn',
|
'title': 'Mein Lehrbeginn',
|
||||||
'description': 'Was war ich angespannt… und nervös. Das hat sich aber schnell gelegt.'
|
'description': 'Was war ich angespannt… und nervös. Das hat sich aber schnell gelegt.',
|
||||||
|
'contents': [
|
||||||
|
{
|
||||||
|
'type': 'image_block',
|
||||||
|
'value': {
|
||||||
|
'image__title': 'Ein Bild sagt mehr als 1000 Worte'
|
||||||
|
# 'image': 'https://picsum.photos/200/300/?random',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'text_block',
|
||||||
|
'value': {
|
||||||
|
'text': """<p>Das folgende Interview bezieht sich auf Jugendliche, die Ihre Lehre im Sommer begonnen haben. Lesen Sie das Interview durch und bearbeiten Sie anschliessend die Aufgaben.</p>
|
||||||
|
<p>Aufgaben zum Interview «Das ist ein ganz markanter Wechsel»</p>"""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'task',
|
||||||
|
'value': {
|
||||||
|
'text': '<p>Erklären Sie, welche Informationen den Leserinnen und Lesern in der Einleitung vermittelt werden.</p>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -77,22 +202,11 @@ class Command(BaseCommand):
|
||||||
return {k: v for (k, v) in input_data.items() if not (k in filters)}
|
return {k: v for (k, v) in input_data.items() if not (k in filters)}
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# self.ensure_clean_dir('images')
|
|
||||||
# self.ensure_clean_dir('original_images')
|
|
||||||
# self.ensure_clean_dir('documents')
|
|
||||||
#
|
|
||||||
# site = wagtail_factories.SiteFactory.create(is_default_site=True)
|
|
||||||
# Page.objects.filter(title='Root').delete()
|
|
||||||
#
|
|
||||||
# u = UserFactory(
|
|
||||||
# username='test',
|
|
||||||
# is_staff=True,
|
|
||||||
# is_superuser=True
|
|
||||||
# )
|
|
||||||
|
|
||||||
Room.objects.all().delete()
|
Room.objects.all().delete()
|
||||||
UserGroup.objects.all().delete()
|
UserGroup.objects.all().delete()
|
||||||
|
|
||||||
|
root_page = Site.objects.get(is_default_site=True).root_page
|
||||||
|
|
||||||
for i in range(0, 6):
|
for i in range(0, 6):
|
||||||
UserGroupFactory(users=(random.choices(get_user_model().objects.all(), k=3)))
|
UserGroupFactory(users=(random.choices(get_user_model().objects.all(), k=3)))
|
||||||
|
|
||||||
|
|
@ -102,48 +216,21 @@ class Command(BaseCommand):
|
||||||
default_room_entries = [{} for i in range(0, random.randint(5, 8))]
|
default_room_entries = [{} for i in range(0, random.randint(5, 8))]
|
||||||
room_entries = room_data.get('entries', default_room_entries)
|
room_entries = room_data.get('entries', default_room_entries)
|
||||||
|
|
||||||
for room_entry_idx, room_entry in enumerate(room_entries):
|
for room_entry_idx, room_entry_data in enumerate(room_entries):
|
||||||
RoomEntryFactory.create(room=room, **room_entry)
|
room_entry = RoomEntryFactory.create(room=room, **room_entry_data)
|
||||||
|
|
||||||
# for book_idx, book_data in enumerate(data):
|
# room_entry = RoomEntryFactory.create(room=room, **self.filter_data(room_entry_data, 'contents'))
|
||||||
# book = BookFactory.create(parent=site.root_page, **self.filter_data(book_data, 'topics'))
|
# if 'contents' in room_entry_data:
|
||||||
#
|
# # now create contents in a room entry
|
||||||
# default_topics = [{} for i in range(0, random.randint(5, 8))]
|
# content_block = ContentBlockFactory.create(
|
||||||
# topics_data = book_data.get('topics', default_topics)
|
# parent=root_page,
|
||||||
#
|
# title='{}_{}'.format(room_entry.title, fake_title(min_words=1, max_words=1)),
|
||||||
# for topic_idx, topic_data in enumerate(topics_data):
|
# # description=room_entry.description,
|
||||||
# topic = TopicFactory.create(parent=book, **self.filter_data(topic_data, 'modules'))
|
# contents=room_entry_data['contents']
|
||||||
#
|
# )
|
||||||
# default_modules = [{} for i in range(0, random.randint(3, 6))]
|
# room_entry.content = content_block
|
||||||
# modules_data = topic_data.get('modules', default_modules)
|
# room_entry.save()
|
||||||
#
|
|
||||||
# for module_idx, module_data in enumerate(modules_data):
|
# for content_block_idx, content_block_data in enumerate(content_blocks_data):
|
||||||
# module = ModuleFactory.create(parent=topic, **self.filter_data(module_data, ['objective_groups', 'chapters']))
|
# # ContentBlockFactory.create(parent=chapter, **self.filter_data(content_block_data, 'contents'))
|
||||||
#
|
# ContentBlockFactory.create(parent=chapter, **content_block_data)
|
||||||
# default_objective_groups = [{} for i in range(0, 2)]
|
|
||||||
# objective_group_data = module_data.get('objective_groups', default_objective_groups)
|
|
||||||
#
|
|
||||||
# for objective_group_idx, objective_group_entry in enumerate(objective_group_data):
|
|
||||||
# factory_params = self.filter_data(objective_group_entry, 'objectives')
|
|
||||||
# objective_group = ObjectiveGroupFactory.create(module=module,
|
|
||||||
# user=None,
|
|
||||||
# **factory_params)
|
|
||||||
#
|
|
||||||
# default_objectives = [{} for i in range(0, 4)]
|
|
||||||
# objectives_data = objective_group_entry.get('objectives', default_objectives)
|
|
||||||
#
|
|
||||||
# for objective_idx, objective_data in enumerate(objectives_data):
|
|
||||||
# objective = ObjectiveFactory.create(group=objective_group, **objective_data)
|
|
||||||
#
|
|
||||||
# default_chapters = [{} for i in range(0, 2)]
|
|
||||||
# chapters_data = module_data.get('chapters', default_chapters)
|
|
||||||
#
|
|
||||||
# for chapter_idx, chapter_data in enumerate(chapters_data):
|
|
||||||
# chapter = ChapterFactory.create(parent=module, **self.filter_data(chapter_data, 'content_blocks'))
|
|
||||||
#
|
|
||||||
# default_content_blocks = [{} for i in range(0, 4)]
|
|
||||||
# content_blocks_data = chapter_data.get('content_blocks', default_content_blocks)
|
|
||||||
#
|
|
||||||
# for content_block_idx, content_block_data in enumerate(content_blocks_data):
|
|
||||||
# # ContentBlockFactory.create(parent=chapter, **self.filter_data(content_block_data, 'contents'))
|
|
||||||
# ContentBlockFactory.create(parent=chapter, **content_block_data)
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ INSTALLED_APPS = [
|
||||||
'graphene_django',
|
'graphene_django',
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
'compressor',
|
'compressor',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-23 11:48
|
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||||
|
|
||||||
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-08-23 11:48
|
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||||
|
|
||||||
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 = [
|
||||||
|
|
@ -24,7 +24,7 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='objectivegroup',
|
model_name='objectivegroup',
|
||||||
name='module',
|
name='module',
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='book.Module'),
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='objective_groups', to='book.Module'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='objectivegroup',
|
model_name='objectivegroup',
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-27 16:17
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('objectives', '0002_auto_20180823_1148'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='objectivegroup',
|
|
||||||
name='module',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='objective_groups', to='book.Module'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import factory
|
import factory
|
||||||
|
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 wagtail.core.rich_text import RichText
|
||||||
|
|
||||||
from core.factories import fake
|
from book.factories import TextBlockFactory
|
||||||
|
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
|
||||||
|
|
||||||
|
|
@ -17,10 +21,46 @@ class RoomFactory(factory.django.DjangoModelFactory):
|
||||||
appearance = factory.LazyAttribute(lambda x: random.choice(['red', 'green', 'brown']))
|
appearance = factory.LazyAttribute(lambda x: random.choice(['red', 'green', 'brown']))
|
||||||
|
|
||||||
|
|
||||||
|
block_types = ['text_block', 'image_block']
|
||||||
|
|
||||||
|
|
||||||
class RoomEntryFactory(factory.django.DjangoModelFactory):
|
class RoomEntryFactory(factory.django.DjangoModelFactory):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RoomEntry
|
model = RoomEntry
|
||||||
|
|
||||||
title = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(8, 12)))
|
title = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(8, 12)))
|
||||||
|
subtitle = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(8, 12)))
|
||||||
description = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(20, 30)))
|
description = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(20, 30)))
|
||||||
author = factory.Iterator(get_user_model().objects.all())
|
author = factory.Iterator(get_user_model().objects.all())
|
||||||
|
|
||||||
|
contents = wagtail_factories.StreamFieldFactory({
|
||||||
|
'text_block': TextBlockFactory,
|
||||||
|
'image_block': wagtail_factories.ImageChooserBlockFactory
|
||||||
|
})
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stream_field_magic(cls, kwargs, stream_field_name):
|
||||||
|
if stream_field_name in kwargs:
|
||||||
|
for idx, resource in enumerate(kwargs[stream_field_name]):
|
||||||
|
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])
|
||||||
|
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()
|
||||||
|
|
||||||
|
del kwargs[stream_field_name]
|
||||||
|
else:
|
||||||
|
for i in range(0, random.randint(3, 7)):
|
||||||
|
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()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create(cls, **kwargs):
|
||||||
|
cls.stream_field_magic(kwargs, 'contents')
|
||||||
|
return cls._generate(CREATE_STRATEGY, kwargs)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-23 11:48
|
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django_extensions.db.fields
|
import django_extensions.db.fields
|
||||||
|
import wagtail.core.blocks
|
||||||
|
import wagtail.core.fields
|
||||||
|
import wagtail.images.blocks
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
@ -26,4 +29,19 @@ class Migration(migrations.Migration):
|
||||||
'verbose_name_plural': 'Räume',
|
'verbose_name_plural': 'Räume',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='RoomEntry',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=255, verbose_name='title')),
|
||||||
|
('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)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Raumeintrag',
|
||||||
|
'verbose_name_plural': 'Raumeinträge',
|
||||||
|
},
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('user', '0001_initial'),
|
||||||
|
('rooms', '0001_initial'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='roomentry',
|
||||||
|
name='author',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='roomentry',
|
||||||
|
name='room',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='room_entries', to='rooms.Room'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='room',
|
||||||
|
name='user_group',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.UserGroup'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-23 11:48
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
initial = True
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('rooms', '0001_initial'),
|
|
||||||
('user', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='room',
|
|
||||||
name='user_group',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.UserGroup'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-23 13:25
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
import django_extensions.db.fields
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
('rooms', '0002_room_user_group'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='RoomEntry',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('title', models.CharField(max_length=255, verbose_name='title')),
|
|
||||||
('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')),
|
|
||||||
('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
||||||
('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rooms.Room')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'abstract': False,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-23 13:36
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('rooms', '0003_roomentry'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterModelOptions(
|
|
||||||
name='roomentry',
|
|
||||||
options={'verbose_name': 'Raumeintrag', 'verbose_name_plural': 'Raumeinträge'},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-27 16:02
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('rooms', '0004_auto_20180823_1336'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='roomentry',
|
|
||||||
name='room',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='room_entries', to='rooms.Room'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django_extensions.db.models import TitleDescriptionModel, TitleSlugDescriptionModel
|
from django_extensions.db.models import TitleDescriptionModel, TitleSlugDescriptionModel
|
||||||
|
from wagtail.core.fields import StreamField
|
||||||
|
from wagtail.images.blocks import ImageChooserBlock
|
||||||
|
|
||||||
|
from book.models import ContentBlock, TextBlock
|
||||||
from user.models import UserGroup
|
from user.models import UserGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,6 +27,12 @@ class RoomEntry(TitleSlugDescriptionModel):
|
||||||
|
|
||||||
room = models.ForeignKey(Room, blank=False, null=False, on_delete=models.CASCADE, related_name='room_entries')
|
room = models.ForeignKey(Room, blank=False, null=False, on_delete=models.CASCADE, related_name='room_entries')
|
||||||
author = models.ForeignKey(get_user_model(), null=True, on_delete=models.CASCADE)
|
author = models.ForeignKey(get_user_model(), null=True, on_delete=models.CASCADE)
|
||||||
|
subtitle = models.CharField(blank=True, null=False, max_length=255)
|
||||||
|
|
||||||
|
contents = StreamField([
|
||||||
|
('text_block', TextBlock(icon='doc-full')),
|
||||||
|
('image_block', ImageChooserBlock(icon='image'))
|
||||||
|
], null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'RoomEntry {}-{}-{}'.format(self.id, self.title, self.author)
|
return 'RoomEntry {}-{}-{}'.format(self.id, self.title, self.author)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 2.0.6 on 2018-08-23 11:48
|
# Generated by Django 2.0.6 on 2018-09-04 12:22
|
||||||
|
|
||||||
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