Esempio n. 1
0
class HomePage(Page):
    lead_image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )

    content = StreamField(
        [
            ("cta", blocks.CTABlock()),
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("left_card_block", blocks.LeftCardBlock()),
            ("right_card_block", blocks.RightCardBlock()),
            ("three_image_block", blocks.ThreeCardBlock()),
            ("two_image_block", blocks.TwoImageBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        ImageChooserPanel("lead_image"),
        StreamFieldPanel("content"),
    ]

    class Meta:
        verbose_name = "Home Page"
        verbose_name_plural = "Home Pages"
Esempio n. 2
0
class BlogDetailPage(Page):
    """Blog detail page."""

    custom_title = models.CharField(
        max_length=100,
        blank=False,
        null=False,
        help_text='Overwrites the default title',
    )
    blog_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=False,
        null=True,
        related_name="+",
        on_delete=models.SET_NULL,
    )

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("custom_title"),
        ImageChooserPanel("blog_image"),
        StreamFieldPanel("content"),
    ]
Esempio n. 3
0
class BlogAbout(Page):
    subpage_types = []
    max_count = 1
    address = models.CharField(max_length=250, blank=True, null=True)
    location = models.CharField(max_length=250, blank=True, null=True)

    content = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("Full_richtext", blocks.RichtextBlock()),
        ("card_block", blocks.CardBlock()),
    ],
                          null=True,
                          blank=True)
    subtitle = models.CharField(max_length=250, blank=True, null=True)
    content_panels = Page.content_panels + [
        FieldPanel('subtitle'),
        StreamFieldPanel("content"),
        MultiFieldPanel([
            FieldPanel('address'),
            GeoPanel('location', address_field='address'),
        ], _('Geo details')),
    ]

    @cached_property
    def point(self):
        return geosgeometry_str_to_struct(self.location)

    @property
    def lat(self):
        return self.point['y']

    @property
    def lng(self):
        return self.point['x']
Esempio n. 4
0
class BlogIndexPage(Page):
    """Blog Index Page"""
    template = "blog/blog_index_page.html"     

    intro = RichTextField(blank=True)
    content = StreamField(
        [
            ("title_and_text", my_blocks.TitleAndTextBlock()),
            ("cards", my_blocks.CardBlock()),
            ('embed', EmbedBlock(icon="media")),
        ],
        blank=True,
    )

    subtitle = models.CharField(max_length=100, blank=True)
    
    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content"),
    ]
    def get_context(self, request):
        # Update context to include only published posts, 
        # in reverse chronological order
        context = super(BlogIndexPage, self).get_context(request)
        live_blogpages = self.get_children().live()
        context['blogpages'] = live_blogpages.order_by('-first_published_at')
        return context
Esempio n. 5
0
class BlogDetailPage(Page):
    """Detail blog articles"""
    custom_title = models.CharField(
        max_length=100,
        blank=False,
        null=False,
        help_text="Custom title from blog detail page")
    blog_image = models.ForeignKey("wagtailimages.Image",
                                   blank=False,
                                   null=True,
                                   help_text="Blog article image",
                                   related_name="+",
                                   on_delete=models.SET_NULL)

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("custom_title"),
        ImageChooserPanel("blog_image"),
        StreamFieldPanel("content"),
    ]
Esempio n. 6
0
class FlexPage(Page):
    """Flexibile page class."""
    subpage_types = []

    template = "flex/flex_page.html"

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
        ],
        null=True,
        blank=True,
    )

    subtitle = models.CharField(max_length=100, null=True, blank=True)

    flex_image = models.ForeignKey("wagtailimages.Image",
                                   null=True,
                                   blank=False,
                                   on_delete=models.SET_NULL,
                                   related_name="+")

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        ImageChooserPanel("flex_image"),
        StreamFieldPanel("content"),
    ]

    class Meta:  # noqa
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 7
0
class HomePage(Page):

    templates = "home/hompage_page.html"

    carousel_images = StreamField(blocks.CarouselBlock(max_num=3,
                                                       required=False),
                                  blank=True,
                                  null=True)

    content = StreamField(
        [
            ('team', blocks.TeamCards()),
            ('image', blocks.ImageBlock()),
            ("jumbotron", blocks.ActionAreaBlock()),
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel("carousel_images"),
        StreamFieldPanel("content"),
    ]

    class Meta:
        verbose_name = "Home Page"
        verbose_name_plural = "Home Pages"
Esempio n. 8
0
class ProjectDetailPage(Page):
    """Project Detail Page"""
    custom_title = models.CharField(
        max_length=100,
        blank=False,
        null=False,
        help_text='Overwrites the default content.')
    project_image = models.ForeignKey("wagtailimages.Image",
                                      blank=False,
                                      null=True,
                                      related_name="+",
                                      on_delete=models.SET_NULL)

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichTextBlock()),
            ("cards", blocks.CardBlock()),
        ],
        null=True,
        blank=True,
    )

    categories = ParentalManyToManyField("project.ProjectCategory", blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("custom_title"),
        ImageChooserPanel("project_image"),
        MultiFieldPanel(
            [FieldPanel("categories", widget=forms.CheckboxSelectMultiple)],
            heading="Categories"),
        StreamFieldPanel("content"),
    ]
