Ejemplo n.º 1
0
class LandingPage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname='full title')),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock(icon='image')),
        ('two_columns', TwoColumnBlock()),
        ('embedded_video', EmbedBlock(icon='media'))
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel('body')
    ]
Ejemplo n.º 2
0
class LandingPage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock(icon="image")),
        ('two_columns', TwoColumnBlock()),
        ('embedded_video', EmbedBlock(icon="media")),
    ],null=True,blank=True)

    add_page_1 = models.CharField(max_length=255, blank=True, null=True,)
    link_to_page_1 = models.CharField(max_length=255, blank=True, null=True,)
    add_page_2 = models.CharField(max_length=255, blank=True, null=True,)
    link_to_page_2 = models.CharField(max_length=255, blank=True, null=True,)
    add_page_3 = models.CharField(max_length=255, blank=True, null=True,)
    link_to_page_3 = models.CharField(max_length=255, blank=True, null=True,)
    add_page_4 = models.CharField(max_length=255, blank=True, null=True,)
    link_to_page_4 = models.CharField(max_length=255, blank=True, null=True,)
    add_page_5 = models.CharField(max_length=255, blank=True, null=True,)
    link_to_page_5 = models.CharField(max_length=255, blank=True, null=True,)
    add_page_6 = models.CharField(max_length=255, blank=True, null=True,)
    link_to_page_6 = models.CharField(max_length=255, blank=True, null=True,)

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
        FieldPanel('add_page_1'),
        FieldPanel('link_to_page_1'),
        FieldPanel('add_page_2'),
        FieldPanel('link_to_page_2'),
        FieldPanel('add_page_3'),
        FieldPanel('link_to_page_3'),
        FieldPanel('add_page_4'),
        FieldPanel('link_to_page_4'),
        FieldPanel('add_page_5'),
        FieldPanel('link_to_page_5'),
        FieldPanel('add_page_6'),
        FieldPanel('link_to_page_6'),
    ]

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

    def get_context(self, request, *args, **kwargs):
        context = super(LandingPage, self).get_context(request, *args, **kwargs)
        context['blog_page'] = self.blog_page
        context['landing'] = self
        return context
Ejemplo n.º 3
0
class LandingPage(Page):

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

    body = StreamField([
        ('header', PageHeadingBlock()),
        ('description',
         blocks.CharBlock(required=False, icon="text-full",
                          label="sub-title")),
        ('single_column', ConstructionBlock()),
        ('two_columns', TwoColumnBlock()),
        ('column_w_sidebar', LeftColumnWithSidebarBlock()),
        ('flex_row', InlinedItemsBlock()),
    ],
                       null=True,
                       blank=True)

    # Parent page / subpage type rules

    parent_page_types = ['home.HomePage', 'blog.LandingPage']
    subpage_types = ['blog.LandingPage']

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

    @property
    def get_blog_pages(self):
        return BlogPage.objects.sibling_of(self).live()

    @property
    def blog_page(self):
        self.blog_pages = self.get_blog_pages
        return self.blog_pages.first()

    def get_context(self, request, *args, **kwargs):
        context = super(LandingPage, self).get_context(request, *args,
                                                       **kwargs)
        context['page_author'] = self.owner
        context['blog_page'] = self.blog_page
        return context
Ejemplo n.º 4
0
class PostPage(Page):
    date = models.DateTimeField(verbose_name="Post date",
                                default=datetime.datetime.today)
    categories = ParentalManyToManyField('blog.BlogCategory', blank=True)
    tags = ClusterTaggableManager(through='blog.BlogPageTag', blank=True)
    header = StreamField([
        ('page_header', PageHeaderBlock()),
    ],
                         null=True,
                         blank=True)
    body = StreamField([
        ('single_column', ConstructionBlock()),
        ('column_w_sidebar', LeftColumnWithSidebarBlock()),
        ('two_columns', TwoColumnBlock(icon="grip")),
        ('three_columns', ThreeColumnBlock(icon="table")),
        ('flex_row', InlinedItemsBlock()),
    ],
                       null=True,
                       blank=True)

    parent_page_types = ['blog.BlogPage']

    content_panels = Page.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('body'),
        FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        FieldPanel('tags'),
    ]

    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
        context['page_author'] = self.owner
        return context
Ejemplo n.º 5
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
Ejemplo n.º 6
0
class BlogPage(Page):
    date = models.DateField("Post date")
    description = models.CharField(max_length=250, blank=True)
    tags = ClusterTaggableManager(through='blog.BlogTag', blank=True)
    categories = ParentalManyToManyField('blog.BlogCategory', blank=True)

    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('two_columns', TwoColumnBlock()),
        ('three_columns', ThreeColumnBlock()),
        ('image', ImageChooserBlock()),
        ('htmljs', blocks.TextBlock()),
        ('code_bash', blocks.TextBlock()),
        ('code_py', blocks.TextBlock()),
        ('code_htmljs', blocks.TextBlock()),
    ],
                       null=True,
                       blank=True)

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

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

    def get_context(self, request):
        #update context: adding catgories list for side widget
        context = super().get_context(request)
        SetContext(context)
        return context
Ejemplo n.º 7
0
class LandingPage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock(icon="image")),
        ('two_columns', TwoColumnBlock()),
        ('embedded_video', EmbedBlock(icon="media")),
    ], null=True, blank=True)

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

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

    def get_context(self, request, *args, **kwargs):
        context = super(LandingPage, self).get_context(request, *args, **kwargs)
        context['blog_page'] = self.blog_page
        return context
