class EventBlock(SectionBlock): start_date = core_blocks.DateTimeBlock() stop_date = core_blocks.DateTimeBlock() photo = image_blocks.ImageChooserBlock(required=False) description = common_blocks.SimpleRichTextBlock(required=False) class Meta: icon = 'date' template = 'blocks/event_block.html'
class LiveBreakBlock(blocks.StructBlock): start = blocks.DateTimeBlock() end = blocks.DateTimeBlock() label = blocks.CharBlock(reqired=False) message = blocks.CharBlock(reqired=False) class Meta: icon = 'horizontalrule' value_class = LiveInfoStructValue form_template = 'block_forms/live_break.html'
class AgendaItem(blocks.StructBlock): title = blocks.CharBlock(max_length=512) description = blocks.RichTextBlock(required=False) start = blocks.DateTimeBlock() end = blocks.DateTimeBlock() speakers = blocks.StreamBlock( [("speaker", SpeakerBlock())], required=False) class Meta: icon = 'list-ol' form_template = 'block_forms/agenda_item.html'
class LiveChannelBlock(blocks.StructBlock): start = blocks.DateTimeBlock() end = blocks.DateTimeBlock(reqired=False) cid = blocks.CharBlock("Channel ID", max_length=255) wid = blocks.CharBlock("Watch ID", max_length=255, reqired=False) vendor = blocks.ChoiceBlock(choices=LiveVendor.choices) channel_type = blocks.ChoiceBlock(choices=ChannelType.choices) token = blocks.CharBlock(max_length=255, reqired=False) class Meta: icon = 'view' value_class = LiveChannelStructValue form_template = 'block_forms/live_channel.html'
class ConcertBlock(blocks.StructBlock): band_img = ImageChooserBlock(required=True) hidden = blocks.BooleanBlock( default=True, help_text=_( 'If hidden box is checked, concert will not be displayed on' ' the page'), required=False) on_sale = blocks.BooleanBlock( default=True, help_text=_('If unchecked, Buy Tickets button will be grayed out'), required=False) virtual = blocks.BooleanBlock(default=False, help_text=_('Is this a virtual concert?'), required=False) canceled = blocks.BooleanBlock(default=False, required=False) postponed = blocks.BooleanBlock(default=False, required=False) sold_out = blocks.BooleanBlock(default=False, required=False) # Virtual concert will remain available on demand until this date available_until = blocks.DateTimeBlock( required=False, blank=True, null=True, help_text=_( 'Date that on-demand virtual concert will remain available until')) # Band/opener names and url properties replaced with single RichTextField to account for wide variety in how the # bands info may be displayed band_info = blocks.RichTextBlock(help_text=_( 'Provide the names of the bands/openers and any other info here. Text will be' ' centered.')) concert_dates = blocks.ListBlock(blocks.DateTimeBlock()) gates_time = blocks.TimeBlock(default=datetime.time(hour=18), required=False, blank=True, null=True) show_time = blocks.TimeBlock(default=datetime.time(hour=19), required=False, blank=True, null=True) member_price = blocks.CharBlock(default='$', max_length=100, blank=True, null=True) public_price = blocks.CharBlock(default='$', max_length=100) # Added a ticket URL for concerts that are sold from a non-standard URL ticket_url = blocks.URLBlock( default='https://redbuttegarden.ticketfly.com')
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()
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'), ]
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()
class ProductPage(Page): body = StreamField([('heading', blocks.RichTextBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('url', blocks.URLBlock()), ('datetime', blocks.DateTimeBlock()), ('qoute', blocks.BlockQuoteBlock()), ('file', DocumentChooserBlock())]) content_panels = Page.content_panels + [StreamFieldPanel('body')]
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'), ]
class AbstractUpdateBlock(blocks.StructBlock): message_id = blocks.CharBlock(required=False) timestamp = blocks.DateTimeBlock(required=False) def clean(self, value): """Add timestamp if timestamp is empty. This would happen when an block is added via de admin. """ if not value['timestamp']: value['timestamp'] = timezone.now() return super().clean(value)
class SimpleConcertBlock(blocks.StructBlock): """ Simplified concert info designed for Concert Donor Schedule page. """ band_img = ImageChooserBlock(required=True) concert_dates = blocks.ListBlock(blocks.DateTimeBlock()) band_info = blocks.RichTextBlock(help_text=_( 'Provide the names of the bands/openers and any other info here. Text will be' ' centered.')) class Meta: template = 'blocks/simple_concert_block.html'
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()
class _S_TallBlock(blocks.StructBlock): timeblock = blocks.TimeBlock() datetimeblock = blocks.DateTimeBlock() richtextblock = blocks.RichTextBlock() rawhtmlblock = blocks.RawHTMLBlock() blockquoteblock = blocks.BlockQuoteBlock() choiceblock = blocks.ChoiceBlock(choices=[ ("apples", "Apple"), ("bananas", "Bananas"), ]) graphql_fields = [ GraphQLString("timeblock"), GraphQLString("datetimeblock"), GraphQLString("richtextblock"), GraphQLString("rawhtmlblock"), GraphQLString("blockquoteblock"), GraphQLString("choiceblock"), ]
class CountdownBlock(blocks.StructBlock): """Bootstrap countdown block""" to_datetime = blocks.DateTimeBlock(required=True) day_string = blocks.CharBlock(required=False) hour_string = blocks.CharBlock(required=False) minute_string = blocks.CharBlock(required=False) second_string = blocks.CharBlock(required=False) heading_type = blocks.ChoiceBlock( choices=[('h1', 'h1'), ('h2', 'h2'), ('h3', 'h3'), ('h4', 'h4'), ('h5', 'h5')]) heading_size = blocks.CharBlock( required=False, help_text="any CSS unit supported px, %, rem, vh enz") google_font = blocks.CharBlock(required=False, help_text="Choose a font from Google Font") class Meta: icon = 'fa-clock' template = 'wagtail_block_collection/special/countdown_block.html' label = "Countdown" group = "Special"
class ExibitionDatesBlock(blocks.StructBlock): exibition_section_title = blocks.CharBlock(required=True, max_length=100) exibition_dates = blocks.ListBlock( blocks.StructBlock([ ('city_or_town_location', blocks.CharBlock(required=True, max_length=40, help_text="Name of Art Piece")), ('venue', blocks.CharBlock(required=True, max_length=40, help_text="Name of Art Piece")), ('date', blocks.DateTimeBlock(required=True, help_text='The date of the show')), ('buy_tickets', blocks.URLBlock(required=False)), ])) class Meta: template = 'blocks/exibition_dates_block.html' icon = 'clock' label = 'Date/Time'
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)
class EventItemBlock(blocks.StructBlock): schedule = blocks.DateTimeBlock() event = blocks.CharBlock() description = blocks.CharBlock()
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'), ]
class ActivityPage(Page): parent_page_types = ['ActivityIndexPage'] subpage_types = [] name = models.CharField(max_length=100) intro = models.CharField(max_length=500) date = models.DateField(("Publish Date"), default=datetime.date.today) application_form_link = models.CharField(max_length=500, null=True, blank=True) body = RichTextField(blank=True) cover_image = models.ForeignKey('wagtailimages.Image', null=True, on_delete=models.SET_NULL, related_name='+') background_image = models.ForeignKey('wagtailimages.Image', null=True, on_delete=models.SET_NULL, related_name='+') theme = models.ForeignKey(Theme, on_delete=models.SET_NULL, null=True, blank=False, related_name="activity_theme", limit_choices_to={'type': "ACTIVITY"}) activity_info = StreamField([ ('activity_info', blocks.StructBlock([ ('starting_time', blocks.DateTimeBlock(required=False, format='%Y-%m-%d %H:%M')), ('ending_time', blocks.DateTimeBlock(required=False, format='%Y-%m-%d %H:%M')), ('venue', blocks.CharBlock(max_length=500, required=False)), ('label', blocks.CharBlock(max_length=200, required=False, default="")), ])), ], null=True, blank=True) timezone = models.CharField(max_length=10, choices=[ ('Melbourne', 'Melbourne'), ('Beijing', 'Beijing'), ], default='mel', null=True, blank=False) search_fields = Page.search_fields + [ index.SearchField('name'), index.SearchField('intro'), ] content_panels = Page.content_panels + [ FieldPanel('name'), FieldPanel('intro'), FieldPanel('date'), FieldPanel('application_form_link'), StreamFieldPanel('activity_info'), FieldPanel('timezone'), FieldPanel('body'), ImageChooserPanel('cover_image'), ImageChooserPanel('background_image'), ] theme_panels = [ FieldPanel('theme', widget=RadioSelectWithPicture), ] edit_handler = TabbedInterface([ ObjectList(content_panels, heading='Content'), ObjectList(theme_panels, heading='Theme Setting'), ObjectList(Page.promote_panels, heading='Promote'), ObjectList(Page.settings_panels, heading='Settings', classname="settings"), ]) def get_context(self, request, *args, **kwargs): context = super().get_context(request) context['theme'] = self.theme.template_path favorite = False if not request.user.is_anonymous: for page in request.user.favorite_activities.all(): if self.id == page.id: favorite = True break context['favorite'] = favorite return context
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'), ]