示例#1
0
文件: models.py 项目: schlich/stl-dsa
class InfoPage(Page):
    body = RichTextField(blank=True)
    additional_content = StreamField([("embed", blocks.RawHTMLBlock())],
                                     null=True,
                                     blank=True)

    search_fields = Page.search_fields + [
        index.SearchField("body"),
    ]

    content_panels = Page.content_panels + [
        FieldPanel("body", classname="full"),
        StreamFieldPanel("additional_content"),
    ]
示例#2
0
class Seo(models.Model):
    name = models.CharField(max_length=255, default='')

    seo = StreamField([
        ('tag', blocks.RawHTMLBlock()),
    ], blank=True)

    panels = [
        FieldPanel('name'),
        StreamFieldPanel('seo'),
    ]

    def __str__(self):
        return self.name
示例#3
0
class ModernPost(BasePage, BlogPost):
    body = StreamField([
        ('heading', blocks.CharBlock(classname='full title')),
        ('paragraph', blocks.RichTextBlock(
            features=[
                'ol',
                'ul',
                'blockquote',
                'bold',
                'italic',
                'superscript',
                'subscript',
                'strikethrough',
                'code',
                'link',
                'image',
                'document-link',
            ],
        )),
        ('image', ImageBlock()),
        ('embed', EmbedBlock()),
        ('media', MediaBlock(icon='media')),
        ('raw_HTML', blocks.RawHTMLBlock(required=False)),
    ])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
        FieldPanel('tags'),
        FieldPanel('has_comments_enabled'),
    ]

    search_fields = Page.search_fields + [
        index.SearchField('title'),
        index.SearchField('body'),
    ]

    subpage_types = []

    def full_clean(self, *args, **kwargs):
        """ Override method to provide default slug for micro posts. """
        if self.is_micro():
            base_slug = dt.datetime.now(dt.timezone.utc).strftime('%Y%m%dT%H%MZ')
            self.slug = self._get_autogenerated_slug(base_slug)
        super(ModernPost, self).full_clean(*args, **kwargs)

    def is_micro(self):
        return True if 'micro' in self.tags.names() else False

    def is_snapshot(self):
        return True if 'snapshot' in self.tags.names() else False
示例#4
0
class Poll(models.Model):                                       
    intro = StreamField([                                       
        ('heading', blocks.CharBlock(classname='full title')),  
        ('html', blocks.RawHTMLBlock()),                        
        ('image', ImageChooserBlock()),                         
        ('paragraph', blocks.RichTextBlock()),                  
        ('video', EmbedBlock()),                                
    ])                                                          

    thank_you_text = StreamField([                              
        ('heading', blocks.CharBlock(classname='full title')),  
        ('html', blocks.RawHTMLBlock()),                        
        ('image', ImageChooserBlock()),                         
        ('paragraph', blocks.RichTextBlock()),                  
        ('video', EmbedBlock()),                                
    ])                                                          

    panels = [                                          
        # FieldPanel('title', classname='full title'),            
        StreamFieldPanel('intro'),                              
        # InlinePanel('form_fields', label='Questions'),          
        StreamFieldPanel('thank_you_text'),                     
    ]                                                           
示例#5
0
class HomePage(_MetadataPageMixin, Page):
    body = StreamField([
        ('full_width_image', FullWidthImageSectionBlock()),
        ('full_width_section', FullWidthSectionBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
    ])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body', heading=_('Page Body')),
    ]

    class Meta:
        verbose_name = _('Home Page')
        verbose_name_plural = _('Home Pages')
