Distinguish between default and user created content blocks in cms admin
This commit is contained in:
parent
3369d0fbb7
commit
8110ee359f
|
|
@ -6,6 +6,8 @@
|
|||
{{chapter.description}}
|
||||
</p>
|
||||
|
||||
<add-content-block-button :parent="chapter.id"></add-content-block-button>
|
||||
|
||||
<content-block :contentBlock="contentBlock"
|
||||
:key="contentBlock.id" v-for="contentBlock in filteredContentBlocks">
|
||||
</content-block>
|
||||
|
|
@ -14,12 +16,14 @@
|
|||
|
||||
<script>
|
||||
import ContentBlock from '@/components/ContentBlock';
|
||||
import AddContentBlockButton from '@/components/AddContentBlockButton';
|
||||
|
||||
export default {
|
||||
props: ['chapter', 'index'],
|
||||
|
||||
components: {
|
||||
ContentBlock,
|
||||
AddContentBlockButton
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
<add-content-block-button v-if="canChangeContentBlock" :after="contentBlock.id"></add-content-block-button>
|
||||
<add-content-block-button :after="contentBlock.id"></add-content-block-button>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
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),
|
||||
('books', '0001_initial'),
|
||||
('assignments', '0001_initial'),
|
||||
('books', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -12,8 +12,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0040_page_draft_title'),
|
||||
('wagtailimages', '0021_image_file_hash'),
|
||||
('wagtailcore', '0040_page_draft_title'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -46,6 +46,7 @@ class Migration(migrations.Migration):
|
|||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||
('contents', wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())])), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('assignment', wagtail.core.blocks.StructBlock([('assignment_id', wagtail.core.blocks.IntegerBlock())])), ('image_block', wagtail.images.blocks.ImageChooserBlock()), ('image_url_block', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('task', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())])), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())]))], blank=True, null=True)),
|
||||
('type', models.CharField(choices=[('plain', 'Normal'), ('yellow', 'Gelb'), ('green', 'Grün'), ('blue', 'Blau')], default='plain', max_length=100)),
|
||||
('hide_in_admin', models.BooleanField(default=False)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Inhaltsblock',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('books', '0001_initial'),
|
||||
('user', '0001_initial'),
|
||||
('books', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from django.db import models
|
|||
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, StreamFieldPanel
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
from wagtail.core import hooks
|
||||
|
||||
from books.blocks import TextBlock, BasicKnowledgeBlock, LinkBlock, VideoBlock, DocumentBlock, \
|
||||
ImageUrlBlock, AssignmentBlock
|
||||
|
|
@ -65,7 +66,16 @@ class ContentBlock(StrictHierarchyPage):
|
|||
ObjectList(settings_panels, heading='Settings'),
|
||||
])
|
||||
|
||||
hide_in_admin = models.BooleanField(default=False)
|
||||
|
||||
template = 'generic_page.html'
|
||||
|
||||
parent_page_types = ['books.Chapter']
|
||||
subpage_types = []
|
||||
|
||||
|
||||
@hooks.register('construct_explorer_page_queryset')
|
||||
def remove_user_created_content_blocks_from_menu(parent_page, pages, request):
|
||||
if parent_page.content_type.model == 'chapter':
|
||||
return ContentBlock.get_by_parent(parent_page.specific).exclude(hide_in_admin=True)
|
||||
return pages
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class AddContentBlock(relay.ClientIDMutation):
|
|||
title = content_block_data.get('title')
|
||||
contents = content_block_data.get('contents')
|
||||
|
||||
new_content_block = ContentBlock(title=title)
|
||||
new_content_block = ContentBlock(title=title, hide_in_admin=True)
|
||||
|
||||
if parent is not None:
|
||||
parent_chapter = get_object(Chapter, parent).specific
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ContentBlockNode(DjangoObjectType):
|
|||
class Meta:
|
||||
model = ContentBlock
|
||||
only_fields = [
|
||||
'slug', 'title', 'type', 'contents', 'hidden_for'
|
||||
'slug', 'title', 'type', 'contents', 'hidden_for',
|
||||
]
|
||||
filter_fields = [
|
||||
'slug', 'title',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
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),
|
||||
('books', '0002_contentblock_hidden_for'),
|
||||
('objectives', '0001_initial'),
|
||||
('books', '0002_contentblock_hidden_for'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django_extensions.db.fields
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
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),
|
||||
('rooms', '0001_initial'),
|
||||
('user', '0001_initial'),
|
||||
('rooms', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-05 09:24
|
||||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.auth.models
|
||||
|
|
@ -60,7 +60,7 @@ class Migration(migrations.Migration):
|
|||
('year', models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(1900), django.core.validators.MaxValueValidator(2200)])),
|
||||
('is_deleted', models.BooleanField(default=False)),
|
||||
('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.School')),
|
||||
('users', models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
|
||||
('users', models.ManyToManyField(related_name='school_classes', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
|
|
|
|||
Loading…
Reference in New Issue