Пример #1
0
class CraftPost(Page):
    author = models.CharField(max_length=255, blank=True, null=True)
    date = models.DateField("Post date")
    featured = models.BooleanField(default=False)
    body = StreamField([
        ('content', blocks.RichTextBlock()),
        ('quote', blocks.BlockQuoteBlock()),
        ('image', ImageChooserBlock(template="frontend/craftbox/blocks/image.html")),
        ('embed', EmbedBlock()),
        ('code', CodeBlock())
    ])
    cover_image = models.ForeignKey(
        'wagtailimages.Image',
        help_text="An optional image to represent the page",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
        )
    excerpt = StreamField([
        ('qoute', blocks.BlockQuoteBlock())]
        )
    tags = ClusterTaggableManager(through=CraftPostTag, blank=True)
    post_category = models.ForeignKey(
        CraftboxCategory,
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    search_fields = Page.search_fields + [
        index.SearchField('featured'),
        index.SearchField('body'),
        index.SearchField('tags'),
        index.SearchField('post_category', boost=4)
    ]

    content_panels = Page.content_panels + [
        FieldPanel('author'),
        StreamFieldPanel('body'),
    ]
    promote_panels = Page.promote_panels + [
        FieldPanel('date'),
        FieldPanel('featured'),
        ImageChooserPanel('cover_image'),
        StreamFieldPanel('excerpt'),
        FieldPanel('tags'),
        SnippetChooserPanel('post_category'),
    ]

    parent_page_types = ['craftbox.CraftHome']
    subpage_types = []

    def get_template(request, *args, **kwargs):
        return "frontend/craftbox/post.html"

    class Meta:
        verbose_name = "craft post page"
Пример #2
0
class BootstrapCol(blocks.StructBlock):
    width = blocks.IntegerBlock(max_value=12,
                                min_value=0,
                                help_text='0 = auto',
                                default=0)
    alignment = blocks.ChoiceBlock(choices=[
        ('center', 'Center'),
        ('right', 'Right'),
        ('left', 'Left'),
    ],
                                   default='center')
    vertical_center = blocks.BooleanBlock(default=False,
                                          blank=True,
                                          required=False)
    body = blocks.StreamBlock([
        (_('Rich_Text'), blocks.RichTextBlock()),
        (_('Text'), blocks.TextBlock()),
        (_('Image'), ImageChooserBlock(icon="image")),
        (_('Embedded_Video'), EmbedBlock(icon="media")),
        (_('HTML'), blocks.RawHTMLBlock()),
        (_('Quote'), blocks.BlockQuoteBlock()),
        (_('Optin'), OptinChooserBlock('optin.Optin')),
        (_('Code'), CodeBlock(label='Code Editor')),
        (_('Aligned_Image'), AlignedImageBlock()),
    ],
                              blank=True,
                              null=True,
                              required=False)

    class Meta:
        icon = 'grip'
        label = 'Bootstrap Col'
        template = 'blog/blocks/bootstrap_col.html'
Пример #3
0
class BlogPage(Page):
    CATEGORY_CHOICES = [
        ('technology', 'Technology'),
        ('missions', 'Missions'),
        ('politics', 'Politics'),
        ('discoveries', 'Discoveries'),
    ]

    date = models.DateField("Post date")
    category = models.CharField(
        max_length=256,
        choices=CATEGORY_CHOICES,
    )
    subtitle = models.CharField(blank=True, max_length=256)
    body = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('blockquote', blocks.BlockQuoteBlock()),
        ('image', ImageChooserBlock()),
    ])

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

    content_panels = Page.content_panels + [
        FieldPanel('date'),
        FieldPanel('subtitle'),
        FieldPanel('category'),
        StreamFieldPanel('body'),
    ]
