Пример #1
0
class FlexPage(Page):
    parent_page_types = ["home.HomePage", "flex.FlexPage"]
    body = StreamField(
        [("title", blocks.TitleBlock()), ("cards", blocks.CardsBlock()),
         ("image_and_text", blocks.ImageAndTextBlock()),
         ("cta", blocks.CallToActionBlock()),
         ("testimonial",
          SnippetChooserBlock(
              target_model='testimonials.Testimonial',
              template="streams/testimonial_block.html",
          )),
         ("pricing_table",
          blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS, )),
         ("richtext",
          wagtail_blocks.RichTextBlock(
              template="streams/simple_richtext_block.html",
              features=["bold", "italic", "ol", "ul", "link"])),
         ("large_image",
          ImageChooserBlock(
              help_text='This image will be cropped to 1200px by 775px',
              template="streams/large_image_block.html"))],
        null=True,
        blank=True)

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

    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"
Пример #2
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage", "services.ServiceListingPage", "contact.ContactPage"]
    max_count = 1
    lead_text = models.CharField(
        max_length=140,
        blank=True,
        help_text='Subheading text under the banner title',
    )
    button = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name='+',
        help_text='Select an optional page to link to',
        on_delete=models.SET_NULL,
    )
    button_text = models.CharField(
        max_length=50,
        default='Read More',
        blank=False,
        help_text='Button text',
    )
    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        help_text='The banner background image',
        on_delete=models.SET_NULL,
    )
    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("cards", blocks.CardsBlock()),
        ("image_and_text", blocks.ImageAndTextBlock()),
        ("cta", blocks.CallToActionBlock()),
        ("testimonial", SnippetChooserBlock(
            target_model='testimonials.Testimonial',
            template="streams/testimonial_block.html",
        )),
        ("pricing_table", blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS)),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]

    def save(self, *args, **kwargs):

        key = make_template_fragment_key(
            "home_page_streams",
            [self.id],
        )
        cache.delete(key)

        return super().save(*args, **kwargs)
Пример #3
0
class FlexPage(Page):

    parent_page_types = ['home.HomePage', 'flex.FlexPage']

    body = StreamField(
        [
            ('title', blocks.TitleBlock()),
            ('cards', blocks.CardsBlock()),
            ('image_and_text', blocks.ImageAndTextBlock()),
            ('cta', blocks.CallToActionBlock()),
            # ('richtext_with_title', blocks.RichTextWithTitleBlock()), # Optional way of doing richtext
            ('richtext',
             wagtail_blocks.RichTextBlock(
                 template='streams/simple_richtext_block.html',
                 features=[
                     'h3', 'bold', 'italic', 'ol', 'ul', 'hr', 'link',
                     'document-link', 'image'
                 ])),
        ],
        null=True,
        blank=True)

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

    class Meta:
        verbose_name = 'Flex (misc) page'
        verbose_name_plural = 'Flex (misc) pages'
Пример #4
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage", "services.ServiceListingPage"]
    max_count = 1

    lead_text = models.CharField(max_length=140,
                                 blank=True,
                                 help_text="Banner title here")
    button = models.ForeignKey(
        "wagtailcore.Page",
        blank=True,
        null=True,
        related_name="+",
        help_text="Select an optional page link to",
        on_delete=models.SET_NULL,
    )
    button_text = models.CharField(
        max_length=50,
        default="Read more",
        blank=False,
        help_text="Button text",
    )
    banner_background_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=False,
        null=True,
        related_name="+",
        help_text="The banner background image",
        on_delete=models.SET_NULL,
    )

    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("ImageAndTextBlock", blocks.ImageAndTextBlock()),
            ("cta", blocks.CallToActionBlock()),
            (
                "testimonial",
                SnippetChooserBlock(
                    target_model="testimonials.Testimonial",
                    template="streams/testimonial_block.html",
                ),
            ),
            (
                "pricing_table",
                blocks.PrincingTableBlock(table_options=NEW_TABLE_OPTIONS),
            ),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]
Пример #5
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage"]
    max_count = 1
    lead_text = models.CharField(
        max_length=140,
        blank=True,
        help_text="Subheading text under the banner title",
    )

    button = models.ForeignKey(
        "wagtailcore.Page",
        blank=True,
        null=True,
        related_name="+",
        on_delete=models.SET_NULL,
    )

    button_text = models.CharField(
        max_length=50,
        default="Read More",
        blank=False,
        help_text="Button text",
    )

    banner_background_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=False,
        null=True,
        related_name="+",
        help_text="The banner background Image",
        on_delete=models.SET_NULL,
    )

    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            (
                "richtext",
                wagtail_blocks.RichTextBlock(
                    template="streams/simple_richtext_block.html",
                    features=["bold", "italic", "ol", "ul", "link"],
                ),
            ),
        ],
        null=True,
        blank=True,
    )
    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]