Ejemplo n.º 8
0
class BlogPage(RoutablePageMixin, Page):

    header = StreamField([
        ('page_header', PageHeaderBlock()),
    ],
                         null=True,
                         blank=True)
    body = StreamField([
        ('single_column', ConstructionBlock()),
        ('column_w_sidebar', LeftColumnWithSidebarBlock()),
        ('two_columns', TwoColumnBlock(icon="grip")),
        ('three_columns', ThreeColumnBlock(icon="table")),
        ('flex_row', InlinedItemsBlock()),
        ('flex_row', InlinedItemsBlock()),
    ],
                       null=True,
                       blank=True)

    parent_page_types = ['home.HomePage']
    subpage_types = ['blog.PostPage', 'blog.LandingPage']

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

    def get_context(self, request, *args, **kwargs):
        context = super(BlogPage, self).get_context(request, *args, **kwargs)
        context['posts'] = self.posts
        context['blog_page'] = self
        context['page_author'] = self.owner
        context['search_type'] = getattr(self, 'search-type', "")
        context['search_term'] = getattr(self, 'search-term', "")
        context['menuitems'] = self.get_children().filter(live=True,
                                                          show_in_menus=True)
        return context

    def get_posts(self):
        return PostPage.objects.descendant_of(self).live()

    @route(r'^(\d{4})/$')
    @route(r'^(\d{4})/(\d{2})/$')
    @route(r'^(\d{4})/(\d{2})/(\d{2})/$')
    def post_by_date(self,
                     request,
                     year,
                     month=None,
                     day=None,
                     *args,
                     **kwargs):
        self.posts = self.get_posts().filter(date__year=year)
        self.search_type = 'date'
        self.search_term = year
        if month:
            self.posts = self.posts.filter(date__month=month)
            df = DateFormat(date(int(year), int(month), 1))
            self.search_term = df.format('F Y')
        if day:
            self.posts = self.posts.filter(date__day=day)
            self.search_term = date_format(
                date(int(year), int(month), int(day)))
        return Page.serve(self, request, *args, **kwargs)

    @route(r'^(\d{4})/(\d{2})/(\d{2})/(.+)/$')
    def post_by_date_slug(self, request, year, month, day, slug, *args,
                          **kwargs):
        post_page = self.get_posts().filter(slug=slug).first()
        if not post_page:
            raise Http404
        return Page.serve(post_page, request, *args, **kwargs)

    @route(r'^tag/(?P<tag>[-\w]+)/$')
    def post_by_tag(self, request, tag, *args, **kwargs):
        self.search_type = 'tag'
        self.search_term = tag
        self.posts = self.get_posts().filter(tags__slug=tag)
        return Page.serve(self, request, *args, **kwargs)

    @route(r'^category/(?P<category>[-\w]+)/$')
    def post_by_category(self, request, category, *args, **kwargs):
        self.search_type = 'category'
        self.search_term = category
        self.posts = self.get_posts().filter(categories__slug=category)
        return Page.serve(self, request, *args, **kwargs)

    @route(r'^$')
    def post_list(self, request, *args, **kwargs):
        self.posts = self.get_posts()
        return Page.serve(self, request, *args, **kwargs)

    @route(r'^search/$')
    def blog_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)
Ejemplo n.º 9
0
class LandingPage(
        BasePost
):  # a special type of post page (I intend to use it for game devlog)

    Page = TranslatablePage
    project_overview = models.BooleanField(default=False)
    banner = models.ForeignKey('wagtailimages.Image',
                               on_delete=models.SET_NULL,
                               related_name='+',
                               blank=True,
                               null=True)
    title_color = ColorField(default='#FFFFFF')
    tilable_banner = models.BooleanField(default=False)
    intro = models.CharField(
        max_length=255,
        blank=True,
    )

    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('code', blocks.TextBlock()),
        ('code_output', blocks.TextBlock()),
        ('image', ImageChooserBlock(icon="image")),
        ('two_columns', TwoColumnBlock()),
        ('embedded_video', EmbedBlock(icon="media")),
        ('custom_html', blocks.TextBlock(icon='plus-inverse')),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            ImageChooserPanel('banner'),
            FieldPanel('tilable_banner'),
            FieldPanel('title_color')
        ],
                        heading='Banner'),
        FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        FieldPanel('intro'),
        StreamFieldPanel('body'),
        PageChooserPanel(
            'related_page1',
            ['blog.PostPage', 'blog.LandingPage', 'blog.LandingPost']),
        PageChooserPanel(
            'related_page2',
            ['blog.PostPage', 'blog.LandingPage', 'blog.LandingPost']),
        # InlinePanel('related_links', label="Related Links"),
    ]
    settings_panels = Page.settings_panels + [
        FieldPanel('date'),
        FieldPanel('project_overview'),
        ImageChooserPanel('thumbnail'),
        MultiFieldPanel([
            FieldPanel('is_series'),
            FieldPanel('series_name'),
            FieldPanel('series_id')
        ],
                        heading='SeriesSetting',
                        classname="collapsible collapsed"),
    ]

    def get_context(self, request, *args, **kwargs):
        context = super().get_context(request, *args, **kwargs)
        return context