class ProjectPage(ArticlePage):
  promoted = models.BooleanField(
      default=False,
      help_text="Promoted pages are highlighted on the home page"
      )
  blurb = RichTextField(blank=True)
  image = models.ForeignKey(
      'wagtailimages.Image', on_delete=models.SET_NULL, related_name='+',
      null=True
      )

  body = StreamField([
      ('heading', blocks.CharBlock(classname="full title", icon='title')),
      ('textblock', blocks.RichTextBlock(label="Text Block")),
      ('image', CaptionedImageBlock()),
      ('pullquote', blocks.BlockQuoteBlock(label="Pull Quote")), 
      ])

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

  content_panels = Page.content_panels + [
      FieldPanel('promoted'),
      FieldPanel('blurb', classname="full"),
      ImageChooserPanel('image'),
      StreamFieldPanel('body'),
      ]

  index_entry_template = 'articles/fragments/project_index_entry.html'
Пример #5
0
class ParallaxHeaderBlock(blocks.StructBlock):
    background = ImageChooserBlock(blank=True)
    title = blocks.CharBlock(blank=True)
    body = blocks.StreamBlock(
        [
            (_('Rich_Text'), blocks.RichTextBlock()),
            (_('Text'), blocks.TextBlock()),
            (_('Image'), ImageChooserBlock(icon="image")),
            # (_('Image(aligned)'), AlignedImageBlock()),
            (_('Embedded_Video'), EmbedBlock(icon="media")),
            (_('HTML'), blocks.RawHTMLBlock()),
            (_('Quote'), blocks.BlockQuoteBlock()),
            (_('Optin'), OptinChooserBlock('optin.Optin')),
            (_('Code'), CodeBlock(label='Code Editor')),
            (_('Bootstrap_Row'), BootstrapRow()),
            (_('Bootstrap_Col'), BootstrapCol()),
            (_('Aligned_Image'), AlignedImageBlock()),
        ],
        blank=True,
        null=True,
        required=False)

    class Meta:
        icon = 'form'
        label = 'Parallax Header'
        template = 'blog/blocks/parallax_header.html'
Пример #6
0
class BlogPage(BlogRootMixin, Page):
    template = "web/blog/blog-details.html"
    parent_page_types = ["web.BlogListPage"]
    subpage_types = []

    body = StreamField([
        ("heading", blocks.CharBlock(form_classname="full title")),
        ("paragraph", blocks.RichTextBlock(features=RICH_TEXT_FEATURES)),
        ("image", ImageChooserBlock()),
        ("quote", blocks.BlockQuoteBlock()),
    ])
    main_image = models.ForeignKey(
        "wagtailimages.Image",
        related_name="+",
        on_delete=models.PROTECT,
        blank=True,
        null=True,
    )

    promote_panels = [FieldPanel("slug")]
    settings_panels = [PrivacyModalPanel()]
    content_panels = Page.content_panels + [
        FieldPanel("owner", heading="Author"),
        MultiFieldPanel(
            [
                ImageChooserPanel("main_image"),
                FieldPanel("search_description"),
            ],
            "Search and social media",
        ),
        StreamFieldPanel("body"),
    ]