Esempio n. 9
0
class StandardPage(Page):
    """Standard page class."""

    template = "standard/standard_page.html"

    # @todo add streamfields
    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
        ],
        null=True,
        blank=True,
    )
    page_image = models.ForeignKey("wagtailimages.Image",
                                   null=True,
                                   blank=False,
                                   on_delete=models.SET_NULL,
                                   related_name="+")

    subtitle = models.CharField(max_length=100, null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        ImageChooserPanel("page_image"),
        StreamFieldPanel("content"),
    ]

    class Meta:  # noqa
        verbose_name = "Standard Page"
        verbose_name_plural = "Standard Pages"
Esempio n. 10
0
class BlogDetailPage(Page):
    """Blog detail page"""
    custom_title = models.CharField(max_length=100,
                                    blank=False,
                                    null=False,
                                    help_text='Overwrites the default title')
    blog_image = models.ForeignKey('wagtailimages.Image',
                                   blank=False,
                                   null=True,
                                   related_name='+',
                                   on_delete=models.SET_NULL)

    content = StreamField([
        ('title_and_text', blocks.TitleAndTextBlock()),
        ('full_richtext', blocks.RichtextBlock()),
        ('simple_richtext', blocks.SimpleRichtextBlock()),
        ('cards', blocks.CardBlock()),
        ('cta', blocks.CTABlock()),
    ],
                          null=True,
                          blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('custom_title'),
        ImageChooserPanel('blog_image'),
        StreamFieldPanel('content'),
    ]
Esempio n. 11
0
class FlexPage(Page):
    """flexbile page class"""

    template = "flex/flex_page.html"
    parent_page_types = ['flex.FlexPage', 'home.HomePage']
    subpage_types = ['flex.FlexPage']

    subtitle = models.CharField(max_length=100, null=True, blank=True)

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichTextBlock()),
            ("simple_richtext", blocks.SimpleRichTextBlock()),
            # ("simple_richtext", blocks.SimpleRichTextBlock(features=["bold", "italic"])),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
            ("button", blocks.ButtonBlock()),
        ],
        null=True,
        blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content"),
    ]

    class Meta:  # noqa

        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 12
0
class BlogPage(Page):
	date = models.DateField("Post Date")
	intro = models.CharField(max_length = 250)
	body = RichTextField(blank = True)
	tags = ClusterTaggableManager(through=BlogTag, blank = True)
	categories = ParentalManyToManyField('blog.BlogCategory', blank = True)

	content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
			("cards", blocks.CardBlock()),
			("cta", blocks.CTABlock()),
        ],
        null=True,
        blank=True,
    )

	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("content"),
		InlinePanel('gallery_images', label = "Gallery images"),
	]
Esempio n. 13
0
class HomePage(Page):
    body = RichTextField(blank=True, default="")

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

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        MultiFieldPanel([ImageChooserPanel('image')],
                        heading=" Common Fields"),
        MultiFieldPanel([
            FieldPanel('body'),
            StreamFieldPanel('content'),
        ],
                        heading="Translatable fields")
    ]
Esempio n. 14
0
class FlexPage(Page):
    """
    Flex page model
    """

    template = "flex/flex.html"

    # Django models
    subtitle = models.CharField(max_length=100, null=True, blank=True)

    # Wagtail models
    content = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("full_rich_text", blocks.FullRichTextBlock()),
        ("simple_rich_text", blocks.SimpleRichTextBlock()),
        ("cards_blocks", blocks.CardBlock()),
    ],
                          blank=True,
                          null=True)

    # Add the all of fields to Wagtail panels
    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content"),
    ]

    class Meta:
        verbose_name = "Flex page"
        verbose_name_plural = "Flex pages"