示例#6
0
class ExamplePage(Page):
    """Page template for "how to report" and "example scenario" pages
    Always within the Help section"""
    featured_image = models.ForeignKey('wagtailimages.Image',
                                       blank=True,
                                       null=True,
                                       on_delete=models.SET_NULL,
                                       related_name='+')

    pre_title = models.CharField(blank=True,
                                 null=True,
                                 max_length=255,
                                 choices=[('how', 'How to report'),
                                          ('scenario', 'Example scenario'),
                                          ('example', 'Example')])

    body = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('example_image', ExampleImage()),
        ('reporting_example_cards', ReportingExampleCards()),
        ('internal_button', InternalButtonBlock()),
        ('external_button', ExternalButtonBlock()),
        ('image', ImageChooserBlock()),
        ('html', blocks.RawHTMLBlock()),
    ],
                       null=True)

    related_media_title = models.CharField(blank=True,
                                           null=True,
                                           max_length=255)
    related_media = StreamField([
        ('continue_learning',
         blocks.ListBlock(ThumbnailBlock(),
                          icon='doc-empty',
                          template='blocks/related-media.html')),
    ],
                                null=True,
                                blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('pre_title'),
        ImageChooserPanel('featured_image'),
        StreamFieldPanel('body'),
        FieldPanel('related_media_title'),
        StreamFieldPanel('related_media')
    ]

    @property
    def content_section(self):
        return 'help'
示例#7
0
class HomePage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('page', blocks.PageChooserBlock()),
        ('document', DocumentChooserBlock()),
        ('media', EmbedBlock()),
        ('html', blocks.RawHTMLBlock(label='Raw HTML')),
    ])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]
示例#8
0
class LegacyBlogPage(AbstractFilterPage):
    content = StreamField([
        ('content',
         blocks.RawHTMLBlock(help_text='Content from WordPress unescaped.')),
        ('feedback', v1_blocks.Feedback()),
    ])
    objects = CFGOVPageManager()
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'

    search_fields = AbstractFilterPage.search_fields + [
        index.SearchField('content')
    ]
示例#9
0
class PostPage(Page):
    excerpt = MarkdownField()
    featured = models.BooleanField(default=False)
    body = StreamField([
        ('image', ImageChooserBlock()),
        ('html', blocks.RawHTMLBlock()),
        ('embed', EmbedBlock()),
        ('paragraph', MarkdownBlock(icon="code")),
    ])
    date = models.DateTimeField(verbose_name="Post date",
                                default=datetime.datetime.today)

    header_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )
    header_image_link = models.CharField(max_length=255, blank=True)

    categories = ParentalManyToManyField('blog.BlogCategory', blank=True)
    tags = ClusterTaggableManager(through='blog.BlogPageTag', blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
        ImageChooserPanel('header_image'),
        FieldPanel('header_image_link'),
        FieldPanel('excerpt'),
        FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        #FieldPanel('tags'),
        FieldPanel('featured'),
    ]

    settings_panels = Page.settings_panels + [
        FieldPanel('date'),
    ]

    @property
    def blog_page(self):
        return self.get_parent().specific

    def get_context(self, request, *args, **kwargs):
        context = super(PostPage, self).get_context(request, *args, **kwargs)
        context['blog_page'] = self.blog_page
        context['post'] = self
        return context

    def get_absolute_url(self):
        return "/news/%s/" % self.slug
示例#10
0
class BlogPage(Page):
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)
    body = StreamField([
        ('first_paragraph', blocks.CharBlock()),
        ('pullquotes', blocks.CharBlock()),
        ('blockquotes',
         blocks.StructBlock([
             ('quote', blocks.CharBlock()),
             ('cite', blocks.CharBlock()),
             ('cite_link', blocks.URLBlock(required=False)),
         ],
                            template='blocks/bquote.html')),
        ('image', ImageChooserBlock()),
        ('list', blocks.ListBlock(blocks.CharBlock())),
        ('paragraph', blocks.RichTextBlock()),
        ('code', CodeBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
    ])
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
    categories = ParentalManyToManyField('realblog.BlogCategory', blank=True)

    def main_image(self):
        gallery_item = self.gallery_images.first()
        if gallery_item:
            return gallery_item.image
        else:
            return None

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('date'),
            FieldPanel('tags'),
            FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        ],
                        heading="Blog information"),
        FieldPanel('intro'),
        StreamFieldPanel('body'),
        InlinePanel('gallery_images', label="Gallery images"),
    ]

    parent_page_types = [
        BlogIndexPage,
    ]