Пример #7
0
class StaticPage(Page):
    date = models.DateField("Post date", blank=True, null=True)
    intro = models.CharField(max_length=250)

    body = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('html_paragraph', blocks.RawHTMLBlock()),
        ('quote', blocks.BlockQuoteBlock()),
        ('image', ImageChooserBlock()),
    ])

    order = models.IntegerField(blank=True, null=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 + [
        FieldPanel('date'),
        FieldPanel('intro'),
        StreamFieldPanel('body'),
        InlinePanel('gallery_images', label="Gallery images"),
    ]
Пример #8
0
class FlexPage(ExportModelOperationsMixin("flex_page"), MetadataPageMixin,
               Page):
    body = StreamField(
        [
            ("header", MyHeaderBlock()),
            ("list", ListBlock()),
            ("image_text_overlay", ImageTextOverlayBlock()),
            ("cropped_images_with_text", CroppedImagesWithTextBlock()),
            ("list_with_images", ListWithImagesBlock()),
            ("thumbnail_gallery", ThumbnailGalleryBlock()),
            ("chart", ChartBlock()),
            ("map", MapBlock()),
            ("image_slider", ImageSliderBlock()),
            ("form", WagtailFormBlock()),
            ("Parallax", ParallaxBlock()),
            ("Code", MyCodeBlock()),
            ("Timeline", TimelineBlock()),
            ("Text", blocks.RichTextBlock()),
            ("Quote", blocks.BlockQuoteBlock()),
            ("Embed", EmbedBlock()),
            ("Document", DocumentChooserBlock()),
        ],
        blank=True,
    )
    author_twitter_handle = models.CharField(max_length=15)
    content_panels = Page.content_panels + [
        StreamFieldPanel("body", classname="Full"),
        FieldPanel("author_twitter_handle"),
    ]
Пример #9
0
class NewsItem(AbstractNewsItem):
    # NewsItem is a normal Django model, *not* a Wagtail Page. RichTextField
    # Add any fields required for your page.
    # It already has ``date`` field, and a link to its parent ``NewsIndex`` Page
    headline = models.CharField(max_length=255)
    byline = models.CharField(max_length=255)
    lead = StreamField([
        ('lead', blocks.RichTextBlock()),
    ], blank=True)
    body = StreamField([
        ('heading', blocks.CharBlock(form_classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('blockquote', blocks.BlockQuoteBlock()),
        ('svg', SvgChooserBlock()),
        ('image', ImageChooserBlock()),
        ('embed', EmbedBlock()),
        ('button', ButtonBlock()),
    ],
                       blank=True)
    author = StreamField([
        ('author', PersonBlock()),
    ], blank=True)

    panels = [
        FieldPanel('headline', classname='full title'),
        FieldPanel('byline', classname='byline'),
        StreamFieldPanel('lead', classname='lead'),
        StreamFieldPanel('body', classname='body'),
        StreamFieldPanel('author', classname='author'),
    ] + AbstractNewsItem.panels

    def __str__(self):
        return self.headline
Пример #10
0
class VolunteerPage(VolunteerRootMixin, Page):
    template = "web/volunteers/volunteer-details.html"
    parent_page_types = ["web.VolunteerListPage"]
    subpage_types = []

    body = StreamField([
        ("heading", blocks.CharBlock(form_classname="full title")),
        ("paragraph", blocks.RichTextBlock(features=RICH_TEXT_FEATURES)),
        ("image", ImageChooserBlock()),
        ("quote", blocks.BlockQuoteBlock()),
        ("attributed_quote", AttributedQuoteBlock()),
    ])
    position = models.CharField(max_length=255,
                                help_text="The name of their role")
    main_image = models.ForeignKey(
        "wagtailimages.Image",
        related_name="+",
        on_delete=models.PROTECT,
        blank=True,
        null=True,
    )

    promote_panels = [FieldPanel("slug")]
    settings_panels = [PrivacyModalPanel()]
    content_panels = Page.content_panels + [
        FieldPanel("position"),
        ImageChooserPanel("main_image"),
        StreamFieldPanel("body"),
    ]

    def save(self, *args, **kwargs):
        self.search_description = f"{self.title}, {self.position} at Anika Legal"
        return super().save(*args, **kwargs)
Пример #11
0
class MultiSectionBlock(blocks.StreamBlock):
    text_block = blocks.RichTextBlock()
    quote_block = blocks.BlockQuoteBlock()
    code_block = CodeBlock()

    class Meta:
        icon = "placeholder"
        label = "Multi Section"
Пример #12
0
class HomePage(Page):
    advert = models.ForeignKey('home.Advert',
                               null=True,
                               blank=True,
                               on_delete=models.SET_NULL,
                               related_name='+')

    body = StreamField([
        ('Paragraph', blocks.RichTextBlock()),
        ('Image', ImageChooserBlock()),
        ('OtherImgBlock', OtherImgBlock()),
        ('Text', blocks.TextBlock()),
        ('Heading', blocks.CharBlock()),
        ('BlockQuote', blocks.BlockQuoteBlock()),
        ('Email', blocks.EmailBlock()),
        ('URL', blocks.URLBlock()),
        ('Boolean', blocks.BooleanBlock()),
        ('Integer', blocks.IntegerBlock()),
        ('Float', blocks.FloatBlock()),
        ('Decimal', blocks.DecimalBlock()),
        ('Date', blocks.DateBlock()),
        ('Time', blocks.TimeBlock()),
        ('DateTime', blocks.DateTimeBlock()),
        ('RawHTML', blocks.RawHTMLBlock()),
        ('Choice', blocks.ChoiceBlock()),
        ('PageChooser', blocks.PageChooserBlock()),
        ('DocumentChooser', DocumentChooserBlock()),
        ('Banner', BannerBlock()),
        ('Embed', EmbedBlock()),
        ('RecommendCourse',
         blocks.StructBlock([('title', blocks.CharBlock()),
                             ('courses', blocks.ListBlock(CourseBlock()))],
                            template='home/blocks/recommend_courses.html')),
        ('SeriesCourse',
         blocks.StructBlock([('title', blocks.CharBlock()),
                             ('series', blocks.ListBlock(SeriesBlock()))],
                            template='home/blocks/series_list.html')),
        ('StoryBlock', StoryBlock()),
        ('ProfessorBlock', ProfessorBlock()),
        ('CategoriesListBlock', CategoriesListBlock()),
        ('SubjectCourse',
         blocks.StructBlock(
             [('required_course', blocks.ListBlock(SeriesBlock())),
              ('optional_course', blocks.ListBlock(SeriesBlock()))],
             template='home/blocks/subject_course.html')),
        ('VipBlock', VipBlock()),
        ('SeriesProcessBlock', SeriesProcessBlock()),
    ])

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

    api_fields = [
        APIField('body'),
    ]
Пример #13
0
class BlogPage(MenuMixin, Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname='full title')),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('embed', blocks.RawHTMLBlock()),
        ('block_quote', blocks.BlockQuoteBlock()),
    ])

    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)

    category = models.ForeignKey(
        'blog.BlogCategory',
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )

    image = models.ForeignKey('wagtailimages.Image',
                              blank=True,
                              null=True,
                              on_delete=models.SET_NULL,
                              related_name='+')

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

    content_panels = Page.content_panels + [
        ImageChooserPanel('image'),
        StreamFieldPanel('body'),
        MultiFieldPanel([
            FieldPanel('first_published_at'),
            FieldPanel('tags'),
            SnippetChooserPanel('category'),
        ],
                        heading="Post Details"),
    ]

    parent_page_types = ['blog.BlogIndexPage']

    @property
    def siblings(self):
        return self.get_parent().get_children().order_by('-first_published_at')

    @property
    def sidebar_intro(self):
        if hasattr(self, 'intro'):
            return self.intro
        else:
            return self.get_parent().specific.intro

    def get_context(self, request):
        context = super().get_context(request)
        context['menuitems'] = get_menu_items()
        return context