Esempio n. 15
0
class FlexPage(Page):

    template = "flex/flex_page.html"

    #@todo add streamfields
    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock())
        ],
        null=True,
        blank=True,
    )

    subtitle = models.CharField(max_length=100, null=True, blank=True)
    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content"),
        ]

    class Meta:
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 16
0
class FlexPage(Page):
    # @remember:
    # This page generates the blocks/streamfields on the your flex_page.html.
    # Copy/Paste this whole class to make other pages flexibe,
    # Change the template.
    template = 'flex/flex_page.html'

    # @remember:
    # This is the content being rendered on the flex_page.html
    content = StreamField(
        [
            ('title_and_text', blocks.TitleAndTextBlock()),
            ('full_richtext', blocks.RichTextBlock()),
            ('simple_richtext', blocks.SimpleRichTextBlock()),
            ('service_cards', blocks.CardBlock()),

        ],
        null=True,
        blank=True
    )

    subtitle = models.CharField(max_length=150, null=True, blank=True)

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

    class Meta:
        verbose_name = 'Flex Page'
        verbose_name_plural = 'Flex Pages'
Esempio n. 17
0
class HomeFlexPage(Page):
    template = 'home/home_page.html'

    content = StreamField(
        [
            ('title_and_text', blocks.TitleAndTextBlock()),
            ('full_richtext', blocks.RichTextBlock()),
            ('simple_richtext', blocks.SimpleRichTextBlock()),
            ('service_cards', blocks.CardBlock()),

        ],
        null=True,
        blank=True
    )

    subtitle = models.CharField(max_length=150, null=True, blank=True)

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

    class Meta:
        verbose_name = 'Flexed Home Page'
        verbose_name_plural = 'Flexed Home Pages'
Esempio n. 18
0
class FlexPage(Page):
    template = "flex/flex_page.html"

    banner_title = models.CharField (max_length=100, blank=False, null=True)
    banner_subtitle = models.CharField (max_length=100, blank=False, null=True)
    banner_image = models.ForeignKey(
        "wagtailimages.Image",
        null = True,
        blank = False,
        on_delete = models.SET_NULL,
        related_name = "+",
    )
    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.FullRichTextBlock()),
            ("cards", blocks.CardBlock())
        ],
        null= True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("banner_title"),
        FieldPanel("banner_subtitle"),
        ImageChooserPanel("banner_image"),
        StreamFieldPanel("content"),
    ]

    class Meta:
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 19
0
class BlogDetailPage(Page):
    """Blog detail page."""

    template = "blog/blog_detail_page.html"

    custom_title = models.CharField(max_length=100,
                                    blank=False,
                                    null=False,
                                    help_text="Overwrites the default title.")

    blog_image = models.ForeignKey("wagtailimages.Image",
                                   blank=False,
                                   null=True,
                                   related_name="+",
                                   on_delete=models.SET_NULL)

    content = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("full_rich_text", blocks.RichTextBlock()),
        ("simple_richtext", blocks.SimpleRichTextBlock()),
        ("cards", blocks.CardBlock()),
        ("call_to_action", blocks.CTABlock()),
    ],
                          null=True,
                          blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('custom_title'),
        ImageChooserPanel('blog_image'),
        StreamFieldPanel("content")
    ]
Esempio n. 20
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    max_count = 1

    standard = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("richtext", blocks.RichtextBlock()),
        ("simplerichtext", blocks.SimpleRichtextBlock()),
        ("buttons", blocks.ButtonBlock()),
    ],
                           null=True,
                           blank=True)

    sections = StreamField([
        ("cards", blocks.CardBlock()),
        ("products", blocks.ProductCardBlock()),
        ("cta", blocks.CTABlock()),
    ],
                           null=True,
                           blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("standard"),
        StreamFieldPanel("sections"),
    ]

    api_fields = [
        APIField("standard"),
        APIField("sections"),
    ]
Esempio n. 21
0
class FlexPage(Page):

    template = "flex/flex_page.html"

    parent_page_types = [
        'flex.Flexpage',
        'home.HomePage',
    ]
    subpage_types = [
        'flex.FlexPage',
        'contact.ContactPage',
    ]
    subtitle = models.CharField(max_length=100, null=True, blank=True)

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichTextBlock()),
            ("cards", blocks.CardBLock()),
            ("cta", blocks.CTABlock()),
            ("button_block", blocks.ButtonBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content")
    ]

    class Meta:
        verbose_name = "Flex Page"
        verbose_name_plural = "flex pages"