示例#11
0
class SimplePageWithMenuSidebar(MetadataPageMixin, BaseSidebarPageMixin, Page):
    subtitle = models.CharField(max_length=255, null=True, blank=True)
    body = StreamField([
        ('text',
         blocks.RichTextBlock(features=[
             'bold',
             'italic',
             'h2',
             'h3',
             'h4',
             'ol',
             'ul',
             'hr',
             'embed',
             'link',
             'document-link',
             'image',
             'code',
         ], )),
        ('image', AlignedImageBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
        ('blockquote', RichTextBlockQuoteBlock()),
        ('list',
         blocks.ListBlock(blocks.CharBlock(label="List Item"),
                          template='common/blocks/list_block_columns.html')),
        ('video', AlignedEmbedBlock()),
        ('heading_1', Heading1()),
        ('heading_2', Heading2()),
        ('heading_3', Heading3()),
    ],
                       blank=False)

    content_panels = Page.content_panels + [
        FieldPanel('subtitle'),
        StreamFieldPanel('body'),
    ]

    settings_panels = Page.settings_panels + BaseSidebarPageMixin.settings_panels

    search_fields_pgsql = ['title', 'body']

    def get_search_content(self):
        return get_search_content_by_fields(self, self.search_fields_pgsql)

    def get_meta_description(self):
        if self.search_description:
            return self.search_description

        return truncatewords(strip_tags(self.body.render_as_block()), 20)
示例#12
0
class Content(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname='full title')),
        ('rich_text', blocks.RichTextBlock()),
        ('raw', blocks.RawHTMLBlock()),
        ('include_content', blocks.CharBlock()),
        ('content_list', blocks.CharBlock()),
    ], null=True, blank=True)
    date = models.DateField('Content updated date', default=timezone.now)
    template_filename = models.CharField(max_length=64, choices=(
        ('content.html', 'content.html'),
        ('f6-content.html', 'f6-content.html'),
        ('f6-vue.html', 'f6-vue.html'),
    ), default='f6-content.html')
    tags = ClusterTaggableManager(through=ContentTag, blank=True)

    def get_template(self, request, *args, **kwargs):
        template_name = request.GET.get('template', self.template_filename)
        return '{}/{}'.format(self.__class__._meta.app_label, template_name)

    promote_panels = Page.promote_panels + [
        FieldPanel('date'),
        FieldPanel('tags')
    ]

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]

    settings_panels = Page.settings_panels + [
        FieldPanel('template_filename')
    ]

    search_fields = Page.search_fields + [
        index.SearchField('body'),
        index.FilterField('url_path'),
    ]

    def serve(self, request):
        if 'draft' in request.GET:
            return HttpResponseRedirect('/admin/pages/{}/view_draft/'.format(self.pk))
        response = super(Content, self).serve(request)
        if 'embed' in request.GET:
            with open(os.path.join(settings.MEDIA_ROOT, 'images', self.slug + '.html')) as output:
                output.write(response.content)
        return response

    class Meta:
        ordering = ('date',)
示例#13
0
class StaticPage(Page):
    """ To be deprecated. HomePage type might later become more generic e.g. GenericPage instead """
    body = StreamField([
        ('raw_html', blocks.RawHTMLBlock()),
        ('full_width_image', FullWidthImageSectionBlock()),
        ('full_width_section', FullWidthSectionBlock()),
    ])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body', heading=_('Page Body')),
    ]

    class Meta:
        verbose_name = _('Static Page')
        verbose_name_plural = _('Static Pages')
示例#14
0
class HomePage(Page):
    body = StreamField([('heading', blocks.CharBlock(classname="full title")),
                        ('paragraph', blocks.RichTextBlock()),
                        ('html', blocks.RawHTMLBlock()),
                        ('image', ImageChooserBlock()),
                        ('section_block', SectionBlock())])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]

    def latest(self):
        pages = GenericPage.objects.all().live()
        pages = pages.order_by('-date')[:3]
        return pages