Пример #14
0
class ProductPage(Page):
    body = StreamField([('heading',
                         blocks.RichTextBlock(classname="full title")),
                        ('paragraph', blocks.RichTextBlock()),
                        ('image', ImageChooserBlock()),
                        ('url', blocks.URLBlock()),
                        ('datetime', blocks.DateTimeBlock()),
                        ('qoute', blocks.BlockQuoteBlock()),
                        ('file', DocumentChooserBlock())])

    content_panels = Page.content_panels + [StreamFieldPanel('body')]
Пример #15
0
class BlogPage(RoutablePageMixin,Page):
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)
    template = 'blogs/blog_page.html'
    ajax_template = "blogs/blog_page_ajax.html"
    # body = RichTextField(features=['h1','h2', 'h3','h4','h5','h6', 'bold', 'italic', 'link','ol','ul','hr','document-link','image','embed','code','superscript','subscript','blockquote'])
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('list', blocks.ListBlock(blocks.CharBlock(label=""))),
        ('document', blocks.BlockQuoteBlock()),
    ])

    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
    author = models.CharField(max_length=255,default='Adrian')
    categories = ParentalManyToManyField('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'),
        ], heading="Blog information"),
        FieldPanel('intro'),
        FieldPanel('author'),
        # FieldPanel('body'),
        StreamFieldPanel('body'),
        InlinePanel('gallery_images', label="Gallery images"),
        FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
    ]
    def get_context(self, request):
        context = super().get_context(request)
        raw_url = context['request'].get_raw_uri()
        parse_result = six.moves.urllib.parse.urlparse(raw_url)
        lista = parse_result.path.split('/')
        slug = lista[4]
        print(slug)
        comment1 = Comment.objects.filter(post__slug = slug)
        # comment2 = Comment.objects.filter(post__slug = 'post-1')
        # print(comment)
        post = BlogPage.objects.all()
        context['comments'] = comment1
        return context