Esempio n. 22
0
class FlexPage(Page):
    """Flexible page class."""

    template = "flex/flex_page.html"

    content = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("full_richtext", blocks.RichtextBlock()),
        ("simple_richtext", blocks.SimpleRichTextBlock()),
        ("cards", blocks.CardBlock()),
        ("cta", blocks.CTABlock()),
        ("button", blocks.ButtonBlock()),
    ],
                          null=True,
                          blank=True)

    subtitle = models.CharField(max_length=100, null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content"),
    ]

    class Meta:  # noqa
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 23
0
class FlexPage(Page):
    """Flexible page class"""

    template = 'flex/flex_page.html'

    content = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("RichText_Tool", blocks.RichtextBlock()),
        ("Simple_RichText_Tool", blocks.SimpleRichtextBlock()),
        ("Cards", blocks.CardBlock()),
        ("Call_to_action", blocks.CTABlock()),
        ("Button_Url", blocks.ButtonBlock()),
    ],
                          null=True,
                          blank=True)

    subtitle = models.CharField(max_length=100, blank=True, null=True)

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

    class Meta:  # noqa

        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 24
0
class JournalPage(Page):
    """Journal page class."""

    template = "journal/journal_page.html"
    
    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("Raw_HTML", blocks.RawHTMLBlock()),
            ("cards", blocks.CardBlock()),
        ],
        null=True,
        blank=True,
    )

    subtitle = models.CharField(max_length=100, null=True, blank = True)

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content"),
    ]

    class Meta: # noqa
        verbose_name = "Journal Page"
        verbose_name_plural = "Journal Pages"
Esempio n. 25
0
class FlexPage(Page):
    template = "flex/flex_page.html"

    content = StreamField([
        ("column_wide_image", blocks.ColumnWideImageBlock()),
        ("cta", blocks.CTABlock()),
        ("left_card_block", blocks.LeftCardBlock()),
        ("full_richtext", blocks.RichtextBlock()),
        ("right_card_block", blocks.RightCardBlock()),
        ("three_image_block", blocks.ThreeCardBlock()),
        ("two_column_text", blocks.TwoColumnTextBlock()),
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("two_image_block", blocks.TwoImageBlock()),
    ],
                          null=True,
                          blank=True)

    subtitle = models.CharField(max_length=100, null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content"),
    ]

    class Meta:
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 26
0
class BlogDetailPage(Page):
    """Parental blog detail page."""

    subpage_types = []
    parent_page_types = ['blog.BlogListingPage']
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
    custom_title = models.CharField(
        max_length=100,
        blank=False,
        null=False,
        help_text='Overwrites the default title',
    )
    banner_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=False,
        null=True,
        related_name="+",
        on_delete=models.SET_NULL,
    )

    categories = ParentalManyToManyField("blog.BlogCategory", blank=True)

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("custom_title"),
        FieldPanel("tags"),
        ImageChooserPanel("banner_image"),
        MultiFieldPanel([
            InlinePanel("blog_authors", label="Author", min_num=1, max_num=4)
        ],
                        heading="Author(s)"),
        MultiFieldPanel(
            [FieldPanel("categories", widget=forms.CheckboxSelectMultiple)],
            heading="Categories"),
        StreamFieldPanel("content"),
    ]

    api_fields = [
        APIField("blog_authors"),
        APIField("content"),
    ]

    def save(self, *args, **kwargs):
        """Create a template fragment key.

        Then delete the key."""
        key = make_template_fragment_key("blog_post_preview", [self.id])
        cache.delete(key)
        return super().save(*args, **kwargs)
Esempio n. 27
0
class NewsPage(Page) : 
    """  News page temaple"""
    template = "news/news_page.html"
     
    # @todo add streamfields
    content_stream = StreamField(
        [
            ("title_and_text", my_blocks.TitleAndTextBlock()),
            ("full_richText",  my_blocks.RichTextBlock()),
            ("simple_richText",  my_blocks.SimpleRichTextBlock()),
            ("cards", my_blocks.CardBlock()),
            ("cta", my_blocks.CtaBlock()),
            ("button_url",my_blocks.ButtonBlock()),
            ("char_block", blocks.CharBlock(
                required=True,
                help_text='Oh wow this is help text!!',
                min_length=10,
                max_length=50,
                template="streams/char_block.html",
            ))
        ],
        null = True,
        blank = True
    )

    subtitle = models.CharField(max_length = 100 , null = True , blank = True)

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        StreamFieldPanel("content_stream")
    ]

    class Meta:
        verbose_name = "News Page"
        verbose_name_plural = "News Pages"