Пример #6
0
class FlexPage(Page):
    # limit where pages may be created
    parent_page_types = ["home.HomePage", "flex.FlexPage"]
    # define custom streamfields, takes list of tuples
    # uses classes defined in streams.blocks
    body = StreamField(
        [
            # names in quotes are arbitrary but should be descriptive
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ('call_to_action', blocks.CallToActionBlock()),
            (
                'richtext_editor',
                wagtail_blocks.RichTextBlock(
                    template='streams/simple_richtext_block.html',
                    # limit available features to the following
                    # features=["bold", "italic", "ol", "ul", "link"]
                )),
            ('large_image',
             ImageChooserBlock(
                 help_text='Add a large image to the page, 1200x775',
                 template="streams/large_image_block.html")),
            ('small_image',
             ImageChooserBlock(
                 help_text='Add a small image to the page, 900x450',
                 template="streams/small_image_block.html")),
            ('pricing_table',
             blocks.PricingTableBlock(table_options=new_table_options)),
        ],
        null=True,
        blank=True)

    # expose the body fields via the admin interface for editing
    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
        MultiFieldPanel(
            [
                InlinePanel(
                    "carousel_images", max_num=10, min_num=0, label="Image")
            ],
            heading="Carousel Images",
        ),
    ]

    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"
Пример #7
0
class FlexPage(Page):
    parent_page_types = ["home.HomePage","flex.FlexPage"]
    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"


#Declare the Stream Field
    body = StreamField([
        ('title', blocks.TitleBlock()),
        ('cards', blocks.CardsBlock()),
        ('images', blocks.ImageAndTextBlock()),
        ('cta', blocks.CallToActionBlock()),
        ("testimonials", SnippetChooserBlock(
            target_model = "testimonials.Testimonial",
            template = "streams/testimonial_block.html",
        )),
        ("table", blocks.PricingTableBlock(
            table_options = new_table_options
        )),
        ('rich_text', wagtail_blocks.RichTextBlock(
            template = "streams/simple_richtext_block.html"
        )),
        ('large_image', ImageChooserBlock(
            template = "streams/large_image_block.html",
            help_text = "This image will be cropped 1080px by 900px"
        ))
        #('new_richtext', blocks.NewRichTextBlock())
    ], null = True, blank = True)

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

    def save(self,*args,**kwargs):

        key = make_template_fragment_key(
            "flex_page",
            [self.id]
        )

        cache.delete(key)
        return super().save(*args,**kwargs)
Пример #8
0
class FlexPage(Page):
    parent_page_types = ["home.HomePage", "flex.FlexPage"]
    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ("cta", blocks.CallToActionBlock()),
            ("youtube", blocks.YouTubeEmbedBlock()),
            ("spotify", blocks.SpotifyEmbedBlock()),
            ("podcast", blocks.PodcastEmbedBlock()),
            (
                "richtext",
                wagtail_blocks.RichTextBlock(
                    template="streams/simple_richtext_block.html",
                    features=["bold", "italic", "ol", "ul", "link"],
                ),
            ),
            (
                "large_image",
                ImageChooserBlock(
                    help_text="This image will be cropped to 1200px by 775px",
                    template="streams/large_image_block.html",
                ),
            ),
        ],
        null=True,
        blank=True,
    )

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

    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"
