Example #1
0
class PykafeMap(blocks.StructBlock):
    title = blocks.CharBlock(help_text='Enter the title of the map')
    location_lat = blocks.DecimalBlock(max_value=90,
                                       min_value=-90,
                                       max_digits=15)
    location_long = blocks.DecimalBlock(max_value=180,
                                        min_value=-180,
                                        max_digits=15)
    zoom = blocks.DecimalBlock(max_value=21, min_value=0)

    class Meta:
        template = 'home/blocks/pykafe_map.html'
class Recipe(models.Model):
    title = models.CharField(max_length=255)
    image = models.ForeignKey(Image,
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    ingredients = StreamField([
        ('ingredient',
         blocks.StructBlock([('name', blocks.CharBlock()),
                             ('quantity', blocks.DecimalBlock()),
                             ('unit',
                              blocks.ChoiceBlock(choices=[
                                  ('none', '(no unit)'),
                                  ('g', 'Grams (g)'),
                                  ('ml', 'Millilitre (ml)'),
                                  ('tsp', 'Teaspoon (tsp.)'),
                                  ('tbsp', 'Tablespoon (tbsp.)'),
                              ]))]))
    ])
    instructions = StreamField([
        ('instruction', blocks.TextBlock()),
    ])

    panels = [
        FieldPanel('title'),
        ImageChooserPanel('image'),
        StreamFieldPanel('ingredients'),
        StreamFieldPanel('instructions'),
    ]

    def __str__(self):
        return self.title
Example #3
0
class Shop_PricingcardBlock(blocks.StructBlock):
    shopcard_background = ColorBlock(null=True, blank=False, required=False, help_text="Select background color that contrasts text")
    shopcard_title = blocks.CharBlock(null=True, blank=False, required=False, classname="full title", help_text="Title of pricing card")
    shopcard_description = blocks.RichTextBlock(null=True, blank=False, required=False, help_text="Description of offer", classname="full")
    shopcard_price = blocks.DecimalBlock(null=True, blank=False, required=False, decimal_places=2, help="Price of the offer")
    shopcard_sucessmsg = blocks.RichTextBlock(null=True, blank=False, required=False, help_text="Success message", classname="full")
    shopcard_button = SnippetChooserBlock(Button, null=True, blank=False, required=False, help_text="Button displayed at the pricing-section")
Example #4
0
class CardBlock(blocks.StructBlock):

    service_cards_title = blocks.CharBlock(required=True,
                                           help_text="Add Your Title")

    service_cards = blocks.ListBlock(
        blocks.StructBlock([
            ('image', ImageChooserBlock(required=False)),
            ('icon_image', ImageChooserBlock(required=True)),
            ('service_type', blocks.CharBlock(required=True, max_length=50)),
            ('service_description',
             blocks.TextBlock(required=True, max_length=121)),
            ('service_offering_1',
             blocks.CharBlock(required=True, max_length=50)),
            ('service_offering_2',
             blocks.CharBlock(required=True, max_length=50)),
            ('service_offering_3',
             blocks.CharBlock(required=True, max_length=50)),
            ('service_price',
             blocks.DecimalBlock(required=True, decimal_places=2)),
            ('button_to_internal_page',
             blocks.PageChooserBlock(
                 required=False, help_text="Button to a page on your site")),
            ('button_to_url',
             blocks.URLBlock(
                 required=False,
                 help_text='Button to any website using the URL link')),
        ]))

    class Meta:
        template = 'streams/card_block.html'
        icon = 'image'
        label = 'Service Cards'
Example #5
0
class StreamFieldBlock(blocks.StreamBlock):
    heading = blocks.CharBlock(classname="full title")
    paragraph = blocks.RichTextBlock()
    image = ImageChooserBlock()
    decimal = blocks.DecimalBlock()
    date = blocks.DateBlock()
    datetime = blocks.DateTimeBlock()
    gallery = ImageGalleryBlock()
Example #6
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'),
    ]
Example #7
0
class CourseRunCertificateOverrides(blocks.StructBlock):
    """
    Block class that defines override values for a course run to be displayed on the certificate
    """

    readable_id = CourseRunFieldBlock(
        help_text="Course run to add the override for")
    CEUs = blocks.DecimalBlock(
        help_text=
        "CEUs to override for this CourseRun, for display on the certificate")
