diff --git a/client/src/graphql/gql/sandbox/hiddenForContentBlockQuery.gql b/client/src/graphql/gql/sandbox/hiddenForContentBlockQuery.gql new file mode 100644 index 00000000..58e20095 --- /dev/null +++ b/client/src/graphql/gql/sandbox/hiddenForContentBlockQuery.gql @@ -0,0 +1,23 @@ +query ContentBlockQuery { + chapter(id: "RmlsdGVyZWRDaGFwdGVyTm9kZTo3") { + id + slug + contentBlocks { + edges { + node { + id + title + slug + hiddenFor { + edges { + node { + id + name + } + } + } + } + } + } + } +} diff --git a/server/book/migrations/0002_auto_20180913_0738.py b/server/book/migrations/0002_auto_20180913_0738.py new file mode 100644 index 00000000..04154d44 --- /dev/null +++ b/server/book/migrations/0002_auto_20180913_0738.py @@ -0,0 +1,27 @@ +# Generated by Django 2.0.6 on 2018-09-13 07:38 + +from django.db import migrations, models +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('user', '0001_initial'), + ('book', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='contentblock', + name='hidden_for', + field=models.ManyToManyField(to='user.UserGroup'), + ), + migrations.AlterField( + model_name='contentblock', + name='contents', + field=wagtail.core.fields.StreamField([('text_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='doc-full')), ('basic_knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.RichTextBlock()), ('url', wagtail.core.blocks.URLBlock())], icon='placeholder')), ('student_entry', wagtail.core.blocks.StructBlock([('task_text', wagtail.core.blocks.RichTextBlock())], icon='download')), ('image_block', wagtail.images.blocks.ImageChooserBlock(icon='image')), ('link_block', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())], icon='link')), ('task', wagtail.core.blocks.StructBlock([('text', wagtail.core.blocks.RichTextBlock())], icon='tick')), ('video_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())], icon='media')), ('document_block', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock())], icon='doc-full'))], blank=True, null=True), + ), + ] diff --git a/server/book/models/contentblock.py b/server/book/models/contentblock.py index 51538212..40217ecd 100644 --- a/server/book/models/contentblock.py +++ b/server/book/models/contentblock.py @@ -29,6 +29,8 @@ class ContentBlock(StrictHierarchyPage): (BLUE, 'Blau'), ) + hidden_for = models.ManyToManyField(UserGroup) + contents = StreamField([ ('text_block', TextBlock(icon='doc-full')), ('basic_knowledge', BasicKnowledgeBlock(icon='placeholder')), diff --git a/server/book/schema/queries.py b/server/book/schema/queries.py index f62415dc..4050930a 100644 --- a/server/book/schema/queries.py +++ b/server/book/schema/queries.py @@ -10,7 +10,7 @@ class ContentBlockNode(DjangoObjectType): class Meta: model = ContentBlock only_fields = [ - 'slug', 'title', 'type', 'contents' + 'slug', 'title', 'type', 'contents', 'hidden_for' ] filter_fields = [ 'slug', 'title',