Пример #9
0
class HomePage(Page):

    template = 'home/home_page.html'

    parent_page_types = ["wagtailcore.Page"]
    subpage_types = [
        "flex.FlexPage", "services.ServiceListingPage", "contact.ContactPage"
    ]
    max_count = 1

    lead_subtitle = models.CharField(
        max_length=20,
        blank=True,
        # Field can be left blank
        help_text="Subheading under banner title",
    )

    lead_text = models.CharField(
        max_length=100,
        blank=True,
        # Field can be left blank
        help_text="Subtext under banner title",
    )

    button = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        # Field can be null
        related_name="+",
        help_text='Select an optional page to link to',
        on_delete=models.SET_NULL,
    )

    button_text = models.CharField(
        max_length=50,
        blank=True,
        help_text='Button Text',
    )

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=True,
        null=True,
        related_name="+",
        help_text="The banner background image",
        on_delete=models.SET_NULL,
    )

    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ("cta", blocks.CallToActionBlock()),
            ("testimonial",
             SnippetChooserBlock(
                 target_model='testimonials.Testimonials',
                 template="streams/testimonial_block.html",
             )),
            ("pricing_table_block",
             blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS)),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("lead_subtitle"),
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]
Пример #10
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage", "services.ServiceListingPage","contacts.ContactPage"]
    max_count = 1
    
    lead_text = models.CharField(
        max_length = 140,
        blank = True,
        help_text = "Subsequent text after the banner title idk some other stuff ok?",
    )

    button = models.ForeignKey(
        'wagtailcore.Page',
        blank = True,
        null = True,
        on_delete = models.SET_NULL,
        related_name = '+',
        help_text = "Page Chooser Panel"
    )

    button_text = models.CharField(
        max_length = 50,
        blank = False,
        help_text = "The Button Text",
    )

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank = False,
        null = True,
        related_name = '+',
        help_text = 'The banner background image',
        on_delete = models.SET_NULL,
    )

    #Declare the Stream Field
    body = StreamField([
        ('title', blocks.TitleBlock()),
        ('cards', blocks.CardsBlock()),
        ('images', blocks.ImageAndTextBlock()),
        ('cta', blocks.CallToActionBlock()),
        ("testimonials", SnippetChooserBlock(
            target_model = "testimonials.Testimonial",
            template = "streams/testimonial_block.html",
        )),
        ("table", blocks.PricingTableBlock(
            table_options = new_table_options
        ))
    ], null = True, blank = True)

    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),    
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"), #Add the stream field to content Panel
    ]

    #*********Remove Caching every time the page gets saved**************
    
    def save(self, *args, **kwargs):

        key = make_template_fragment_key(
            "home_page_streams",
            [self.id], #This value is a list
        )

        cache.delete(key)

        return super().save(*args,**kwargs)
Пример #11
0
class ServicePage(Page):
    parent_page_types = ["services.ServiceListingPage"]
    subpage_types = []
    template = "services/service_page.html"

    description = models.TextField(
        blank=True,
        max_length=500,
    )
    internal_page = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name='+',
        help_text='Select an internal Wagtail page',
        on_delete=models.SET_NULL,
    )
    external_page = models.URLField(blank=True)
    button_text = models.CharField(blank=True, max_length=50)
    service_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        help_text=
        'This image will be used on the Service Listing Page and will be cropped to 570px by 370px on this page.',
        related_name='+',
    )

    body = StreamField(
        [("title", blocks.TitleBlock()), ("cards", blocks.CardsBlock()),
         ("image_and_text", blocks.ImageAndTextBlock()),
         ("cta", blocks.CallToActionBlock()),
         ("testimonial",
          SnippetChooserBlock(
              target_model='testimonials.Testimonial',
              template="streams/testimonial_block.html",
          )),
         ("pricing_table",
          blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS, )),
         ("richtext",
          wagtail_blocks.RichTextBlock(
              template="streams/simple_richtext_block.html",
              features=["bold", "italic", "ol", "ul", "link"])),
         ("large_image",
          ImageChooserBlock(
              help_text='This image will be cropped to 1200px by 775px',
              template="streams/large_image_block.html"))],
        null=True,
        blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("description"),
        PageChooserPanel("internal_page"),
        FieldPanel("external_page"),
        FieldPanel("button_text"),
        ImageChooserPanel("service_image"),
        StreamFieldPanel("body"),
    ]

    def clean(self):
        super().clean()

        if self.internal_page and self.external_page:
            # Both fields are filled out
            raise ValidationError({
                'internal_page':
                ValidationError(
                    "Please only select a page OR enter an external URL"),
                'external_page':
                ValidationError(
                    "Please only select a page OR enter an external URL"),
            })

        if not self.internal_page and not self.external_page:
            raise ValidationError({
                'internal_page':
                ValidationError(
                    "You must always select a page OR enter an external URL"),
                'external_page':
                ValidationError(
                    "You must always select a page OR enter an external URL"),
            })