Example #8
0
class BootstrapCommonPriceCardBlock(blocks.StructBlock):
    heading = blocks.CharBlock()
    paragraph = blocks.RichTextBlock()
    price = blocks.DecimalBlock()
    rate = blocks.CharBlock()
    button_text = blocks.CharBlock()

    class Meta:
        template = 'bootstrap_common/blocks/pricing/bootstrap_common_price_card_block.html'
        label = 'Price Card'
Example #9
0
class StreamFieldBlock(blocks.StreamBlock):
    heading = blocks.CharBlock(classname="full title")
    paragraph = blocks.RichTextBlock()
    image = ImageChooserBlock()
    decimal = blocks.DecimalBlock()
    date = blocks.DateBlock()
    datetime = blocks.DateTimeBlock()
    gallery = ImageGalleryBlock()
    video = VideoBlock()
    objectives = blocks.ListBlock(blocks.CharBlock())
    carousel = CarouselBlock()
Example #10
0
class BlogPage(GrapplePageMixin, Page):
    author = models.CharField(max_length=255)
    date = models.DateField("Post date")
    advert = models.ForeignKey('home.Advert',
                               null=True,
                               blank=True,
                               on_delete=models.SET_NULL,
                               related_name='+')
    cover = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    book_file = models.ForeignKey('wagtaildocs.Document',
                                  null=True,
                                  blank=True,
                                  on_delete=models.SET_NULL,
                                  related_name='+')
    featured_media = models.ForeignKey('wagtailmedia.Media',
                                       null=True,
                                       blank=True,
                                       on_delete=models.SET_NULL,
                                       related_name='+')
    body = StreamField([
        ("heading", blocks.CharBlock(classname="full title")),
        ("paraagraph", blocks.RichTextBlock()),
        ("image", ImageChooserBlock()),
        ("decimal", blocks.DecimalBlock()),
        ("date", blocks.DateBlock()),
        ("datetime", blocks.DateTimeBlock()),
    ])

    content_panels = Page.content_panels + [
        FieldPanel("author"),
        FieldPanel("date"),
        ImageChooserPanel('cover'),
        StreamFieldPanel("body"),
        InlinePanel('related_links', label="Related links"),
        SnippetChooserPanel('advert'),
        DocumentChooserPanel('book_file'),
        MediaChooserPanel('featured_media'),
    ]

    graphql_fields = [
        GraphQLString("heading"),
        GraphQLString("date"),
        GraphQLString("author"),
        GraphQLStreamfield("body"),
        GraphQLForeignKey("related_links", "home.blogpagerelatedlink", True),
        GraphQLSnippet('advert', 'home.Advert'),
        GraphQLImage('cover'),
        GraphQLDocument('book_file'),
        GraphQLMedia('featured_media'),
    ]
Example #11
0
class IframeBlock(blocks.StructBlock):
    url = blocks.URLBlock(
        label="URL",
        required=True,
        help_text=
        "URL zu der Website, die mittels Iframe eingebunden werden soll.",
    )

    allowFullScreen = blocks.BooleanBlock(label="Vollbild erlauben?",
                                          required=False)

    height = blocks.DecimalBlock(default="1000",
                                 label="Höhe",
                                 help_text="in px")
    width = blocks.DecimalBlock(default="1000",
                                label="Breite",
                                help_text="in px")

    class Meta:
        label = "Iframe"
        icon = "media"
        template = "blocks/iframe.html"
Example #12
0
class StreamFieldBlock(blocks.StreamBlock):
    heading = blocks.CharBlock(classname="full title")
    paragraph = blocks.RichTextBlock()
    image = ImageChooserBlock()
    decimal = blocks.DecimalBlock()
    date = blocks.DateBlock()
    datetime = blocks.DateTimeBlock()
    gallery = ImageGalleryBlock()
    video = VideoBlock()
    objectives = blocks.ListBlock(blocks.CharBlock())
    carousel = CarouselBlock()
    callout = CalloutBlock()
    text_and_buttons = TextAndButtonsBlock()
    page = blocks.PageChooserBlock()
    text_with_callable = TextWithCallableBlock()
Example #13
0
class _S_BigBlock(blocks.StructBlock):
    integerblock = blocks.IntegerBlock()
    floatblock = blocks.FloatBlock()
    decimalblock = blocks.DecimalBlock()
    regexblock = blocks.RegexBlock(regex="")
    urlblock = blocks.URLBlock()
    booleanblock = blocks.BooleanBlock()
    dateblock = blocks.DateBlock()

    graphql_fields = [
        GraphQLInt("integerblock"),
        GraphQLFloat("floatblock"),
        GraphQLFloat("decimalblock"),
        GraphQLString("regexblock"),
        GraphQLString("urlblock"),
        GraphQLBoolean("booleanblock"),
        GraphQLString("dateblock"),
    ]