示例#15
0
class ArticlePage(Page):
    template = 'articles/article.html'

    body = StreamField([
        ('text', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('html', blocks.RawHTMLBlock()),
        ('markdown', MarkDownBlock()),
        ('sourcecode', CodeBlock()),
    ],
                       blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]
示例#16
0
class NavbarBaseBlock(blocks.StructBlock):

    expand = BreakpointChooserBlock(required=False, closed=True)
    type = blocks.ChoiceBlock(choices=[
        ("navbar-light", "Light"),
        ("navbar-dark", "Dark"),
    ],
                              required=False,
                              closed=True)
    css_style = blocks.StreamBlock([
        ("background", BackgroundBlock(closed=True, required=False)),
        ("css", blocks.RawHTMLBlock(closed=True, required=False)),
    ],
                                   closed=True,
                                   required=False)
    style = StyleBlock(closed=True, required=False)
    parameters = blocks.StreamBlock(
        [("parameter", blocks.RawHTMLBlock(closed=True, required=False))],
        closed=True,
        required=False)

    class Meta:
        template = "components/base/navbar_base_block.html"
        icon = "doc-full-inverse"
示例#17
0
class ColumnBlock(blocks.StreamBlock):
    heading = Heading(classname='full title',
                      help_text=_('Text will be green and centered'))
    emphatic_text = EmphaticText(
        classname='full title',
        help_text=_('Text will be red, italic and centered'))
    aligned_paragraph = AlignedParagraphBlock()
    paragraph = blocks.RichTextBlock()
    image = ImageChooserBlock()
    document = DocumentChooserBlock()
    button = ButtonBlock()
    html = blocks.RawHTMLBlock()

    class Meta:
        template = 'blocks/column.html'
示例#18
0
class NomenDetail(RoutablePageMixin, Page):
    """
    Nomen Detail View Page using the Routable Page Mixin to return different
    views depending on Nomen id.
    """
    TEMPLATE_CHOICES = [
        ('origins/nomen_detail.html', 'Default Template'),
    ]

    subtitle = models.CharField(max_length=255, blank=True)
    intro = RichTextField(blank=True)
    body = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('html', blocks.RawHTMLBlock()),
    ])

    template_string = models.CharField(max_length=255,
                                       choices=TEMPLATE_CHOICES,
                                       default='pages/standard_page.html')

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    # def get_context(self, request):
    #     nomen = origins_models.Nomen.objects.get(pk=19)
    #
    #     context = super(NomenDetail, self).get_context(request)
    #     context['nomen'] = nomen
    #     return context

    @route(r'^(\d+)/$')
    def nomen_detail(self, request, id):
        """
        View function for nomen_detail
        :param request:
        :return:
        """

        nomen = origins_models.Nomen.objects.get(pk=id)
        references = nomen.references
        return self.render(request,
                           context_overrides={
                               'nomen': nomen,
                               'title': "Details for PK 19 Au. anamensis",
                           })
示例#19
0
class TestStreamBlock(blocks.StreamBlock):
    test_charblock = blocks.CharBlock(max_length=255)
    test_textblock = blocks.TextBlock(label=gettext_lazy("text block"))
    test_emailblock = blocks.EmailBlock()
    test_urlblock = blocks.URLBlock()
    test_richtextblock = blocks.RichTextBlock()
    test_rawhtmlblock = blocks.RawHTMLBlock()
    test_blockquoteblock = blocks.BlockQuoteBlock()
    test_structblock = TestStructBlock()
    test_listblock = blocks.ListBlock(blocks.TextBlock())
    test_nestedstreamblock = TestNestedStreamBlock()
    test_customstructblock = CustomStructBlock()
    test_customblockwithoutextractmethod = CustomBlockWithoutExtractMethod()
    test_pagechooserblock = blocks.PageChooserBlock()
    test_imagechooserblock = ImageChooserBlock()
    test_documentchooserblock = DocumentChooserBlock()
    test_snippetchooserblock = SnippetChooserBlock(TestSnippet)
