class ArticlePage(Page): body = StreamField( [ ('heading', CharBlock(classname="full title")), ('paragraph', RichTextBlock()), ('reference_page', PageChooserBlock()), # this is single StructBlock ('struct_data', StructBlock([ ('heading', CharBlock(classname="full title")), ('paragraph', RichTextBlock()), ('reference_page', PageChooserBlock()), ])), # this is StreamBlock ('stream_data', StreamBlock([ ('sub_struct_data', StructBlock([ ('heading', CharBlock(classname="full title")), ('paragraph', RichTextBlock()), ('reference_page', PageChooserBlock()), ])), ])), ('column_struct_data', ColumnStructBlock()), ('column_stream_data', ColumnStreamBlock()) ], null=True, blank=True) # Editor panels configuration content_panels = Page.content_panels + [ StreamFieldPanel('body'), ]
class HomePage(RoutablePageMixin, Page): footer_colour = models.CharField("Hover colour", max_length=255, blank=True, null=True) splash_items = StreamField([ ('image', StructBlock([('image', ImageChooserBlock(blank=True, required=False)), ('title', CharBlock(required=False)), ('page_link', PageChooserBlock(blank=True))], icon='image')), ], blank=True) @route('^checkout/$') def checkout(self, request): context = self.get_context(request) return TemplateResponse(request, 'shop/checkout.html', context) @route('^amend-basket/$') def amend_basket(self, request): context = self.get_context(request) return TemplateResponse(request, 'shop/amend_basket.html', context) content_panels = Page.content_panels + [ StreamFieldPanel('splash_items'), ] promote_panels = [ FieldPanel('footer_colour'), ] + Page.promote_panels
class Plain(Page): footer_colour = models.CharField("Hover colour", max_length=255, blank=True, null=True) plain_text = RichTextField(blank=True) page_content = StreamField([ ('text_block', StructBlock([ ('text', RichTextBlock(blank=True)), ('width', ChoiceBlock(required=False, max_length=20, choices=( (u'6', u'half'), (u'8', u'third'), ))), ], template='home/blocks/text.html', icon="pilcrow")), ], blank=True) content_panels = Page.content_panels + [ FieldPanel('plain_text'), StreamFieldPanel('page_content'), ] promote_panels = [ FieldPanel('footer_colour'), ] + Page.promote_panels
class CardBlock(StructBlock): """Карточки с изображением, текстом и кнопкой.""" title = CharBlock(required=True, help_text="Add your title") cards = ListBlock( StructBlock( [ ("image", ImageChooserBlock(required=True)), ("title", CharBlock(required=True, max_length=40)), ("text", TextBlock(required=True, max_length=200)), ("button_page", PageChooserBlock(required=False)), ( "button_url", URLBlock( required=False, help_text="Если выбрана страница кнопки выше, она будет использоваться первой.", # noqa ), ), ] ) ) class Meta: # noqa template = "layouts/card_block.html" icon = "placeholder" label = "Карточка с фото"
class ProgramDocuments(models.Model): """ List of documents associated with a program .. no_pii: """ display = models.BooleanField( blank=False, null=False, default=True, verbose_name="Display Program Documents", ) header = models.CharField( max_length=128, blank=False, null=False, default="Program Documents", verbose_name="Header for Program Documents", ) documents = StreamField( [ ('file', StructBlock( [ ('display_text', CharBlock()), ('document', DocumentChooserBlock()) ], icon='doc-full' )), ('link', StructBlock( [ ('display_text', CharBlock()), ('url', URLBlock()), ], icon='link' )) ], blank=True, verbose_name="Documents" ) page = ParentalKey(ProgramPage, on_delete=models.CASCADE, related_name='program_documents', unique=True) panels = [ FieldPanel('display'), FieldPanel('header'), StreamFieldPanel('documents'), ]
class ContactTypeStreamBlock(StreamBlock): """Model allowing the CMS to bring together multiple struct block objects.""" contact_type_editor = StructBlock([ ('heading', TextBlock()), ('description', RichTextBlock(required=False)), ('email', TextBlock()) ], icon='title', classname='title')
class FourColumnBlock(StructBlock): """4 column block for price/service etc""" background = ChoiceBlock(choices=COLOUR_CHOICES, default="orange") block_title = CharBlock(classname='block title') block_subtitle = CharBlock(classname='block subtitle') first_column = StructBlock([ ('heading', CharBlock(classname="description")), ('subheading', CharBlock(classname="sub description")), ('bigtext', CharBlock(classname="bigtext")), ('toplist', ListBlock(CharBlock(classname='top list'))), ('bottomlist', ListBlock(CharBlock(classname='bottom list'))), ]) second_column = StructBlock([ ('heading', CharBlock(classname="description")), ('subheading', CharBlock(classname="sub description")), ('bigtext', CharBlock(classname="bigtext")), ('toplist', ListBlock(CharBlock(classname='top list'))), ('bottomlist', ListBlock(CharBlock(classname='bottom list'))), ]) third_column = StructBlock([ ('heading', CharBlock(classname="description")), ('subheading', CharBlock(classname="sub description")), ('bigtext', CharBlock(classname="bigtext")), ('toplist', ListBlock(CharBlock(classname='top list'))), ('bottomlist', ListBlock(CharBlock(classname='bottom list'))), ]) fourth_column = StructBlock([ ('heading', CharBlock(classname="description")), ('subheading', CharBlock(classname="sub description")), ('bigtext', CharBlock(classname="bigtext")), ('toplist', ListBlock(CharBlock(classname='top list'))), #Max number is 3 ('bottomlist', ListBlock(CharBlock(classname='bottom list'))), ]) class Meta: template = 'blocks/four_column_block.html' icon = 'placeholder' label = 'Four Columns'
class ImageGridBlock(StreamBlock): grid = StructBlock([ ('image', ImageChooserBlock(required=True, help_text='size: 800X450px')), ('caption', CharBlock(max_length=26, help_text='26 characters limit')), ('description', CharBlock(max_length=300, required=False, help_text='300 characters limit')), ('link', PageChooserBlock(required=False)) ]) class Meta: icon = 'image' template = 'blocks/image_grid_block.html'
class CarouselBlock(StructBlock): """ Custom `StructBlock` that allows the user to create a sequence of sub-blocks of different types, which can be mixed and reordered at will. """ image = ImageChooserBlock() quotation = StructBlock([('text', TextBlock()), ('author', CharBlock())]) video = EmbedBlock() class Meta: icon = "fa-images" template = "blocks/carousel_block.html"