Пример #16
0
class TestStreamBlock(blocks.StreamBlock):
    test_charblock = blocks.CharBlock(max_length=255)
    test_textblock = blocks.TextBlock()
    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()
Пример #17
0
class LoguePage(Page):
    date = models.DateField("Post date")
    header_image = models.ForeignKey(
        "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+"
    )
    intro = models.CharField(max_length=250)
    body = StreamField(
        [
            ("heading", blocks.CharBlock(classname="full title")),
            ("paragraph", blocks.RichTextBlock()),
            ("block_quote", blocks.BlockQuoteBlock()),
            ("image", ImageChooserBlock()),
        ],
        null=True,
    )
    tags = ClusterTaggableManager(through=LoguePageTag, blank=True)
    categories = ParentalManyToManyField("logue.LogueCategory", blank=True)
    feed_image = models.ForeignKey(
        "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+"
    )

    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"),
        index.FilterField("date"),
    ]

    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [
                InlinePanel("logue_authors", label="Author", min_num=1, max_num=6),
                FieldPanel("date"),
                FieldPanel("tags"),
                FieldPanel("categories", widget=forms.CheckboxSelectMultiple),
            ],
            heading="Logue information",
        ),
        ImageChooserPanel("header_image"),
        FieldPanel("intro"),
        StreamFieldPanel("body"),
        InlinePanel("gallery_images", label="Gallery images"),
        InlinePanel("related_links", label="Related links"),
    ]

    promote_panels = [ImageChooserPanel("feed_image")]
Пример #18
0
class WfPage(Page):
    body = StreamField(
        [
            ("document", DocumentChooserBlock()),
            ("heading", blocks.CharBlock(classname="full title")),
            ("image", ImageChooserBlock()),
            (
                "paragraph",
                blocks.RichTextBlock(
                    features=[
                        "h2",
                        "h3",
                        "h4",
                        "bold",
                        "italic",
                        "ol",
                        "ul",
                        "hr",
                        "link",
                        "document-link",
                        "image",
                        "superscript",
                        "superscript",
                        "strikethrough",
                        "blockquote",
                    ]
                ),
            ),
            ("pullquote", blocks.BlockQuoteBlock()),
        ]
    )
    body_migrated = models.TextField(
        help_text="Used only for content from old Drupal website.",
        null=True,
        blank=True,
    )
    collection = models.ForeignKey(
        WfPageCollection,
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="pages",
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
        FieldPanel("collection"),
    ]

    class Meta:
        verbose_name = "Page"
        verbose_name_plural = "Pages"
Пример #19
0
class InlinedItemsBlock(blocks.StreamBlock):
    text = RichTextBlock(icon='edit')
    image = ImageChooserBlock(icon='image')
    blockquote = blocks.BlockQuoteBlock(icon='openquote')
    document = DocumentChooserBlock(icon='doc-full')
    email = blocks.EmailBlock(icon='mail')
    link = QuickLinkBlock(icon='link', template='blog/blocks/quick_link_block.html')

    class Meta:
        template = 'blog/blocks/inlined_items_block.html'
        icon = 'arrow-right'
        label = 'Block-Inline Items'
        help_text = 'A row of flex items justified to full page width with equal spacing between, only wrapping to new row when necessary.'