示例#20
0
class FlexPage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(icon="title", null=True, blank=True)),
        ('image', ImageChooserBlock(required=False)),
        ('paragraph', blocks.RichTextBlock(icon="pilcrow", features=['h3', 'h4', 'centre', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'embed'],  null=True, blank=True)),
        ('embed', EmbedBlock(icon="media", null=True, blank=True)),
        ('embed_HTML', blocks.RawHTMLBlock(required=False, help_text="use this to embed elements that do not embed using the normal embed block, e.g. google forms", null=True, blank=True)),
        ('cards', CardBlock()),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("body", classname="full"),
    ]

    class Meta: #noqa
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
示例#21
0
class EDoX(Page):
    date = models.DateField("Date", default=datetime.date.today)
    authors = ParentalManyToManyField('edox.Author', blank=True)

    hero = models.ForeignKey('wagtailimages.Image',
                             null=True,
                             blank=True,
                             on_delete=models.PROTECT,
                             related_name='+')
    intro = models.CharField(max_length=250)

    tags = ClusterTaggableManager(through=Tag, blank=True)
    categories = ParentalManyToManyField('edox.Category', blank=True)

    # body = EDoxField([])
    body = StreamField([
        ('text', wt_blocks.RichTextBlock()),
        ('raw', wt_blocks.RawHTMLBlock()),
        ('code', blocks.CodeBlock()),
        ('image', blocks.ImageBlock()),
        ('plot', blocks.PlotBlock()),
        ('table', blocks.TableBlock()),
        ('program', blocks.JSProgramInlineBlock()),
    ])
    # panel layout
    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('date'),
            FieldPanel('authors', widget=forms.CheckboxSelectMultiple),
            FieldPanel('tags'),
            FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        ],
                        heading="Blog information"),
        FieldPanel('intro'),
        ImageChooserPanel('hero'),
        StreamFieldPanel('body'),
    ]

    def prev(self):
        return self.get_prev_siblings().live().first()

    def next(self):
        return self.get_next_siblings().live().first()

    class Meta:
        verbose_name = "EDoX"
示例#22
0
class HomePage(Page):
    
    body = StreamField([
        ('jumbotron', blocks.RawHTMLBlock()),
    ])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]

    subpage_types = [
        'home.HomePage',
        'home.BasicPage',
    ]

    parent_page_type = [
        'wagtailcore.Page'
    ]
示例#23
0
class SearchHelpBlock(models.Model):
    content = StreamField([
        ('text', blocks.RichTextBlock()),
        ('html', blocks.RawHTMLBlock()),
    ],
                          null=True)

    panels = [
        StreamFieldPanel('content'),
    ]

    def __str__(self):
        return "Search Help"

    def clean(self):
        if self.id is None and self._meta.model.objects.exists():
            raise ValidationError(
                'The search page can only have one help block.')
示例#24
0
class BlogPage(Page):
    author = models.CharField(max_length=255)
    date = models.DateField("Post date")
    one_line = models.CharField(max_length=100)
    intro = models.CharField(max_length=250)
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('two_columns', TwoColumnBlock()),
        ('embedded_video', EmbedBlock(icon="media")),
        ('equation', MathBlock()),
        ('html', blocks.RawHTMLBlock()),
        ('resizable_image', ImageBlock()),
    ],null=True,blank=True)
    
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
    categories = ParentalManyToManyField('blog.BlogCategory', blank=True)

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('author'),
            FieldPanel('date'),
            FieldPanel('tags'),
            FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        ], heading="Blog information"),
        FieldPanel('one_line'),
        FieldPanel('intro'),
        StreamFieldPanel('body'),
        InlinePanel('gallery_images', label="Gallery images"),
    ]

    def main_image(self):
        gallery_item = self.gallery_images.first()
        if gallery_item:
            return gallery_item.image
        else:
            return None