Esempio n. 28
0
class BlogDetailPage(Page):
    """Parental blog detail page."""

    parent_page_types = ['blog.BlogListingPage']
    subpage_types = []

    # author = models.ForeignKey(User, on_delete=models.CASCADE, related_name="posts", null=True, blank=True)

    custom_title = models.CharField(
        max_length=100,
        blank=False,
        null=False,
        help_text='Overwrites the default title',
        # verbose_name="タイトル"
    )
    banner_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=False,
        null=True,
        related_name="+",
        on_delete=models.SET_NULL,
    )
    image_alt = models.CharField(
        max_length=100,
        blank=True,
        null=True,
        help_text='Add some alt text',
    )

    categories = ParentalManyToManyField("blog.BlogCategory",
                                         blank=True,
                                         related_name="posts")
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)

    content = StreamField(
        [
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichTextBlock()),
            ("simple_richtext", blocks.SimpleRichTextBlock()),
            # ("simple_richtext", blocks.SimpleRichTextBlock(features=["bold", "italic"])),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
        ],
        null=True,
        blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("custom_title"),
        ImageChooserPanel("banner_image"),
        FieldPanel("image_alt", heading="Image Alt (Option)"),
        MultiFieldPanel([
            InlinePanel("blog_authors", label="Author", min_num=1, max_num=4)
        ],
                        heading="Author(s)"),
        FieldPanel("categories", widget=forms.CheckboxSelectMultiple),
        FieldPanel("tags"),
        StreamFieldPanel("content"),
    ]
Esempio n. 29
0
class BlogPage(RoutablePageMixin, Page):
    subpage_types = []
    parent_page_types = ['blogger.BlogIndexPage']
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)
    body = RichTextField(blank=True)
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
    categories = ParentalManyToManyField('blogger.BlogCategory', blank=True)
    release = models.IntegerField(default=2000)

    sequel = StreamField([
        ('title_and_text', blocks.TitleAndTextBlock()),

    ], null=True,
        blank=True
    )

    @route(r'^search/$', name="post_search")
    def post_search(self, request, *args, **kwargs):
        search_query = request.GET.get('q', None)
        self.posts = self.get_posts()
        if search_query:
            self.posts = self.posts.filter(body__contains=search_query)
            self.search_term = search_query
            self.search_type = 'search'
        return Page.serve(self, request, *args, **kwargs)

    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('release'),
            FieldPanel('tags'),
            FieldPanel("categories", widget=forms.CheckboxSelectMultiple),
            InlinePanel('customcomments', label='Comments'),

        ], heading='Blog information'),
        FieldPanel('intro'),
        FieldPanel('body', classname='full'),
        InlinePanel('gallery_images', label='Gallery Images'),
        StreamFieldPanel("sequel"),
    ]

    def get_absolute_url(self):
        return self.get_url()
Esempio n. 30
0
class BlogDetailPage(Page):
    """ Parental blog Detail page """

    subpage_types = []
    parent_page_types = ['blog.BlogListingPage']
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)

    custom_title = models.CharField(
        max_length=100,
        blank=False,
        null=False,
        help_text='Add your title',
    )

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

    categories = ParentalManyToManyField('blog.BlogCategory', blank=True)

    content = StreamField([
        ('title_and_text', blocks.TitleAndTextBlock()),
        ('full_richtext', blocks.RichTextBlock()),
        ('cards', blocks.CardBlock()),
        ('cta', blocks.CTABlock()),
    ],
                          null=True,
                          blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('custom_title'),
        FieldPanel("tags"),
        ImageChooserPanel('banner_image'),
        StreamFieldPanel('content'),
        MultiFieldPanel([
            InlinePanel('blog_authors', label='Author', min_num=1, max_num=4)
        ],
                        heading='Authors'),
        MultiFieldPanel(
            [FieldPanel('categories', widget=forms.CheckboxSelectMultiple)],
            heading='Categories'),
    ]

    api_fields = [
        APIField('blog_authors'),
        APIField('content'),
    ]

    def save(self, *args, **kwargs):
        key = make_template_fragment_key('blog_post_preview', [self.id])
        cache.delete(key)
        return super().save(*args, **kwargs)