Пример #20
0
class TestStreamBlock(blocks.StreamBlock):
    test_charblock = blocks.CharBlock(max_length=255)
    test_textblock = blocks.TextBlock(label=__("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()
Пример #21
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)
Пример #22
0
class NewsPage(NewsRootMixin, Page):
    template = "web/news/news-details.html"
    parent_page_types = ["web.NewsListPage"]
    subpage_types = []
    body = StreamField([
        ("heading", blocks.CharBlock(form_classname="full title")),
        ("paragraph", blocks.RichTextBlock(features=RICH_TEXT_FEATURES)),
        ("image", ImageChooserBlock()),
        ("quote", blocks.BlockQuoteBlock()),
    ])
    promote_panels = [FieldPanel("slug")]
    settings_panels = [PrivacyModalPanel()]
    content_panels = Page.content_panels + [
        FieldPanel("owner", heading="Author"),
        FieldPanel("search_description", heading="Social description"),
        StreamFieldPanel("body"),
    ]
Пример #23
0
class LibraryItem(Page):
    publication_date = models.DateField("Publication date")
    body = StreamField([
        ("paragraph", blocks.RichTextBlock()),
        ("image", ImageChooserBlock()),
        ("document", DocumentChooserBlock()),
        ("embed", EmbedBlock()),
        ("url", blocks.URLBlock()),
        ("quote", blocks.BlockQuoteBlock()),
    ])
    item_audience = models.ForeignKey("facets.Audience",
                                      on_delete=models.SET_NULL,
                                      null=True)
    item_genre = models.ForeignKey("facets.Genre",
                                   on_delete=models.SET_NULL,
                                   null=True)
    item_medium = models.ForeignKey("facets.Medium",
                                    on_delete=models.SET_NULL,
                                    null=True)
    item_time_period = models.ForeignKey("facets.TimePeriod",
                                         on_delete=models.SET_NULL,
                                         null=True)

    content_panels = Page.content_panels + [
        InlinePanel(
            "authors",
            heading="Authors",
            help_text=
            "Select one or more authors, who contributed to this article",
        ),
        FieldPanel("publication_date"),
        StreamFieldPanel("body"),
        MultiFieldPanel(
            children=[
                FieldPanel("item_audience"),
                FieldPanel("item_genre"),
                FieldPanel("item_medium"),
                FieldPanel("item_time_period"),
                InlinePanel("topics", label="topics")
            ],
            heading="Categorization",
        ),
    ]

    parent_page_types = ["LibraryIndexPage"]
    subpage_types = []
Пример #24
0
class StandardPage(Page):

    section = StreamField([
        ('heading', HeadingBlock()),
        ('paragraph', blocks.RichTextBlock()),
        ('quote', blocks.BlockQuoteBlock()),
        ('image', ImageChooserBlock()),
        ('document', DocumentChooserBlock()),
        ('embed', EmbedBlock()),
        ('table', TableBlock()),
        ('person', SnippetChooserBlock(Person)),
        ('event', blocks.StaticBlock(admin_text='Latest events: no configuration needed.', template='')),



    ], blank=True)

    person = models.ForeignKey(
        'Person',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    # event = models.ForeignKey(
    #     'Event',
    #     null=True,
    #     blank=True,
    #     on_delete=models.SET_NULL,
    #     related_name='+'
    # )






    content_panels = Page.content_panels + [
        StreamFieldPanel('section'),
        InlinePanel('person_placements', label="people"),
        # SnippetChooserPanel('event'),



    ]
Пример #25
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"),
    ]
Пример #26
0
class ConstructionBlock(blocks.StreamBlock):
    heading = HeadingBlock(required=False, icon='title')
    richtext = blocks.RichTextBlock(icon='pilcrow', label='Rich Text')
    paragraph = blocks.TextBlock(icon='pilcrow',template='blog/blocks/text_block.html', label='Simple Text')
    blockquote = blocks.BlockQuoteBlock(icon='openquote')
    image = ImageChooserBlock(icon='image')
    video = EmbedBlock(icon='media')
    code = CodeBlock(icon='code')
    search = SearchBlock(icon='search')
    author = AuthorBlock(icon='user')
    document = DocumentChooserBlock(icon='doc-full')
    email = blocks.EmailBlock(icon='mail')
    linklist = blocks.ListBlock(
        QuickLinkBlock(), template='blog/blocks/linklist_block.html', icon='link')
    documentlist = blocks.ListBlock(DocumentChooserBlock(icon='doc-full'))

    class Meta:
        template = 'blog/blocks/construction_block.html'
        icon = 'placeholder'
        label = 'Construction Block'
Пример #27
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_pagechooserblock_with_restricted_types = blocks.PageChooserBlock([
        'wagtail_localize_test.TestHomePage', 'wagtail_localize_test.TestPage'
    ])
    test_imagechooserblock = ImageChooserBlock()
    test_documentchooserblock = DocumentChooserBlock()
    test_snippetchooserblock = SnippetChooserBlock(TestSnippet)
    test_nontranslatablesnippetchooserblock = SnippetChooserBlock(
        NonTranslatableSnippet)
    test_embedblock = EmbedBlock()
Пример #28
0
class BlogPage(Page):
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)
    #bodytwo = RichTextField(blank=True)
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('html', blocks.RawHTMLBlock()),
        ('quote', blocks.BlockQuoteBlock()),
    ])

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

    content_panels = Page.content_panels + [
        FieldPanel('date'),
        FieldPanel('intro'),
        #FieldPanel('body', classname="full"),
        StreamFieldPanel('body'),
    ]
