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 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 HeroC_ItemCustom(blocks.StructBlock): #heading = blocks.RichTextBlock() text_size = blocks.ChoiceBlock(choices=[ ('xsmall', 'X-Small'), ('small', 'Small'), ('normal', 'Normal'), ('medium', 'Medium'), ('big', 'Big'), ('giant', 'Giant'), ], icon='edit', default='big') text_color = SnippetChooserBlock('home.Colors', blank=True) text = blocks.CharBlock(required=False) is_bold = blocks.BooleanBlock(required=False) image = ImageChooserBlock(required=False) use_video = blocks.BooleanBlock(required=False) video = DocumentChooserBlock(required=False) interval = blocks.IntegerBlock(default=3000, label='Interval In millisec') align = blocks.CharBlock(default="left", label='css align type [left, right, center, etc]') tintBlue = blocks.FloatBlock(default=0.3, label='Alpha Tint of the Blue Overlay') has_link = blocks.BooleanBlock(required=False) page = blocks.PageChooserBlock(required=False) use_external = blocks.BooleanBlock(required=False) link_external = blocks.CharBlock(required=False) use_anchor = blocks.BooleanBlock(required=False) anchor = blocks.CharBlock(required=False, label="like #anchor, dont include #") open_on_new = blocks.BooleanBlock(required=False)
class PieChartBlock(BasePieChartBlock): """ Basic pie chart block """ hole = blocks.FloatBlock( default=0, max_value=0.9, min_value=0, help_text='Hole size for pie chart', ) marker_line_color = NativeColorBlock( required=False, help_text='Line color for pie chart', ) marker_line_width = blocks.IntegerBlock( default=1, min_value=0, max_value=10, help_text='Line width for pie chart', ) layout = LayoutChooserBlock(required=False) def get_trace_fields(self): return ['hole', 'marker_line_color', 'marker_line_width']
class HeroSoloText(blocks.StructBlock): images = blocks.StreamBlock([('image', ImageChooserBlock())]) tint_overlay = blocks.FloatBlock(default=0.7, label='Amount of blue Tint') big_text = blocks.RichTextBlock() detail_text = blocks.RichTextBlock(required=False) class Meta: template = 'tmps/tmp_hero_solo_text.html'
class NumericQuestionBlock(blocks.StructBlock): """ A question that expects an numeric answer. """ question = blocks.RichTextBlock() answer = blocks.FloatBlock() class Meta: icon = 'help' label = 'Numeric'
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 ImageMapCoordinates(blocks.StructBlock): left = blocks.FloatBlock(required=True, min_value=0, max_value=100) top = blocks.FloatBlock(required=True, min_value=0, max_value=100) width = blocks.FloatBlock(required=True, min_value=0, max_value=100) height = blocks.FloatBlock(required=True, min_value=0, max_value=100) def clean(self, value): cleaned = super(ImageMapCoordinates, self).clean(value) errors = {} if cleaned.get('left') + cleaned.get('width') > 100: errors['left'] = errors['width'] = ErrorList( ['Sum of left and width values should not exceed 100.']) if cleaned.get('top') + cleaned.get('height') > 100: errors['top'] = errors['height'] = ErrorList( ['Sum of top and height values should not exceed 100.']) if errors: raise ValidationError('Validation error in ImageMapCoordinates', params=errors) return cleaned
class HeroAcademic(blocks.StructBlock): images = blocks.StreamBlock([('image', ImageChooserBlock())]) tint_overlay = blocks.FloatBlock(default=0.7, label='Amount of blue Tint') letters = blocks.CharBlock(max_length=3, default="AA", label='Initial or Code Letters') big_text = blocks.RichTextBlock() detail_text = blocks.RichTextBlock(required=False) class Meta: template = 'tmps/tmp_hero_academic.html'
class MessageBlock(blocks.StructBlock): message = TextBlock() font_size_factor = blocks.FloatBlock(default=1) font_color = blocks.ChoiceBlock(choices=COLOR_CHOICES, default=COLOR_XR_YELLOW) background_color = blocks.ChoiceBlock(choices=COLOR_CHOICES, default=COLOR_XR_GREEN) background_image = ImageChooserBlock(required=False) link = LinkBlock() class Meta: icon = "openquote" template = "xr_pages/blocks/message.html"
class SkillBlock(blocks.StructBlock): name = blocks.CharBlock(min_length=1, max_length=20, help_text='Tecnología') percentage = blocks.FloatBlock(min_value=0, max_value=100, help_text='Porcentaje') image = ImageChooserBlock() class Meta: icon = 'placeholder'
class PageHeadingBlock(blocks.StructBlock): text = CharBlock(label='Page Heading Text', required=True) color = ColorBlock( required=False, help_text="Select text color that contrasts background", label="Text Color") shadow_offsets = CharBlock(label='Shadow Offsets and Blur Radius', default='1px 1px 2px', required=False, help_text='h-offset v-offset blur-radius') shadow_opacity = blocks.FloatBlock(required=False, label='Shadow Opacity', default='0.0',\ help_text='Opacity of shadow from zero to one') class Meta: template = 'blog/blocks/page_heading_block.html' icon = 'title' label = 'Page Heading' help_text = 'For best SEO result, match all the titles.'
class HeroWithMiniFoto(blocks.StructBlock): images = blocks.StreamBlock([('image', ImageChooserBlock())]) tint_overlay = blocks.FloatBlock(default=0.7, label='Amount of blue Tint') mini_image = ImageChooserBlock(required=False) big_text = blocks.RichTextBlock() size_text = blocks.ChoiceBlock(choices=[ ('big', 'Big'), ('normal', 'Normal'), ], icon='edit', default="big") detail_text = blocks.RichTextBlock(required=False) class Meta: template = 'tmps/tmp_hero_with_mini_photo.html'
class SucursalesYekoMapBlock(blocks.StructBlock): marker_title = blocks.CharBlock( max_length=120, default="Marker Title 'This will be updated after you save changes.'") 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: form_template = 'wagtail_blocks/admin_blocks/map.html' template = 'wagtail_blocks/map.html' icon = "fa-globe"
class ParallaxBlock(blocks.StructBlock): text = blocks.RichTextBlock(required=False, help_text="Text to overlay parallax") img = ImageChooserBlock(required=True, help_text="Image for parallax") speed = blocks.FloatBlock( required=True, max_value=1.0, min_value=0.0, default=0.2, help_text="Speed to run the parallax", ) class Meta: icon = "fa-caret-square-o-down" label = "Parallax" template = "parallax.html"
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"), ]
class BarChartBlock(BaseBarChartBlock): """ Basic bar chart block """ orientation = blocks.ChoiceBlock( default='v', choices=ORIENTATION_CHOICES, help_text='Display as a vertical or horizontal bar chart', ) marker_line_color = NativeColorBlock( required=False, help_text='Line color for bar chart', ) marker_line_width = blocks.IntegerBlock( default=1, min_value=0, max_value=10, help_text='Line width for bar chart', ) barmode = blocks.ChoiceBlock( default='group', choices=BARMODE_CHOICES, help_text='Display as a grouped or stacked bar chart', ) bargroupgap = blocks.FloatBlock( default=0.1, min_value=0, max_value=0.5, help_text='Gap between bars of the same location coordinate', ) layout = LayoutChooserBlock(required=False) def get_trace_fields(self): return ['orientation', 'marker_line_color', 'marker_line_width'] def get_layout_fields(self): return ['barmode', 'bargroupgap']
class DocumentBlock(blocks.StructBlock): type = blocks.ChoiceBlock( choices=[ ('document', 'Document'), ('publication', 'Publication'), ('talk', 'Talk') ], ) title = blocks.CharBlock() abstract = blocks.CharBlock(required=False) author = blocks.CharBlock() detail = blocks.CharBlock(required=False) version = blocks.FloatBlock(required=False) document = DocumentChooserBlock(required=False) url = blocks.URLBlock(required=False) date = blocks.DateBlock() class Meta: icon = 'doc-full' template = 'dalme_public/blocks/_document.html'
class EpisodeBlock(blocks.StructBlock): """Episode Block with title media""" episodes = blocks.ListBlock( blocks.StructBlock([ ("showno", blocks.FloatBlock(required=True, help_text="Track Number")), ("showmedia", AbstractMediaChooserBlock(required=True, help_text="Upload/Choose audio file")), ("showdate", blocks.DateBlock(required=False, help_text="Upload date")), ("shownotes", blocks.PageChooserBlock(required=False, help_text='Choose Shownotespage')), ])) class Meta: # noqa template = "streams/episodes_block.html" icon = "placeholder" label = "Pocast Episode"
class HeroWithFotoOrLetter(blocks.StructBlock): images = blocks.StreamBlock([('image', ImageChooserBlock())]) 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) big_text = blocks.RichTextBlock() detail_text = blocks.RichTextBlock(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_photo_letter.html'
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 Armor(blocks.StructBlock): armor = blocks.FloatBlock()
class Migration(migrations.Migration): initial = True dependencies = [ ('v1', '0203_deprecate_spanish_home_page'), ] operations = [ migrations.CreateModel( name='FormExplainerPage', fields=[ ('cfgovpage_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='v1.CFGOVPage')), ('header', core_fields.StreamField((('hero', core_blocks.StructBlock((('heading', core_blocks.CharBlock(help_text='For complete guidelines on creating heroes, visit our <a href="https://cfpb.github.io/design-manual/global-elements/heroes.html">Design Manual</a>.<ul class="help">Character counts (including spaces) at largest breakpoint:<li>• 41 characters max (one-line heading)</li><li>• 82 characters max (two-line heading)</li></ul>', required=False)), ('body', core_blocks.RichTextBlock(help_text='<ul class="help">Character counts (including spaces) at largest breakpoint:<li>• 165-186 characters (after a one-line heading)</li><li>• 108-124 characters (after a two-line heading)</li></ul>', label='Sub-heading', required=False)), ('image', images_blocks.ImageChooserBlock(help_text='When saving illustrations, use a transparent background. <a href="https://cfpb.github.io/design-manual/global-elements/heroes.html#style">See image dimension guidelines.</a>', label='Large image', required=False)), ('small_image', images_blocks.ImageChooserBlock(help_text='<b>Optional.</b> Provides an alternate image for small displays when using a photo or bleeding hero. Not required for the standard illustration. <a href="https://cfpb.github.io/design-manual/global-elements/heroes.html#style">See image dimension guidelines.</a>', required=False)), ('background_color', core_blocks.CharBlock(help_text='Specify a hex value (with the # sign) from our <a href="https://cfpb.github.io/design-manual/brand-guidelines/color-principles.html">official color palette</a>.', required=False)), ('is_overlay', core_blocks.BooleanBlock(help_text='<b>Optional.</b> Uses the large image as a background under the entire hero, creating the "Photo" style of hero (see <a href="https://cfpb.github.io/design-manual/global-elements/heroes.html">Design Manual</a> for details). When using this option, make sure to specify a background color (above) for the left/right margins that appear when screens are wider than 1200px and for the text section when the photo and text stack at mobile sizes.', label='Photo', required=False)), ('is_white_text', core_blocks.BooleanBlock(help_text='<b>Optional.</b> Turns the hero text white. Useful if using a dark background color or background image.', label='White text', required=False)), ('is_bleeding', core_blocks.BooleanBlock(help_text='<b>Optional.</b> Select if you want the illustration to bleed vertically off the top and bottom of the hero space.', label='Bleed', required=False))))), ('text_introduction', core_blocks.StructBlock((('eyebrow', core_blocks.CharBlock(help_text='Optional: Adds an H5 eyebrow above H1 heading text. Only use in conjunction with heading.', label='Pre-heading', required=False)), ('heading', core_blocks.CharBlock(required=False)), ('intro', core_blocks.RichTextBlock(required=False)), ('body', core_blocks.RichTextBlock(required=False)), ('links', core_blocks.ListBlock(core_blocks.StructBlock((('text', core_blocks.CharBlock(required=False)), ('url', core_blocks.CharBlock(default='/', required=False)))), required=False)), ('has_rule', core_blocks.BooleanBlock(help_text='Check this to add a horizontal rule line to bottom of text introduction.', label='Has bottom rule', required=False)))))), blank=True)), ('content', core_fields.StreamField((('explainer', core_blocks.StructBlock((('pages', core_blocks.ListBlock(core_blocks.StructBlock((('image', images_blocks.ImageChooserBlock(icon='image', required=True)), ('categories', core_blocks.ListBlock(core_blocks.StructBlock((('title', core_blocks.CharBlock(help_text='Optional. Leave blank if there is only one type of note for this image.', label='Category title', required=False)), ('notes', core_blocks.ListBlock(core_blocks.StructBlock((('coordinates', core_blocks.StructBlock((('left', core_blocks.FloatBlock(max_value=100, min_value=0, required=True)), ('top', core_blocks.FloatBlock(max_value=100, min_value=0, required=True)), ('width', core_blocks.FloatBlock(max_value=100, min_value=0, required=True)), ('height', core_blocks.FloatBlock(max_value=100, min_value=0, required=True))), form_classname='coordinates', help_text='Enter percentage values to define the area that will be highlighted on the image for this note.', label='Note image map coordinates')), ('heading', core_blocks.CharBlock(label='Note heading', required=True)), ('body', core_blocks.RichTextBlock(features=['bold', 'italic', 'link', 'document-link'], label='Note text', required=True))), form_classname='explainer_notes', required=False), default=[]))), required=False)))), required=False))),))), ('well', core_blocks.StructBlock((('content', core_blocks.RichTextBlock(label='Well', required=False)),))), ('info_unit_group', core_blocks.StructBlock((('format', core_blocks.ChoiceBlock(choices=[('50-50', '50/50'), ('33-33-33', '33/33/33'), ('25-75', '25/75')], help_text='Choose the number and width of info unit columns.', label='Format')), ('heading', core_blocks.StructBlock((('text', v1.blocks.HeadingTextBlock(required=False)), ('level', core_blocks.ChoiceBlock(choices=[('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4')])), ('icon', v1.blocks.HeadingIconBlock(help_text='Input the name of an icon to appear to the left of the heading. E.g., approved, help-round, etc. <a href="https://cfpb.github.io/capital-framework/components/cf-icons/#the-icons">See full list of icons</a>', required=False))), required=False)), ('intro', core_blocks.RichTextBlock(help_text='If this field is not empty, the Heading field must also be set.', required=False)), ('link_image_and_heading', core_blocks.BooleanBlock(default=True, help_text="Check this to link all images and headings to the URL of the first link in their unit's list, if there is a link.", required=False)), ('has_top_rule_line', core_blocks.BooleanBlock(default=False, help_text='Check this to add a horizontal rule line to top of info unit group.', required=False)), ('lines_between_items', core_blocks.BooleanBlock(default=False, help_text='Check this to show horizontal rule lines between info units.', label='Show rule lines between items', required=False)), ('info_units', core_blocks.ListBlock(core_blocks.StructBlock((('image', core_blocks.StructBlock((('upload', images_blocks.ImageChooserBlock(required=False)), ('alt', core_blocks.CharBlock(help_text="If the image is decorative (i.e., if a screenreader wouldn't have anything useful to say about it), leave the Alt field blank.", required=False))))), ('heading', core_blocks.StructBlock((('text', v1.blocks.HeadingTextBlock(required=False)), ('level', core_blocks.ChoiceBlock(choices=[('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4')])), ('icon', v1.blocks.HeadingIconBlock(help_text='Input the name of an icon to appear to the left of the heading. E.g., approved, help-round, etc. <a href="https://cfpb.github.io/capital-framework/components/cf-icons/#the-icons">See full list of icons</a>', required=False))), default={'level': 'h3'}, required=False)), ('body', core_blocks.RichTextBlock(blank=True, required=False)), ('links', core_blocks.ListBlock(core_blocks.StructBlock((('text', core_blocks.CharBlock(required=False)), ('url', core_blocks.CharBlock(default='/', required=False)))), required=False)))))), ('sharing', core_blocks.StructBlock((('shareable', core_blocks.BooleanBlock(help_text='If checked, share links will be included below the items.', label='Include sharing links?', required=False)), ('share_blurb', core_blocks.CharBlock(help_text='Sets the tweet text, email subject line, and LinkedIn post text.', required=False)))))))), ('feedback', core_blocks.StructBlock((('was_it_helpful_text', core_blocks.CharBlock(default='Was this page helpful to you?', help_text='Use this field only for feedback forms that use "Was this helpful?" radio buttons.', required=False)), ('intro_text', core_blocks.CharBlock(help_text='Optional feedback intro', required=False)), ('question_text', core_blocks.CharBlock(help_text='Optional expansion on intro', required=False)), ('radio_intro', core_blocks.CharBlock(help_text='Leave blank unless you are building a feedback form with extra radio-button prompts, as in /owning-a-home/help-us-improve/.', required=False)), ('radio_text', core_blocks.CharBlock(default='This information helps us understand your question better.', required=False)), ('radio_question_1', core_blocks.CharBlock(default='How soon do you expect to buy a home?', required=False)), ('radio_question_2', core_blocks.CharBlock(default='Do you currently own a home?', required=False)), ('button_text', core_blocks.CharBlock(default='Submit')), ('contact_advisory', core_blocks.RichTextBlock(help_text='Use only for feedback forms that ask for a contact email', required=False)))))))), ], options={ 'abstract': False, }, bases=('v1.cfgovpage',), ), ]
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'), ]
class HeroProgram(blocks.StructBlock): images = blocks.StreamBlock([('image', ImageChooserBlock())]) tint_overlay = blocks.FloatBlock(default=0.7, label='Amount of blue Tint')
class TextWithCallableBlock(blocks.StructBlock): text = blocks.CharBlock() integer = blocks.IntegerBlock() decimal = blocks.FloatBlock() graphql_fields = [ GraphQLString("text"), GraphQLInt("integer"), GraphQLFloat("decimal"), # GraphQLString test attributes GraphQLString("simple_string"), GraphQLString("simple_string_method", source="get_simple_string_method"), # GraphQLInt test attributes GraphQLInt("simple_int"), GraphQLInt("simple_int_method", source="get_simple_int_method"), # GraphQLFloat test attributes GraphQLFloat("simple_float"), GraphQLFloat("simple_float_method", source="get_simple_float_method"), # GraphQLBoolean test attributes GraphQLBoolean("simple_boolean"), GraphQLBoolean("simple_boolean_method", source="get_simple_boolean_method"), # GraphQLField test attributes GraphQLField("field_property", graphene.String, source="get_field_property"), GraphQLField("field_method", graphene.String, source="get_field_method"), ] # GraphQLString test attributes @property def simple_string(self) -> str: return "A simple string property." def simple_string_method( self, values: Dict[str, Any] = None, ): # Should not be used as we define `source="get_simple_string_method"`. raise Exception def get_simple_string_method( self, values: Dict[str, Any] = None, ) -> Optional[str]: return slugify(values.get("text")) if values else None # GraphQLInt test attributes @property def simple_int(self) -> int: return 5 def simple_int_method( self, values: Dict[str, Any] = None, ): # Should not be used as we define `source="get_simple_int_method"`. raise Exception def get_simple_int_method( self, values: Dict[str, Any] = None, ) -> Optional[int]: return values.get("integer") * 2 if values else None # GraphQLFloat test attributes @property def simple_float(self) -> float: return 0.1 def simple_float_method( self, values: Dict[str, Any] = None, ): # Should not be used as we define `source="get_simple_float_method"`. raise Exception def get_simple_float_method( self, values: Dict[str, Any] = None, ) -> Optional[float]: return values.get("decimal") * 2 if values else None # GraphQLBoolean test attributes @property def simple_boolean(self) -> bool: return 1 def simple_boolean_method( self, values: Dict[str, Any] = None, ): # Should not be used as we define `source="get_simple_boolean_method"`. raise Exception def get_simple_boolean_method( self, values: Dict[str, Any] = None, ) -> Optional[bool]: return bool(values.get("text")) if values else None # GraphQLField test attributes @property def get_field_property(self) -> str: return "A field property." def field_method( self, values: Dict[str, Any] = None, ): # Should not be used as we define `source="get_field_method"`. raise Exception def get_field_method( self, values: Dict[str, Any] = None, ) -> Optional[str]: return slugify(values.get("text")) if values else None
class PerLevelBlock(blocks.StructBlock): base = blocks.IntegerBlock() per_level = blocks.FloatBlock()
class HeroBannerCarrousel(blocks.StructBlock): heading = blocks.RichTextBlock() image = ImageChooserBlock() tintBlue = blocks.FloatBlock(label='Alpha Tint of the Blue Overlay')