Example #14
0
class Pricing_PricingcardBlock(blocks.StructBlock):
    pricingcard_title = blocks.CharBlock(null=True,
                                         blank=False,
                                         classname="full title")
    pricingcard_description = blocks.RichTextBlock(
        null=True,
        blank=False,
        features=[
            'bold', 'italic', 'underline', 'strikethrough', 'h1', 'h2', 'h3',
            'h4', 'h5', 'h6', 'blockquote', 'ol', 'ul', 'hr', 'embed', 'link',
            'superscript', 'subscript', 'document-link', 'image', 'code'
        ],
        classname="full")
    pricingcard_price = blocks.DecimalBlock(null=True,
                                            blank=False,
                                            decimal_places=2)
    pricingcard_button = SnippetChooserBlock(Button,
                                             null=True,
                                             blank=True,
                                             required=False)
Example #15
0
class Pricing_PricingcardBlock(blocks.StructBlock):
    pricingcard_background = ColorBlock(
        null=True,
        blank=False,
        help_text="Select background color that contrasts text")
    pricingcard_title = blocks.CharBlock(null=True,
                                         blank=False,
                                         classname="full title",
                                         help_text="Title of pricing card")
    pricingcard_description = blocks.RichTextBlock(
        null=True,
        blank=False,
        help_text="Description of offer",
        features=[
            'bold', 'italic', 'underline', 'strikethrough', 'h1', 'h2', 'h3',
            'h4', 'h5', 'h6', 'blockquote', 'ol', 'ul', 'hr', 'embed', 'link',
            'superscript', 'subscript', 'document-link', 'image', 'code'
        ],
        classname="full")
    pricingcard_price = blocks.DecimalBlock(null=True,
                                            blank=False,
                                            decimal_places=2,
                                            help="Price of the offer")
    pricingcard_sucessmsg = blocks.RichTextBlock(
        null=True,
        blank=False,
        help_text="Success message",
        features=[
            'bold', 'italic', 'underline', 'strikethrough', 'h1', 'h2', 'h3',
            'h4', 'h5', 'h6', 'blockquote', 'ol', 'ul', 'hr', 'embed', 'link',
            'superscript', 'subscript', 'document-link', 'image', 'code'
        ],
        classname="full")
    pricingcard_button = SnippetChooserBlock(
        Button,
        null=True,
        blank=True,
        required=False,
        help_text="Button displayed at the pricing-section")
Example #16
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)
Example #17
0
class BlogPage(GrapplePageMixin, Page):
    author = models.CharField(max_length=255)
    date = models.DateField("Post date")
    advert = models.ForeignKey('home.Advert',
                               null=True,
                               blank=True,
                               on_delete=models.SET_NULL,
                               related_name='+')
    body = StreamField([
        ("heading", blocks.CharBlock(classname="full title")),
        ("paraagraph", blocks.RichTextBlock()),
        ("image", ImageChooserBlock()),
        ("decimal", blocks.DecimalBlock()),
        ("date", blocks.DateBlock()),
        ("datetime", blocks.DateTimeBlock()),
        ("quote", blocks.BlockQuoteBlock()),
        (
            "drink",
            blocks.ChoiceBlock(choices=[("tea", "Tea"), ("coffee", "Coffee")],
                               icon="time"),
        ),
        ("somepage", blocks.PageChooserBlock()),
        (
            "static",
            blocks.StaticBlock(
                admin_text="Latest posts: no configuration needed."),
        ),
        (
            "person",
            blocks.StructBlock(
                [
                    ("first_name", blocks.CharBlock()),
                    ("surname", blocks.CharBlock()),
                    ("photo", ImageChooserBlock(required=False)),
                    ("biography", blocks.RichTextBlock()),
                ],
                icon="user",
            ),
        ),
        ("video", EmbedBlock()),
        (
            "carousel",
            blocks.StreamBlock(
                [
                    ("image", ImageChooserBlock()),
                    (
                        "quotation",
                        blocks.StructBlock([
                            ("text", blocks.TextBlock()),
                            ("author", blocks.CharBlock()),
                        ]),
                    ),
                ],
                icon="cogs",
            ),
        ),
        ("doc", DocumentChooserBlock()),
        (
            "ingredients_list",
            blocks.ListBlock(
                blocks.StructBlock([
                    ("ingredient", blocks.CharBlock()),
                    ("amount", blocks.CharBlock(required=False)),
                ])),
        ),
    ])

    content_panels = Page.content_panels + [
        FieldPanel("author"),
        FieldPanel("date"),
        StreamFieldPanel("body"),
        InlinePanel('related_links', label="Related links"),
        SnippetChooserPanel('advert')
    ]

    graphql_fields = [
        GraphQLString("heading"),
        GraphQLString("date"),
        GraphQLString("author"),
        GraphQLStreamfield("body"),
        GraphQLForeignKey("related_links", "home.blogpagerelatedlink", True),
        GraphQLSnippet('advert', 'home.Advert'),
    ]
