Add 'user created' property on user created content blocks
This commit is contained in:
parent
9fed2b8422
commit
645c998d5c
|
|
@ -1,8 +1,8 @@
|
|||
<template>
|
||||
<div class="content-block__container">
|
||||
<div class="content-block" :class="specialClass">
|
||||
<div v-if="canChangeContentBlock" class="content-block__actions">
|
||||
<a @click="toggleVisibility()" class="content-block__visibility-button">
|
||||
<div class="content-block__actions">
|
||||
<a @click="toggleVisibility()" v-if="canManageContent" class="content-block__visibility-button">
|
||||
<eye-icon class="content-block__action-icon"></eye-icon>
|
||||
</a>
|
||||
<visibility-popover
|
||||
|
|
@ -10,12 +10,12 @@
|
|||
:content-block="contentBlock"
|
||||
class="content-block__visibility-menu"
|
||||
></visibility-popover>
|
||||
<a @click="editContentBlock()">
|
||||
<a @click="editContentBlock()" v-if="contentBlock.userCreated">
|
||||
<pen-icon class="content-block__action-icon"></pen-icon>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h4 class="content-block__title">{{contentBlock.title}}</h4>
|
||||
<h4 class="content-block__title">{{contentBlock.title}} {{contentBlock.userCreated}}</h4>
|
||||
|
||||
<component v-for="component in contentBlock.contents"
|
||||
:key="component.id"
|
||||
|
|
@ -70,8 +70,8 @@
|
|||
specialClass() {
|
||||
return `content-block--${this.contentBlock.type.toLowerCase()}`
|
||||
},
|
||||
canChangeContentBlock() {
|
||||
return this.me.permissions.includes('user.can_edit_modules');
|
||||
canManageContent() {
|
||||
return this.me.permissions.includes('users.can_manage_school_class_content');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ fragment ContentBlockParts on ContentBlockNode {
|
|||
title
|
||||
type
|
||||
contents
|
||||
userCreated
|
||||
hiddenFor {
|
||||
edges {
|
||||
node {
|
||||
|
|
@ -12,4 +13,12 @@ fragment ContentBlockParts on ContentBlockNode {
|
|||
}
|
||||
}
|
||||
}
|
||||
visibleFor {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08: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-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08:25
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
|
@ -10,9 +10,9 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('assignments', '0001_initial'),
|
||||
('books', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('books', '0001_initial'),
|
||||
('assignments', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -44,9 +44,9 @@ class Migration(migrations.Migration):
|
|||
name='ContentBlock',
|
||||
fields=[
|
||||
('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')),
|
||||
('user_created', models.BooleanField(default=False)),
|
||||
('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',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-10 08:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('users', '0001_initial'),
|
||||
('books', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='contentblock',
|
||||
name='hidden_for',
|
||||
field=models.ManyToManyField(related_name='hidden_content_blocks', to='users.SchoolClass'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='contentblock',
|
||||
name='visible_for',
|
||||
field=models.ManyToManyField(related_name='visible_content_blocks', to='users.SchoolClass'),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('user', '0001_initial'),
|
||||
('books', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='contentblock',
|
||||
name='hidden_for',
|
||||
field=models.ManyToManyField(to='users.SchoolClass'),
|
||||
),
|
||||
]
|
||||
|
|
@ -31,7 +31,9 @@ class ContentBlock(StrictHierarchyPage):
|
|||
(BLUE, 'Blau'),
|
||||
)
|
||||
|
||||
hidden_for = models.ManyToManyField(SchoolClass)
|
||||
hidden_for = models.ManyToManyField(SchoolClass, related_name='hidden_content_blocks')
|
||||
visible_for = models.ManyToManyField(SchoolClass, related_name='visible_content_blocks')
|
||||
user_created = models.BooleanField(default=False)
|
||||
|
||||
contents = StreamField([
|
||||
('text_block', TextBlock()),
|
||||
|
|
@ -66,8 +68,6 @@ class ContentBlock(StrictHierarchyPage):
|
|||
ObjectList(settings_panels, heading='Settings'),
|
||||
])
|
||||
|
||||
hide_in_admin = models.BooleanField(default=False)
|
||||
|
||||
template = 'generic_page.html'
|
||||
|
||||
parent_page_types = ['books.Chapter']
|
||||
|
|
@ -77,5 +77,5 @@ class ContentBlock(StrictHierarchyPage):
|
|||
@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 ContentBlock.get_by_parent(parent_page.specific).exclude(user_created=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, hide_in_admin=True)
|
||||
new_content_block = ContentBlock(title=title, user_created=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', 'visible_for', 'user_created'
|
||||
]
|
||||
filter_fields = [
|
||||
'slug', 'title',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08: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-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08:25
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
|
@ -11,8 +11,8 @@ class Migration(migrations.Migration):
|
|||
|
||||
dependencies = [
|
||||
('objectives', '0001_initial'),
|
||||
('books', '0002_contentblock_hidden_for'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('books', '0002_auto_20181010_0825'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08: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-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08:25
|
||||
|
||||
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),
|
||||
('users', '0001_initial'),
|
||||
('rooms', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.0.6 on 2018-10-09 15:25
|
||||
# Generated by Django 2.0.6 on 2018-10-10 08:25
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.auth.models
|
||||
|
|
@ -73,7 +73,7 @@ class Migration(migrations.Migration):
|
|||
('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.School')),
|
||||
],
|
||||
options={
|
||||
'permissions': (('can_edit_modules', 'Can create new contentblocks'),),
|
||||
'permissions': (('can_manage_school_class_content', 'Can manage contents for assigned school clases'),),
|
||||
},
|
||||
managers=[
|
||||
('objects', users.models.SchoolRoleManager()),
|
||||
|
|
|
|||
Loading…
Reference in New Issue