Add intro to instruments

This commit is contained in:
Ramon Wenger 2020-09-29 13:56:17 +02:00
parent 5057e54e4d
commit 76b14e3cc8
9 changed files with 40 additions and 5 deletions

View File

@ -12,7 +12,7 @@
@edit-note="editNote"
@bookmark="bookmark(!chapter.bookmark)"
/>
<p class="chapter__description">
<p class="chapter__description intro">
{{ chapter.description }}
</p>

View File

@ -20,7 +20,7 @@
@edit-note="editNote"
@bookmark="bookmark(!module.bookmark)"/>
<div
class="module__intro"
class="module__intro intro"
v-html="module.intro"/>
</div>

View File

@ -1,6 +1,7 @@
fragment InstrumentParts on InstrumentNode {
id
title
intro
slug
bookmarks {
uuid

View File

@ -2,6 +2,10 @@
<div class="instrument">
<h1 class="instrument__title">{{ instrument.title }}</h1>
<div
class="instrument__intro intro"
v-html="instrument.intro"/>
<content-component
:key="component.id"
:component="component"

View File

@ -0,0 +1,7 @@
.intro {
@include lead-paragraph;
> p {
@include lead-paragraph;
}
}

View File

@ -27,3 +27,4 @@
@import "simple-list";
@import "widget-popover";
@import "toast";
@import "intro";

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2.12 on 2020-09-29 07:54
from django.db import migrations
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [
('basicknowledge', '0006_auto_20200520_0954'),
]
operations = [
migrations.AddField(
model_name='basicknowledge',
name='intro',
field=wagtail.core.fields.RichTextField(blank=True, default=''),
),
]

View File

@ -1,16 +1,18 @@
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtail.core.fields import StreamField
from wagtail.core.fields import StreamField, RichTextField
from wagtail.images.blocks import ImageChooserBlock
from books.blocks import LinkBlock, VideoBlock, DocumentBlock, SectionTitleBlock, InfogramBlock, \
GeniallyBlock, InstrumentTextBlock, SubtitleBlock, ThinglinkBlock
GeniallyBlock, InstrumentTextBlock, SubtitleBlock, ThinglinkBlock, DEFAULT_RICH_TEXT_FEATURES
from core.wagtail_utils import StrictHierarchyPage
class BasicKnowledge(StrictHierarchyPage):
parent_page_types = ['books.book']
intro = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES, default='', blank=True)
contents = StreamField([
('text_block', InstrumentTextBlock()),
('image_block', ImageChooserBlock()),
@ -42,6 +44,7 @@ class BasicKnowledge(StrictHierarchyPage):
content_panels = [
FieldPanel('title', classname="full title"),
FieldPanel('type'),
FieldPanel('intro'),
StreamFieldPanel('contents')
]

View File

@ -17,7 +17,7 @@ class InstrumentNode(DjangoObjectType):
filter_fields = ['slug', 'type']
interfaces = (relay.Node,)
only_fields = [
'slug', 'title', 'type', 'contents',
'slug', 'title', 'intro', 'type', 'contents',
]
def resolve_bookmarks(self, info, **kwargs):