Example #18
0
class PageTypeA(Page):
    streamfield = StreamField([
        ('h1', blocks.CharBlock(icon="title", classname="title")),
        ('h2', blocks.CharBlock(icon="subtitle", classname="subtitle")),
        ('n1', blocks.IntegerBlock(icon="subtitle", classname="subtitle")),
    ],
                              null=True,
                              blank=True)

    another = StreamField([
        ('h3', blocks.CharBlock(icon="title", classname="title")),
        ('h4', blocks.CharBlock(icon="subtitle", classname="subtitle")),
        ('n2', blocks.IntegerBlock(icon="subtitle", classname="subtitle")),
    ],
                          null=True,
                          blank=True)

    third = StreamField([
        ('char', blocks.CharBlock()),
        ('text', blocks.TextBlock()),
        ('email', blocks.EmailBlock()),
        ('int', blocks.IntegerBlock()),
        ('float', blocks.FloatBlock()),
        ('decimal', blocks.DecimalBlock()),
        ('regex', blocks.RegexBlock(regex=r'^[0-9]{3}$')),
        ('url', blocks.URLBlock()),
        ('bool', blocks.BooleanBlock()),
        ('date', blocks.DateBlock()),
        ('time', blocks.TimeBlock()),
        ('datetime', blocks.DateTimeBlock()),
        ('rich', blocks.RichTextBlock()),
        ('raw', blocks.RawHTMLBlock()),
        ('quote', blocks.BlockQuoteBlock()),
        ('choice',
         blocks.ChoiceBlock(choices=[('tea', 'Tea'), ('coffee', 'Coffee')],
                            icon='cup')),
        ('static', blocks.StaticBlock()),
    ],
                        null=True)

    links = StreamField([
        ('image', ImageChooserBlock()),
        ('page', PageChooserBlock()),
        ('snippet', SnippetChooserBlock(target_model=App2Snippet)),
    ],
                        null=True)

    lists = StreamField([
        ('char', blocks.ListBlock(blocks.CharBlock())),
        ('text', blocks.ListBlock(blocks.TextBlock())),
        ('int', blocks.ListBlock(blocks.IntegerBlock())),
        ('float', blocks.ListBlock(blocks.FloatBlock())),
        ('decimal', blocks.ListBlock(blocks.DecimalBlock())),
        ('date', blocks.ListBlock(blocks.DateBlock())),
        ('time', blocks.ListBlock(blocks.TimeBlock())),
        ('datetime', blocks.ListBlock(blocks.DateTimeBlock())),
    ],
                        null=True)

    links_list = StreamField([
        ('image', blocks.ListBlock(ImageChooserBlock())),
        ('page', blocks.ListBlock(PageChooserBlock())),
        ('snippet',
         blocks.ListBlock(SnippetChooserBlock(target_model=App2Snippet))),
    ],
                             null=True)

    custom = StreamField([
        ('custom1', CustomBlock1()),
        ('custom2', CustomBlock2()),
    ],
                         null=True)

    another_custom = StreamField([
        ('custom1', CustomBlock1()),
        ('custom2', CustomBlock2()),
    ],
                                 null=True)

    custom_lists = StreamField([
        ('custom1', blocks.ListBlock(CustomBlock1())),
        ('custom2', blocks.ListBlock(CustomBlock2())),
    ],
                               null=True)

    content_panels = [
        FieldPanel('title', classname="full title"),
        StreamFieldPanel('streamfield'),
        StreamFieldPanel('another'),
        StreamFieldPanel('third'),
        StreamFieldPanel('links'),
        StreamFieldPanel('custom'),
        StreamFieldPanel('another_custom'),
        StreamFieldPanel('lists'),
        StreamFieldPanel('links_list'),
        StreamFieldPanel('custom_lists'),
    ]