class HeroParametric(blocks.StructBlock): use_image_carousel = blocks.BooleanBlock(required=False) images = blocks.StreamBlock([('image', ImageChooserBlock())], required=False) tint_overlay = blocks.FloatBlock(default=0.7, label='Amount of blue Tint') tint_R = blocks.IntegerBlock(default=0) tint_G = blocks.IntegerBlock(default=74) tint_B = blocks.IntegerBlock(default=135) height = blocks.CharBlock(default="300px") min_height = blocks.CharBlock(default="500px") big_text = blocks.RichTextBlock() detail_text = blocks.RichTextBlock(required=False) text_color = SnippetChooserBlock('home.Colors', blank=True, required=False) use_circle = blocks.BooleanBlock(required=False) use_image = blocks.BooleanBlock(required=False) mini_image = ImageChooserBlock(required=False) letters = blocks.CharBlock(required=False, max_length=3, label="Initial letters if dont use image") letters_color = SnippetChooserBlock('home.Colors', blank=True, required=False) letters_back = SnippetChooserBlock('home.Colors', blank=True, required=False) class Meta: template = 'tmps/tmp_hero_params.html'
class VideoBlock(blocks.StructBlock): width = blocks.IntegerBlock() height = blocks.IntegerBlock() video = MediaChooserBlock() class Meta: icon = 'fa-play'
class HeroImageCarouselBlock(blocks.StructBlock, BlockTupleMixin): slides = blocks.ListBlock( blocks.StructBlock([ ('image', ImageChooserBlock()), ('title', blocks.CharBlock(required=False)), ('text', blocks.TextBlock(required=False)), ('link', LinkBlock()), ]) ) height = blocks.IntegerBlock( default=300, label="Hero Image Height (pixels)", ) width = blocks.IntegerBlock( default=1000, label="Hero Image Width (pixels)", ) cycle_timeout = blocks.IntegerBlock( default=10000, help_text="The time between automatic image cycles (in milliseonds). Set to 0 to disable automatic cycling." ) class Meta: template = 'jetstream/blocks/hero_image_carousel_block.html' form_classname = 'image-carousel struct-block' label = 'Hero Image Slider' icon = 'image'
class MapBlock(CommonBlockMixin): map_height = blocks.IntegerBlock(default=400, help_text='Height of the map in pixels') marker_title = blocks.CharBlock( max_length=120, default="Marker Title 'This will be updated after you save changes.'", classname='half-size-wrapper') marker_description = blocks.RichTextBlock() zoom_level = blocks.IntegerBlock(min_value=0, max_value=18, default='2', required=False) location_x = blocks.FloatBlock(default='35.0', required=False) location_y = blocks.FloatBlock(default='0.16', required=False) marker_x = blocks.FloatBlock(default='51.5', required=False) marker_y = blocks.FloatBlock(default='-0.09', required=False) @property def media(self): return forms.Media( js=["https://unpkg.com/[email protected]/dist/leaflet.js"], css={'all': ["https://unpkg.com/[email protected]/dist/leaflet.css"]}) class Meta: icon = "fa-globe" template = 'page/blocks/map_block.html' form_template = 'admin/blocks/map_block.html'
class DimensionBlock(blocks.StructBlock): height = blocks.IntegerBlock(min_value=1, max_value=500, required=False) width = blocks.IntegerBlock(min_value=1, max_value=500, required=False) class Meta: icon = "arrows-up-down" template = "utilities/size/size_block.html" group = "size"
class ColorBlock(blocks.StructBlock): r = blocks.IntegerBlock() g = blocks.IntegerBlock() b = blocks.IntegerBlock() a = blocks.IntegerBlock() class Meta: icon = 'snippet'
class ExperienceBlock(blocks.StructBlock): num_work = blocks.IntegerBlock(label='Ingrese el numero de trabajos completados') num_years = blocks.IntegerBlock(label='Ingrese años de experiencia') num_clients = blocks.IntegerBlock(label='Ingrese cantidad de clientes') num_awards = blocks.IntegerBlock(label='Ingrese Cantidad de premios obtenidos') class Meta: template = 'blocks/main/experience_main_block.html' label = 'Mi experiencia'
class ArchiveArticleBlock(blocks.StructBlock): title = blocks.CharBlock() authors = blocks.ListBlock( blocks.PageChooserBlock() ) toc_page_number = blocks.IntegerBlock() pdf_page_number = blocks.IntegerBlock() class Meta: icon = "doc-full"
class BodyBlock(blocks.StreamBlock): heading = blocks.CharBlock() description = blocks.TextBlock() email = blocks.EmailBlock() number = blocks.IntegerBlock() numbers = blocks.ListBlock(blocks.IntegerBlock()) paragraph = blocks.RichTextBlock() image = ImageChooserBlock() author = AuthorBlock() authors = blocks.ListBlock(AuthorBlock())
class HomeCounterSlide(blocks.StructBlock): number = blocks.IntegerBlock(required=True) text = blocks.RichTextBlock(required=True, help_text='Add additional text') delay = blocks.IntegerBlock(required=False, default=0) speed = blocks.IntegerBlock(required=True) thousand = blocks.BooleanBlock(required=False, default=False) class Meta: template = "home/home_counter_block.html" icon = "edit" label = "Counter"
class BlogPostListBlock(blocks.StructBlock): title = blocks.CharBlock(blank=True, required=False) root_page = blocks.PageChooserBlock() numPost = blocks.IntegerBlock() numCols = blocks.IntegerBlock() has_pagination = blocks.BooleanBlock(blank=True, required=False, default=True) class Meta: icon = 'grip' label = 'Blog Post List' template = 'blog/blocks/blog_post_list.html'
class BodyBlock(blocks.StreamBlock): heading = blocks.CharBlock() description = blocks.TextBlock() email = blocks.EmailBlock() number = blocks.IntegerBlock() numbers = blocks.ListBlock(blocks.IntegerBlock()) paragraph = blocks.RichTextBlock() image = ImageChooserBlock() person = PersonBlock() people = blocks.ListBlock(PersonBlock()) stream = blocks.StreamBlock([("heading", blocks.CharBlock()), ("paragraph", blocks.RichTextBlock()), ("image", ImageChooserBlock())])
class TableStructBlock(blocks.StructBlock): type_table = blocks.ChoiceBlock( choices=[(' ', 'Gewone tabel'), ('price-table', 'Prijs tabel')], label='Type tabel', ) table_borders = blocks.ChoiceBlock(choices=[ ('no-borders', 'Geen lijnen'), ('column-borders', 'Kolom lijnen'), ('row-borders', 'Regel lijnen'), ('all-borders', 'Kolom en regel lijnen'), ], label='Tabel lijnen') table_header_rows = blocks.IntegerBlock( label='Tabelheaderrijen', min_value=0, max_value=100, default=2, ) table_footer_rows = blocks.IntegerBlock( label='Tabelfooterrijen', min_value=0, max_value=100, default=2, ) table_header_background = ColorPickerBlock( label='Tabelheader achtergrondkleur', required=False, ) table_header_color = ColorPickerBlock( label='Tabelheader tekstkleur', required=False, ) table_header_text_size = blocks.IntegerBlock( label='Tabelheader grootte tekst', help_text='Tabelheader grootte van de tekst.', min_value=1, max_value=100, default=20, ) table_footer_background = ColorPickerBlock( label='Tabelfooter achtergrondkleur', required=False, ) table_footer_color = ColorPickerBlock( label='Tabelfooter tekstkleur', required=False, ) table = TableBlock(table_options=TABLE_OPTIONS, label='Tabel', help_text='HTML is mogelijk in de tabel')
class GoogleMapBlock(blocks.StructBlock): title = blocks.CharBlock(required=True, max_length=255) street = blocks.CharBlock(required=True, max_length=255) postcode = blocks.CharBlock(required=True, max_length=255) city = blocks.CharBlock(required=True, max_length=255) map_long = blocks.CharBlock(required=True, max_length=255) map_lat = blocks.CharBlock(required=True, max_length=255) map_zoom_level = blocks.CharBlock(default=14, required=True, max_length=3) width = blocks.IntegerBlock(required=True) height = blocks.IntegerBlock(required=True) class Meta: template = 'blocks/google_map.html' icon = 'cogs' label = 'Google Map'
class LinePlotBlock(BaseLinePlotBlock): """ Basic line plot with common x axis values """ mode = blocks.ChoiceBlock(default='lines', choices=MODE_CHOICES) fill = blocks.ChoiceBlock(default='none', choices=PLOT_FILL_CHOICES) line_shape = blocks.ChoiceBlock(default='linear', choices=LINE_SHAPE_CHOICES) line_width = blocks.IntegerBlock(default=2, min_value=1, max_value=5) marker_size = blocks.IntegerBlock(default=6, min_value=1, max_value=40) layout = LayoutChooserBlock(required=False) def get_trace_fields(self): return ['mode', 'fill', 'line_shape', 'line_width', 'marker_size']
class Col(blocks.StreamBlock): """Col ('div' tags) See Also: make_row_col_blocks """ small = blocks.IntegerBlock(required=False, blank=True) medium = blocks.IntegerBlock(required=False, blank=True) large = blocks.IntegerBlock(required=False, blank=True) xl = blocks.IntegerBlock(required=False, blank=True) content = blocks.StreamBlock() class Meta: template = 'wagtail_materializecss/grid/col.html'
class PromoBanner(BasePromoBlock): class Meta: template = "core/blocks/promo_banner.html" call_to_action = blocks.CharBlock(required=True) heading_level = blocks.IntegerBlock( min_value=2, max_value=4, default=3, help_text="The heading level affects users with screen readers. Default=3, Min=2, Max=4.", ) image_alignment = blocks.ChoiceBlock( [("right", "Right"), ("left", "Left"),], default="right", required=True, ) def get_form_context(self, value, prefix="", errors=None): context = super().get_form_context(value, prefix=prefix, errors=errors) # Alter the order of the form, so it makes more sense new_keys = [ "heading", "heading_level", "description", "link_page", "url", "call_to_action", "content_image", "alt_text", "image_alignment", ] form_objects = collections.OrderedDict() for key in new_keys: form_objects[key] = context["children"][key] context["children"] = form_objects return context
class PlaceDetailBlock(blocks.StructBlock): place = blocks.CharBlock(requried=True) details = blocks.TextBlock(requried=True, help_text="Add place details") duration_of_visit = blocks.CharBlock(requried=True) distance_from_start_location = blocks.IntegerBlock(null=False, default=0) map_icon = blocks.StructBlock([ ("map_icon", ImageChooserBlock(required=False)), ]) trip_types = blocks.ListBlock( blocks.StructBlock([ ("trip_type", SnippetChooserBlock(models.TripType)), ])) tags = blocks.ListBlock( blocks.StructBlock([ ("tag", SnippetChooserBlock(models.LocationTag)), ])) images = blocks.ListBlock( blocks.StructBlock([ ("image", ImageChooserBlock(required=True)), ])) class Meta: template = "outstation/place_detail.html" icon = "edit"
class GoogleCalendarBlock(blocks.StructBlock): calendars = blocks.ListBlock(blocks.StructBlock([ ('source', blocks.CharBlock( help_text=_('Calendar ID as given by google calendar'), )), ('color', ColorBlock()), ])) mode = blocks.ChoiceBlock(choices=[ ('WEEK', _('Week')), ('', _('Month')), ('AGENDA', _('Agenda')), ], required=False) height = blocks.IntegerBlock() background_color = ColorBlock() week_start = blocks.ChoiceBlock(choices=[ ('2', _('Monday')), ('1', _('Sunday')), ('7', _('Saturday')), ]) class Meta: label = _('Google Calendar') icon = 'fa-calendar' template = 'google/blocks/calendar.html' group = _('Embed')
class LineupBlock(blocks.StructBlock): year = blocks.IntegerBlock(min_value=1980, required=True) poster = ImageChooserBlock(required=True) artists = blocks.RichTextBlock(required=True) class Meta: template = 'blocks/lineup_block.html'
class CoworkerBlock(blocks.StructBlock): name = blocks.CharBlock(max_length=255, blank=True) roepnaam = blocks.CharBlock(max_length=255, null=True, blank=True) job_function = blocks.CharBlock(max_length=255, blank=True, null=True) address = blocks.CharBlock( max_length=255, blank=True, null=True, required=False, ) email = blocks.EmailBlock( max_length=254, blank=True, null=True, required=False, ) phone = blocks.CharBlock( max_length=255, blank=True, null=True, required=False, ) linkedin = blocks.URLBlock( max_length=200, blank=True, null=True, required=False, ) positions = blocks.IntegerBlock(default=1) image = ImageChooserBlock()
class PromoGroupBlock(FlattenValueContext, blocks.StructBlock): class Meta: template = 'wagtailnhsukfrontend/promo_group.html' column = blocks.ChoiceBlock([ ('one-half', 'One-half'), ('one-third', 'One-third'), ], default='one-half', required=True) size = blocks.ChoiceBlock([ ('', 'Default'), ('small', 'Small'), ], required=False) def get_context(self, value, parent_context=None): context = super().get_context(value, parent_context) context['num_columns'] = { 'one-half': 2, 'one-third': 3, }[value['column']] return context heading_level = blocks.IntegerBlock( min_value=2, max_value=4, default=3, help_text='The heading level affects users with screen readers. Default=3, Min=2, Max=4.' ) promos = blocks.ListBlock(BasePromoBlock)
class BackgroundBlock(blocks.StructBlock): type_field = blocks.ChoiceBlock(choices=( ('parallaxBg', 'Parallax'), ('fixedBg', 'Stilstaand'), )) background_image = ImageChooserBlock( label='Afbeelding', help_text='Het achtergrondplaatje van het blok.', ) block_height = blocks.IntegerBlock( label='Hoogte', help_text='Hoogte van het blok in pixels.', min_value=0, max_value=999, default=250, ) columns = blocks.ChoiceBlock( label='Kolommen', choices=[('2', 'Twee'), ('1', 'Een')], default='2', ) text_left = blocks.RichTextBlock( label='Tekst links', help_text='Tekst aan de linkerkant op de achtergrond.', required=False, ) text_right = blocks.RichTextBlock( label='Tekst rechts', help_text='Tekst aan de rechterkant op de achtergrond.', required=False, ) text_color = ColorPickerBlock( label='Kleur tekst', required=False, )
class EmbedGoogleMapBlock(BaseBlock): """ An embedded Google map in an <iframe>. """ search = blocks.CharBlock( required=False, max_length=255, label=_('Search query'), help_text=_( 'Address or search term used to find your location on the map.'), ) api_key = blocks.CharBlock( required=False, max_length=255, label=_('API key'), help_text=_( 'Optional. Only required to use place ID and zoom features.')) place_id = blocks.CharBlock( required=False, max_length=255, label=_('Google place ID'), help_text=_('Requires API key to use place ID.')) map_zoom_level = blocks.IntegerBlock( required=False, default=14, label=_('Map zoom level'), help_text= _('Requires API key to use zoom. 1: World, 5: Landmass/continent, 10: City, 15: Streets, 20: Buildings' )) class Meta: template = 'coderedcms/blocks/google_map.html' icon = 'fa-map' label = _('Google Map')
class CTAStreamBlock(blocks.StructBlock): cta_title = blocks.CharBlock(required=False) cta_content = blocks.RichTextBlock(required=False) cta_page = blocks.PageChooserBlock(label="page", required=False) cta_link = blocks.URLBlock(label="URL",required=False) # Width would be better as a CoiceBlock width = blocks.IntegerBlock(required=False,max_value=12,min_value=0,help_text="Number of columns to span out of 12 (e.g., input of 3 would mean give this a width of 3 out of the 12 (25%))") text_color = blocks.ChoiceBlock(choices=[ ('white', 'White'), ('black', 'Black'), ('blue', 'Blue'), ('green', 'Green'), ('red', 'Red'), ('purple', 'Purple'), ('grey', 'Grey'), ], icon='color_palette', required=False) background_color = blocks.ChoiceBlock(choices=[ ('white', 'White'), ('black', 'Black'), ('blue', 'Blue'), ('green', 'Green'), ('red', 'Red'), ('purple', 'Purple'), ('grey', 'Grey'), ], icon='color', required=False) background_image = ImageChooserBlock(required=False) class Meta: icon = 'form' value_class = LinkStructValue
class MyTestPage(Page): body = StreamField([ ('char_array', blocks.ListBlock(blocks.CharBlock())), ('int_array', blocks.ListBlock(blocks.IntegerBlock())), ('struct', MyBlock()), ('image', ImageChooserBlock()), ])
class BootstrapCol(blocks.StructBlock): width = blocks.IntegerBlock(max_value=12, min_value=0, help_text='0 = auto', default=0) alignment = blocks.ChoiceBlock(choices=[ ('center', 'Center'), ('right', 'Right'), ('left', 'Left'), ], default='center') vertical_center = blocks.BooleanBlock(default=False, blank=True, required=False) body = blocks.StreamBlock([ (_('Rich_Text'), blocks.RichTextBlock()), (_('Text'), blocks.TextBlock()), (_('Image'), ImageChooserBlock(icon="image")), (_('Embedded_Video'), EmbedBlock(icon="media")), (_('HTML'), blocks.RawHTMLBlock()), (_('Quote'), blocks.BlockQuoteBlock()), (_('Optin'), OptinChooserBlock('optin.Optin')), (_('Code'), CodeBlock(label='Code Editor')), (_('Aligned_Image'), AlignedImageBlock()), ], blank=True, null=True, required=False) class Meta: icon = 'grip' label = 'Bootstrap Col' template = 'blog/blocks/bootstrap_col.html'
class PromoGroupBlock(FlattenValueContext, blocks.StructBlock): class Meta: template = "wagtailnhsukfrontend/promo_group.html" column = blocks.ChoiceBlock( [("one-half", "One-half"), ("one-third", "One-third"),], default="one-half", required=True, ) size = blocks.ChoiceBlock([("", "Default"), ("small", "Small"),], required=False) def get_context(self, value, parent_context=None): context = super().get_context(value, parent_context) context["num_columns"] = {"one-half": 2, "one-third": 3,}[value["column"]] return context heading_level = blocks.IntegerBlock( min_value=2, max_value=4, default=3, help_text="The heading level affects users with screen readers. Default=3, Min=2, Max=4.", ) promos = blocks.ListBlock(BasePromoBlock)
class CaseStudyBlock(blocks.StructBlock): heading = blocks.CharBlock(required=False) heading_level = blocks.IntegerBlock( min_value=2, max_value=4, default=3, help_text="The heading level affects users with screen readers. Default=3, Min=2, Max=4.", ) column = blocks.ChoiceBlock( [("one-half", "One-half"), ("one-third", "One-third"),], default="one-third", required=True, ) tag_id = blocks.ChoiceBlock(choices=get_casestudy_tag_list, required=True) def get_context(self, value, parent_context=None): context = super().get_context(value, parent_context=parent_context) context["num_columns"] = {"one-half": 2, "one-third": 3,}[value["column"]] value["tag"] = CaseStudyTag.objects.get(id=value["tag_id"]) value["items"] = self._get_items(value["tag_id"], 99) context.update(value) return context class Meta: abstract = True
class iFrameBlock(blocks.StructBlock): url = blocks.CharBlock( help_text='Please note that only URLs from white-listed domains will work.' ) height = blocks.IntegerBlock( required=False, help_text='Optional integer pixel value for custom iFrame height' ) caption = blocks.CharBlock( required=False ) captionURL = blocks.CharBlock( required=False, help_text='Optional URL that this caption should link out to.' ) iframe_width = RadioSelectBlock( choices=( ("normal", "Normal"), ("wide", "Wide"), ("full_width", "Full Width"), ), default='normal', help_text='Wide iframes are col-12, Full-Width iframes reach both ends of the screen' ) class Meta: template = 'wagtailpages/blocks/iframe_block.html'