Пример #12
0
class HomePage(Page):

    parent_page_types = ['wagtailcore.Page']
    subpage_types = [
        'flex.FlexPage', 'services.ServiceListingPage', 'contact.ContactPage',
        'gallery.GalleryListingPage'
    ]
    max_count = 1
    keywords = models.TextField(
        blank=True,
        help_text=
        'Optional comma separated list of keywords to describe the content of this page.'
    )
    lead_text = models.CharField(
        max_length=250,
        blank=True,
        help_text=
        'Subheading text under the banner title, 250 Chars max length.')
    button = models.ForeignKey('wagtailcore.Page',
                               blank=True,
                               null=True,
                               related_name='+',
                               help_text='Select an optional page link.',
                               on_delete=models.SET_NULL)
    button_text = models.CharField(
        max_length=50,
        default='Read More...',
        blank=False,
        help_text='Text shown on the button, 50 Chars max length.')
    body = StreamField([
        ('title', blocks.TitleBlock()),
        ('cards', blocks.CardsBlock()),
        ('image_and_text', blocks.ImageAndTextBlock()),
        ('cta', blocks.CallToActionBlock()),
        ('richtext',
         wagtail_blocks.RichTextBlock(
             template='streams/simple_richtext_block.html',
             features=[
                 'h2', 'h3', 'bold', 'italic', 'ol', 'ul', 'hr', 'link',
                 'document-link', 'image'
             ])),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('keywords'),
        FieldPanel('lead_text'),
        FieldPanel('button_text'),
        PageChooserPanel('button'),
        StreamFieldPanel('body'),
    ]

    def save(self, *args, **kwargs):

        key = make_template_fragment_key(
            'home_page_streams',
            [
                self.id,
            ],
        )
        cache.delete(key)
        return super().save(*args, **kwargs)
Пример #13
0
class BlogPage(Page):
    post_title = models.CharField(
        blank=False,
        max_length=80,
    )

    published_date = models.DateTimeField(default=timezone.now)

    author = models.CharField(max_length=100)

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

    summary = models.TextField(
        blank=False,
        max_length=300,
        help_text="A brief summary of the article for the post listing.")

    preview_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        on_delete=models.SET_NULL,
        help_text="The preview image displayed on the post listing.")

    internal_page_link = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name='+',
        help_text="Select and internal page to link too.",
        on_delete=models.SET_NULL,
    )

    main_content = StreamField(
        [
            ("blockquote", blocks.BlockquoteBlock()),
            ("Richtext",
             wagtail_blocks.RichTextBlock(
                 template="streams/simple_richtext_block.html",
                 features=["bold", "italic", "h2", "h3", "ol", "ul", "link"])),
            ("ImageAndText", blocks.ImageAndTextBlock()),
            ("Image", blocks.ImageBlock()),
            ("Centered_Image", blocks.ImageCenteredBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("post_title"),
        FieldPanel("published_date"),
        FieldPanel("author"),
        ImageChooserPanel("preview_image"),
        FieldPanel("summary"),
        StreamFieldPanel("main_content"),
    ]

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

    def get_read_time(self):
        ''' Returns the read time of the HTML body '''
        string = str(self.main_content)
        result = readtime.of_html(string)
        return result

    def get_context(self, request, *args, **kwargs):
        ''' Returns all Articles or filters the articles by tags using query parameters and returns the filtered list. '''
        context = super().get_context(request, *args, **kwargs)
        post_tag_ids = self.tags.values_list('id', flat=True)
        similar_posts = BlogPage.objects.live().public().filter(
            tags__in=post_tag_ids).exclude(id=self.id)
        similar_posts = similar_posts.annotate(
            same_tags=Count('tags')).order_by('-same_tags',
                                              '-published_date')[:3]
        context["similar_posts"] = similar_posts
        return context
Пример #14
0
class HomePage(Page):
    # limit where home page may be created
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = [
        "flex.FlexPage", "services.ServiceListingPage", "contact.ContactPage"
    ]
    max_count = 1

    lead_text = models.CharField(max_length=140,
                                 blank=True,
                                 help_text='Subheading text under banner')

    button = models.ForeignKey('wagtailcore.Page',
                               blank=True,
                               null=True,
                               related_name='+',
                               help_text='Select an option page to link to',
                               on_delete=models.SET_NULL)

    button_text = models.CharField(
        max_length=50,
        default='Read More',
        blank=False,
        help_text='button text',
    )

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        help_text='The banner background image',
        on_delete=models.SET_NULL)

    # define custom streamfields, takes list of tuples
    # uses classes defined in streams.blocks
    body = StreamField(
        [
            # names in quotes are arbitrary but should be descriptive
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ('call_to_action', blocks.CallToActionBlock()),
            ('pricing_table',
             blocks.PricingTableBlock(table_options=new_table_options)),
            (
                'richtext_editor',
                wagtail_blocks.RichTextBlock(
                    # template='streams/simple_richtext_block.html',
                    # limit available features to the following
                    # features=["bold", "italic", "ol", "ul", "link", "heading", 'h2', 'h3']
                )),
        ],
        null=True,
        blank=True)

    # augment content panels with the fields defined in our model
    # each panel type takes an argument (string) corresponding to the variables above
    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel('button'),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        # add panel for streamfield in admin interface
        # can create one or more streamfield blocks on the home page
        StreamFieldPanel("body")
    ]