Add document to solution, add more generic document block
This commit is contained in:
parent
04aa7a2524
commit
d96a8c7b11
|
|
@ -2,10 +2,10 @@ from django.db import models
|
|||
from django.utils.text import slugify
|
||||
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
|
||||
from wagtail.core.fields import RichTextField, StreamField
|
||||
from wagtail.documents.blocks import DocumentChooserBlock
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from books.blocks import DocumentBlock, GeniallyBlock, InfogramBlock, InstrumentTextBlock, LinkBlock, SectionTitleBlock, \
|
||||
from books.blocks import CMSDocumentBlock, DocumentBlock, GeniallyBlock, InfogramBlock, InstrumentTextBlock, LinkBlock, \
|
||||
SectionTitleBlock, \
|
||||
SubtitleBlock, ThinglinkBlock, VideoBlock
|
||||
from core.constants import DEFAULT_RICH_TEXT_FEATURES
|
||||
from core.wagtail_utils import StrictHierarchyPage
|
||||
|
|
@ -53,7 +53,7 @@ class BasicKnowledge(StrictHierarchyPage):
|
|||
('genially_block', GeniallyBlock()),
|
||||
('thinglink_block', ThinglinkBlock()),
|
||||
('subtitle', SubtitleBlock()),
|
||||
('cms_document_block', DocumentChooserBlock()),
|
||||
('cms_document_block', CMSDocumentBlock()),
|
||||
], null=True, blank=True)
|
||||
|
||||
new_type = models.ForeignKey(InstrumentType, null=True, on_delete=models.PROTECT, related_name='instruments')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from wagtail.core import blocks
|
||||
from wagtail.documents.blocks import DocumentChooserBlock
|
||||
from wagtail.snippets.blocks import SnippetChooserBlock
|
||||
|
||||
from assignments.models import Assignment
|
||||
|
|
@ -6,6 +7,11 @@ from core.constants import DEFAULT_RICH_TEXT_FEATURES, INSTRUMENTS_RICH_TEXT_FEA
|
|||
from surveys.models import Survey
|
||||
|
||||
|
||||
class CMSDocumentBlock(DocumentChooserBlock):
|
||||
class Meta:
|
||||
label = 'CMS Document'
|
||||
|
||||
|
||||
# link_block
|
||||
class LinkBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
|
|
@ -23,6 +29,14 @@ class TextBlock(blocks.StructBlock):
|
|||
text = blocks.RichTextBlock(features=DEFAULT_RICH_TEXT_FEATURES)
|
||||
|
||||
|
||||
class SolutionBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
icon = 'tick'
|
||||
|
||||
text = blocks.RichTextBlock(features=DEFAULT_RICH_TEXT_FEATURES)
|
||||
document = CMSDocumentBlock()
|
||||
|
||||
|
||||
# 'basic_knowledge'
|
||||
class BasicKnowledgeBlock(blocks.StructBlock):
|
||||
class Meta:
|
||||
|
|
@ -115,6 +129,8 @@ class InstructionBlock(blocks.StructBlock):
|
|||
|
||||
url = blocks.URLBlock()
|
||||
text = blocks.TextBlock(required=False)
|
||||
document = DocumentChooserBlock()
|
||||
|
||||
|
||||
# 'text_block' 'task' 'basic_knowledge' 'student_entry' 'image_block'
|
||||
#
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ from django.db import models
|
|||
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, StreamFieldPanel
|
||||
from wagtail.core.blocks import StreamBlock
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.documents.blocks import DocumentChooserBlock
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from core.wagtail_utils import get_default_settings
|
||||
from books.blocks import TextBlock, BasicKnowledgeBlock, LinkBlock, VideoBlock, DocumentBlock, \
|
||||
from books.blocks import CMSDocumentBlock, SolutionBlock, TextBlock, BasicKnowledgeBlock, LinkBlock, VideoBlock, \
|
||||
DocumentBlock, \
|
||||
ImageUrlBlock, AssignmentBlock, InfogramBlock, GeniallyBlock, SubtitleBlock, SurveyBlock, ModuleRoomSlugBlock, \
|
||||
ThinglinkBlock, InstructionBlock
|
||||
from books.utils import get_type_and_value
|
||||
|
|
@ -56,7 +56,8 @@ class ContentBlock(StrictHierarchyPage):
|
|||
('image_block', ImageChooserBlock()),
|
||||
('image_url_block', ImageUrlBlock()),
|
||||
('link_block', LinkBlock()),
|
||||
('solution', TextBlock(icon='tick')),
|
||||
# ('solution', TextBlock(icon='tick')),
|
||||
('solution', SolutionBlock()),
|
||||
('video_block', VideoBlock()),
|
||||
('document_block', DocumentBlock()),
|
||||
('infogram_block', InfogramBlock()),
|
||||
|
|
@ -65,7 +66,8 @@ class ContentBlock(StrictHierarchyPage):
|
|||
('subtitle', SubtitleBlock()),
|
||||
('instruction', InstructionBlock()),
|
||||
('module_room_slug', ModuleRoomSlugBlock()),
|
||||
('cms_document_block', DocumentChooserBlock())
|
||||
# ('cms_document_block', DocumentChooserBlock(label='CMS Document'))
|
||||
('cms_document_block', CMSDocumentBlock())
|
||||
]
|
||||
|
||||
content_list_item = StreamBlock(content_blocks)
|
||||
|
|
|
|||
Loading…
Reference in New Issue