示例#25
0
class StandardPage(Page):
    TEMPLATE_CHOICES = [
        ('pages/standard_page_full.html', 'Optional custom sidebar'),
        ('pages/standard_page.html', 'Newsfeed sidebar'),
    ]
    subtitle = models.CharField(
        max_length=255,
        blank=True,
        help_text="This will override the title of the page.")
    intro = RichTextField(blank=True)
    midpage_subtitle = models.CharField(
        max_length=255,
        blank=True,
        help_text="This will override the title of the page.")
    body = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('markdown', MarkdownBlock(icon="code")),
        ('html', blocks.RawHTMLBlock()),
    ])
    template_string = models.CharField(max_length=255,
                                       choices=TEMPLATE_CHOICES,
                                       default=TEMPLATE_CHOICES[0][0],
                                       verbose_name='Page Layout')
    feed_image = models.ForeignKey(Image,
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+')
    sidebar_text = RichTextField(
        blank=True,
        help_text=
        "only include text/images in here if you want the side bar, otherwise it will render full page"
    )

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    @property
    def template(self):
        return self.template_string
示例#26
0
class _S_TallBlock(blocks.StructBlock):
    timeblock = blocks.TimeBlock()
    datetimeblock = blocks.DateTimeBlock()
    richtextblock = blocks.RichTextBlock()
    rawhtmlblock = blocks.RawHTMLBlock()
    blockquoteblock = blocks.BlockQuoteBlock()
    choiceblock = blocks.ChoiceBlock(choices=[
        ("apples", "Apple"),
        ("bananas", "Bananas"),
    ])

    graphql_fields = [
        GraphQLString("timeblock"),
        GraphQLString("datetimeblock"),
        GraphQLString("richtextblock"),
        GraphQLString("rawhtmlblock"),
        GraphQLString("blockquoteblock"),
        GraphQLString("choiceblock"),
    ]
示例#27
0
class NominaListView(Page):
    """
    Nomina List View Page
    """
    TEMPLATE_CHOICES = [
        ('origins/nomina_list_view.html', 'Default Template'),
    ]
    subtitle = models.CharField(max_length=255, blank=True)
    intro = RichTextField(blank=True)
    body = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('html', blocks.RawHTMLBlock()),
    ])

    template_string = models.CharField(max_length=255,
                                       choices=TEMPLATE_CHOICES,
                                       default='pages/standard_page.html')

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    def get_context(self, request):
        # Update template context
        qs = origins_models.Nomen.objects.all().select_related(
            'authorship_reference_obj', 'type_specimen')
        tqs = origins_models.Fossil.objects.filter(
            is_type_specimen=True).select_related('site')
        tqs = tqs.order_by('continent', 'site__name')
        count = qs.count()
        context = super(NominaListView, self).get_context(request)
        context['nomina'] = qs
        context['type_fossils'] = tqs
        context['type_fossils_africa'] = tqs.filter(continent='Africa')
        context['type_fossils_asia'] = tqs.filter(continent='Asia')
        context['type_fossils_europe'] = tqs.filter(continent='Europe')
        context['type_fossil_count'] = tqs.count()
        context['count'] = count

        return context
示例#28
0
class SimplePage(Page):
    body = fields.RichTextField(blank=True)
    body_block = fields.StreamField(
        [('text',
          blocks.RichTextBlock(icon='doc-full',
                               template='home/blocks/text.html')),
         ('html', blocks.RawHTMLBlock(template='home/blocks/text.html')),
         ('teasers', TeaserListBlock()), ('columns', ColumnsListBlock()),
         ('projects', CurrentProjectsListBlock()),
         ('updates', UpdatesBlock())],
        blank=True)

    content_panels = [
        edit_handlers.FieldPanel('title'),
        edit_handlers.FieldPanel('body'),
        edit_handlers.StreamFieldPanel('body_block'),
    ]

    parent_page_types = ['home.HomePage']
    subpage_types = []
示例#29
0
class Footer(models.Model):
    label = models.CharField(max_length=50, null=True, blank=True)
    content = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('html', blocks.RawHTMLBlock()),
        ('table', TableBlock()),
        ('image', ImageChooserBlock(template='blocks/image_block.html')),
    ],
                          null=True,
                          blank=True)
    panels = [
        FieldPanel('label'),
        StreamFieldPanel('content'),
    ]

    def __str__(self):
        if self.label:
            return self.label
        else:
            return ''
示例#30
0
class CardBlock(blocks.StructBlock):

    content = blocks.StreamBlock(
        [("header", TitleBlock(required=False, closed=True)),
         ("image_card", ImageBlock(required=False, closed=True)),
         ("title", TitleBlock(required=False, closed=True)),
         ("subtitle", TitleBlock(required=False, closed=True)),
         ("paragraph", RichTextBlock(required=False, closed=True)),
         ("quote", QuoteBlock(required=False, closed=True)),
         ("html", blocks.RawHTMLBlock(required=False, closed=True)),
         ("image", ImageBlock(required=False, closed=True)),
         ("button", ButtonBlock(required=False, closed=True)),
         ("footer", TitleBlock(required=False, closed=True))],
        required=False,
        closed=True)
    card_style = BaseBlock(required=False, closed=True)

    class Meta:
        icon = "image"
        template = "components/container/card_block.html"
        group = "Containers"