Пример #29
0
class CustomBlock1(blocks.StructBlock):
    field_char = blocks.CharBlock(required=False)
    field_text = blocks.TextBlock(required=False)
    field_email = blocks.EmailBlock(required=False)
    field_int = blocks.IntegerBlock(required=False)
    field_float = blocks.FloatBlock(required=False)
    field_decimal = blocks.DecimalBlock(required=False)
    field_regex = blocks.RegexBlock(regex=r'^[0-9]{3}$', required=False)
    field_url = blocks.URLBlock(required=False)
    field_bool = blocks.BooleanBlock(required=False)
    field_date = blocks.DateBlock(required=False)
    field_time = blocks.TimeBlock(required=False)
    field_datetime = blocks.DateTimeBlock(required=False)
    field_rich = blocks.RichTextBlock(required=False)
    field_raw = blocks.RawHTMLBlock(required=False)
    field_quote = blocks.BlockQuoteBlock(required=False)
    field_choice = blocks.ChoiceBlock(choices=[('tea', 'Tea'),
                                               ('coffee', 'Coffee')],
                                      icon='cup',
                                      required=False)
    field_static = blocks.StaticBlock(required=False)
    field_list = blocks.ListBlock(blocks.CharBlock, required=False)
    field_list_2 = blocks.ListBlock(CustomBlockInner, required=False)
Пример #30
0
class BlogPage(Page):
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)

    body = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('html_paragraph', blocks.RawHTMLBlock()),
        ('quote', blocks.BlockQuoteBlock()),
        ('image', ImageChooserBlock()),
    ])

    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)

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

    def serve(self, request):
        from .forms import CommentForm
        post = self.blogpage
        comments = post.comments.filter(active=True, parent__isnull=True)
        new_comment = None

        # Comment posted
        if request.method == 'POST':
            comment_form = CommentForm(request.POST)

            if comment_form.is_valid():
                parent_obj = None
                # get parent comment id from hidden input
                try:
                    # id integer e.g. 15
                    parent_id = int(request.POST.get('parent_id'))
                except:
                    parent_id = None
                # if parent_id has been submitted get parent_obj id
                if parent_id:
                    parent_obj = Comment.objects.get(id=parent_id)
                    # if parent object exist
                    if parent_obj:
                        # create reply comment object
                        reply_comment = comment_form.save(commit=False)
                        # assign parent_obj to reply comment
                        reply_comment.parent = parent_obj
            # normal comment

            # Create Comment object but don't save to database yet
                new_comment = comment_form.save(commit=False)
                # Assign the current post to the comment
                new_comment.post_id = self.id
                # Save the comment to the database
                new_comment.save()
                return render(
                    request, self.template, {
                        'page': self,
                        'new_comment': new_comment,
                        'comments': comments,
                    })

        else:
            comment_form = CommentForm()

        return render(
            request, self.template, {
                'page': self,
                'new_comment': new_comment,
                'comments': comments,
                'comment_form': comment_form,
            })

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

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