Ejemplo n.º 1
0
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"
Ejemplo n.º 2
0
class FullText(blocks.StructBlock):
    text_size = blocks.ChoiceBlock(choices=[
        ('xsmall', 'X-Small'),
        ('small', 'Small'),
        ('normal', 'Normal'),
        ('medium', 'Medium'),
        ('big', 'Big'),
        ('giant', 'Giant'),
    ],
                                   icon='edit',
                                   default='big')
    font_color = SnippetChooserBlock('home.Colors', blank=True)
    text = blocks.RichTextBlock()
    align = blocks.CharBlock(default="left",
                             label='css align type [left, right, center, etc]')
    use_container = blocks.BooleanBlock(required=False, default=False)
    use_background_color = blocks.BooleanBlock(required=False)
    back_color = SnippetChooserBlock('home.Colors', blank=True, required=False)
    padding = blocks.CharBlock(default="none",
                               label='css padding value',
                               required=False)
    margin = blocks.CharBlock(default="none",
                              label='css margin value',
                              required=False)

    class Meta:
        template = 'tmps/tmp_full_text.html'
Ejemplo n.º 3
0
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'
Ejemplo n.º 4
0
class ContributorPage(Page, PagePreviewDescriptionMixin):
    '''Project contributor and advisory board page.'''
    contributors = StreamField(
        [('person', SnippetChooserBlock(Person))],
        blank=True,
        help_text='Select and order people to be listed as project \
        contributors.')
    board = StreamField(
        [('person', SnippetChooserBlock(Person))],
        blank=True,
        help_text='Select and order people to be listed as board members.')

    body = StreamField(BodyContentBlock, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('description'),
        StreamFieldPanel('contributors'),
        StreamFieldPanel('board'),
        StreamFieldPanel('body'),
    ]

    # only allow creating directly under home page
    parent_page_types = [HomePage]
    # not allowed to have sub pages
    subpage_types = []
Ejemplo n.º 5
0
class RoundFrameText(blocks.StructBlock):
    text = blocks.RichTextBlock()
    text_color = SnippetChooserBlock('home.Colors', blank=True)
    back_color = SnippetChooserBlock('home.Colors', blank=True)

    class Meta:
        template = 'tmps/tmp_round_frame_text.html'
        icon = 'placeholder'
        label = 'Round Frame Text'
Ejemplo n.º 6
0
    def test_form_response(self):
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        value = block.value_from_datadict({'advertwithcustomprimarykey': str(test_advert.pk)}, {}, 'advertwithcustomprimarykey')
        self.assertEqual(value, test_advert)

        empty_value = block.value_from_datadict({'advertwithcustomprimarykey': ''}, {}, 'advertwithcustomprimarykey')
        self.assertEqual(empty_value, None)
Ejemplo n.º 7
0
class CircleKeyValues(blocks.StructBlock):
    text_color = SnippetChooserBlock('home.Colors', blank=True)
    background_color = SnippetChooserBlock('home.Colors', blank=True)
    key_value = blocks.StreamBlock([('key_value', blocks.CharBlock())])

    class Meta:
        template = 'tmps/tmp_circle_key_value_aum.html'
        icon = 'placeholder'
        label = 'Little Circles with Value'
Ejemplo n.º 8
0
    def test_deserialize(self):
        """The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance"""
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        self.assertEqual(block.to_python(test_advert.pk), test_advert)

        # None should deserialize to None
        self.assertEqual(block.to_python(None), None)
Ejemplo n.º 9
0
    def test_serialize(self):
        """The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID"""
        block = SnippetChooserBlock(Advert)
        test_advert = Advert.objects.get(text='test_advert')

        self.assertEqual(block.get_prep_value(test_advert), test_advert.id)

        # None should serialize to None
        self.assertEqual(block.get_prep_value(None), None)
Ejemplo n.º 10
0
    def test_deserialize(self):
        """The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance"""
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        self.assertEqual(block.to_python(test_advert.pk), test_advert)

        # None should deserialize to None
        self.assertEqual(block.to_python(None), None)
Ejemplo n.º 11
0
    def test_deserialize(self):
        """The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance"""
        block = SnippetChooserBlock(Advert)
        test_advert = Advert.objects.get(text='test_advert')

        self.assertEqual(block.to_python(test_advert.id), test_advert)

        # None should deserialize to None
        self.assertEqual(block.to_python(None), None)
Ejemplo n.º 12
0
    def test_serialize(self):
        """The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID"""
        block = SnippetChooserBlock(Advert)
        test_advert = Advert.objects.get(text='test_advert')

        self.assertEqual(block.get_prep_value(test_advert), test_advert.id)

        # None should serialize to None
        self.assertEqual(block.get_prep_value(None), None)
Ejemplo n.º 13
0
    def test_deserialize(self):
        """The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance"""
        block = SnippetChooserBlock(Advert)
        test_advert = Advert.objects.get(text='test_advert')

        self.assertEqual(block.to_python(test_advert.id), test_advert)

        # None should deserialize to None
        self.assertEqual(block.to_python(None), None)
Ejemplo n.º 14
0
    def test_serialize(self):
        """The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID"""
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        self.assertEqual(block.get_prep_value(test_advert), test_advert.pk)

        # None should serialize to None
        self.assertEqual(block.get_prep_value(None), None)
Ejemplo n.º 15
0
    def test_form_response(self):
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        value = block.value_from_datadict({'advertwithcustomprimarykey': str(test_advert.pk)}, {}, 'advertwithcustomprimarykey')
        self.assertEqual(value, test_advert)

        empty_value = block.value_from_datadict({'advertwithcustomprimarykey': ''}, {}, 'advertwithcustomprimarykey')
        self.assertEqual(empty_value, None)
Ejemplo n.º 16
0
    def test_form_response(self):
        block = SnippetChooserBlock(Advert)
        test_advert = Advert.objects.get(text='test_advert')

        value = block.value_from_datadict({'advert': str(test_advert.id)}, {}, 'advert')
        self.assertEqual(value, test_advert)

        empty_value = block.value_from_datadict({'advert': ''}, {}, 'advert')
        self.assertEqual(empty_value, None)
Ejemplo n.º 17
0
    def test_serialize(self):
        """The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID"""
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        self.assertEqual(block.get_prep_value(test_advert), test_advert.pk)

        # None should serialize to None
        self.assertEqual(block.get_prep_value(None), None)
Ejemplo n.º 18
0
    def test_form_response(self):
        block = SnippetChooserBlock(Advert)
        test_advert = Advert.objects.get(text='test_advert')

        value = block.value_from_datadict({'advert': str(test_advert.id)}, {}, 'advert')
        self.assertEqual(value, test_advert)

        empty_value = block.value_from_datadict({'advert': ''}, {}, 'advert')
        self.assertEqual(empty_value, None)
Ejemplo n.º 19
0
class CustomBlock2(blocks.StructBlock):
    field_link = PageChooserBlock(required=False)
    field_link_list = blocks.ListBlock(PageChooserBlock(), required=False)
    field_image = ImageChooserBlock(required=False)
    field_image_list = blocks.ListBlock(ImageChooserBlock(), required=False)
    field_snippet = SnippetChooserBlock(target_model=App2Snippet,
                                        required=False)
    field_snippet_list = blocks.ListBlock(
        SnippetChooserBlock(target_model=App2Snippet), required=False)
Ejemplo n.º 20
0
class CentralCircle(blocks.StructBlock):
    anchor = blocks.CharBlock(label='Id of object to use as activator',
                              required=False)
    font_color = SnippetChooserBlock('home.Colors', blank=True)
    back_color = SnippetChooserBlock('home.Colors', blank=True)
    text_big = blocks.RichTextBlock(required=False)
    text_line1 = blocks.RichTextBlock(required=False)
    text_line2 = blocks.RichTextBlock(required=False)

    class Meta:
        template = 'tmps/tmp_centralcircle_aum.html'
Ejemplo n.º 21
0
class Comp_BigNumbAndTextTitle(blocks.StructBlock):
    text_color = SnippetChooserBlock('home.Colors', blank=True)
    text_mini_color = SnippetChooserBlock('home.Colors', blank=True)
    number_big = blocks.CharBlock(required=False)
    text_normal = blocks.RichTextBlock(required=False)
    text_title = blocks.CharBlock(required=False)

    class Meta:
        template = 'tmps/comp_bignumbtext_title.html'
        icon = 'placeholder'
        label = 'Big Number and Title with Sub'
Ejemplo n.º 22
0
class SimpleRecordsTable(blocks.StructBlock):
    field_text_color = SnippetChooserBlock('home.Colors', blank=True)
    detail_text_color = SnippetChooserBlock('home.Colors', blank=True)
    items = blocks.StreamBlock([
        ('record', SimpleRecordsItem()),
    ])

    class Meta:
        template = 'tmps/tmp_simple_records.html'
        icon = 'placeholder'
        label = 'Simple Records Table'
Ejemplo n.º 23
0
class GroupCards(blocks.StructBlock):
    text_color = SnippetChooserBlock('home.Colors', blank=True)
    index_color = SnippetChooserBlock('home.Colors', blank=True)
    background_color = SnippetChooserBlock('home.Colors', blank=True)

    cards = blocks.StreamBlock([('card', CardItem())])

    class Meta:
        template = 'tmps/tmp_groupcards.html'
        icon = 'placeholder'
        label = 'Group Cards'
Ejemplo n.º 24
0
    def test_form_render(self):
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey, help_text="pick an advert, any advert")

        empty_form_html = block.render_form(None, 'advertwithcustomprimarykey')
        self.assertInHTML('<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" />', empty_form_html)
        self.assertIn('createSnippetChooser("advertwithcustomprimarykey", "tests/advertwithcustomprimarykey");', empty_form_html)

        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')
        test_advert_form_html = block.render_form(test_advert, 'advertwithcustomprimarykey')
        expected_html = '<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" value="%s" />' % test_advert.pk
        self.assertInHTML(expected_html, test_advert_form_html)
        self.assertIn("pick an advert, any advert", test_advert_form_html)
Ejemplo n.º 25
0
    def test_form_render(self):
        block = SnippetChooserBlock(AdvertWithCustomPrimaryKey, help_text="pick an advert, any advert")

        empty_form_html = block.render_form(None, 'advertwithcustomprimarykey')
        self.assertInHTML('<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" />', empty_form_html)
        self.assertIn('createSnippetChooser("advertwithcustomprimarykey", "tests/advertwithcustomprimarykey");', empty_form_html)

        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')
        test_advert_form_html = block.render_form(test_advert, 'advertwithcustomprimarykey')
        expected_html = '<input id="advertwithcustomprimarykey" name="advertwithcustomprimarykey" placeholder="" type="hidden" value="%s" />' % test_advert.pk
        self.assertInHTML(expected_html, test_advert_form_html)
        self.assertIn("pick an advert, any advert", test_advert_form_html)
Ejemplo n.º 26
0
    def test_form_render(self):
        block = SnippetChooserBlock(Advert, help_text="pick an advert, any advert")

        empty_form_html = block.render_form(None, 'advert')
        self.assertInHTML('<input id="advert" name="advert" placeholder="" type="hidden" />', empty_form_html)
        self.assertIn('createSnippetChooser("advert", "tests/advert");', empty_form_html)

        test_advert = Advert.objects.get(text='test_advert')
        test_advert_form_html = block.render_form(test_advert, 'advert')
        expected_html = '<input id="advert" name="advert" placeholder="" type="hidden" value="%d" />' % test_advert.id
        self.assertInHTML(expected_html, test_advert_form_html)
        self.assertIn("pick an advert, any advert", test_advert_form_html)
Ejemplo n.º 27
0
    def test_form_render(self):
        block = SnippetChooserBlock(Advert, help_text="pick an advert, any advert")

        empty_form_html = block.render_form(None, 'advert')
        self.assertInHTML('<input id="advert" name="advert" placeholder="" type="hidden" />', empty_form_html)
        self.assertIn('createSnippetChooser("advert", "tests/advert");', empty_form_html)

        test_advert = Advert.objects.get(text='test_advert')
        test_advert_form_html = block.render_form(test_advert, 'advert')
        expected_html = '<input id="advert" name="advert" placeholder="" type="hidden" value="%d" />' % test_advert.id
        self.assertInHTML(expected_html, test_advert_form_html)
        self.assertIn("pick an advert, any advert", test_advert_form_html)
Ejemplo n.º 28
0
class MiniProfessorItem(blocks.StructBlock):
    name = blocks.CharBlock()
    subtitle = blocks.CharBlock(label="Professor of...")
    use_photo = blocks.BooleanBlock(required=False)
    image = ImageChooserBlock(required=False)
    letters = blocks.CharBlock(
        required=False, label="Inital Letter like AA if dont use picture")
    letters_color = SnippetChooserBlock('home.Colors',
                                        blank=True,
                                        required=False)
    letters_back = SnippetChooserBlock('home.Colors',
                                       blank=True,
                                       required=False)
    link = blocks.PageChooserBlock()
Ejemplo n.º 29
0
    def test_clean(self):
        required_block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        nonrequired_block = SnippetChooserBlock(AdvertWithCustomPrimaryKey, required=False)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        self.assertEqual(required_block.clean(test_advert), test_advert)
        with self.assertRaises(ValidationError):
            required_block.clean(None)

        self.assertEqual(nonrequired_block.clean(test_advert), test_advert)
        self.assertEqual(nonrequired_block.clean(None), None)
Ejemplo n.º 30
0
    def test_clean(self):
        required_block = SnippetChooserBlock(Advert)
        nonrequired_block = SnippetChooserBlock(Advert, required=False)
        test_advert = Advert.objects.get(text='test_advert')

        self.assertEqual(required_block.clean(test_advert), test_advert)
        with self.assertRaises(ValidationError):
            required_block.clean(None)

        self.assertEqual(nonrequired_block.clean(test_advert), test_advert)
        self.assertEqual(nonrequired_block.clean(None), None)
Ejemplo n.º 31
0
class _S_WhyBlock(blocks.StructBlock):
    why_background = ColorBlock(
        null=True,
        blank=False,
        help_text="Select background color that contrasts text")
    why_head = blocks.CharBlock(null=True,
                                blank=False,
                                classname="full title",
                                help_text="Bold header text")
    why_displayhead = blocks.BooleanBlock(
        null=True,
        blank=True,
        default=True,
        required=False,
        help_text="Whether or not to display the header")
    why_collum1 = Why_CollumBlock(null=True,
                                  blank=False,
                                  icon='cogs',
                                  help_text="Left block")
    why_collum2 = Why_CollumBlock(null=True,
                                  blank=False,
                                  icon='cogs',
                                  help_text="Middle block")
    why_collum3 = Why_CollumBlock(null=True,
                                  blank=False,
                                  icon='cogs',
                                  help_text="Right block")
    why_button = SnippetChooserBlock(
        Button,
        null=True,
        blank=True,
        required=False,
        help_text="Button displayed at why-section")
Ejemplo n.º 32
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)
Ejemplo n.º 33
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")
Ejemplo n.º 34
0
class OfficeBlock(blocks.StructBlock):
    office = SnippetChooserBlock(Office)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context=parent_context)
        context["candidates"] = [a for a in CandidatePage.objects.live()]
        return context
Ejemplo n.º 35
0
class FooterCTABlock(blocks.StructBlock):

    cta = SnippetChooserBlock(target_model='cta.CallToAction')

    class Meta:
        template = "includes/footer_cta.html"
        label = "Footer Call to Action"
Ejemplo n.º 36
0
class BTOPage(Page):
    background_image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )

    author = models.CharField(
        max_length=64, default="William D. Torcaso", null=True, blank=True,
    )
    body = StreamField(
        [
            ("heading", CharBlock(classname="full title")),
            ("rtblock", RichTextBlock()),
            ("image", ImageChooserBlock()),
        ],
        null=True,
        blank=True,
    )
    info_stream = StreamField(
        [("info_snippet", SnippetChooserBlock(BTOInfoSnippet))], null=True, blank=True,
    )
    template = "BTOPage/bto_responsive_page_v2.html"

    content_panels = Page.content_panels + [
        ImageChooserPanel("background_image"),
        FieldPanel("author"),
        StreamFieldPanel("body"),
        StreamFieldPanel("info_stream"),
    ]
Ejemplo n.º 37
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"
Ejemplo n.º 38
0
class _S_FeaturesBlock(blocks.StructBlock):
    features_background = ColorBlock(
        null=True,
        blank=False,
        help_text="Select background color that contrasts text")
    features_head = blocks.CharBlock(null=True,
                                     blank=False,
                                     classname="full title",
                                     help_text="Bold header text")
    features_displayhead = blocks.BooleanBlock(
        null=True,
        blank=True,
        default=True,
        required=False,
        help_text="Whether or not to display the header")
    features_subhead = blocks.CharBlock(null=True,
                                        blank=False,
                                        classname="full title",
                                        help_text="Smaller subhead text")
    features_displaysubhead = blocks.BooleanBlock(
        null=True,
        blank=True,
        default=True,
        required=False,
        help_text="Whether or not to display the header")
    features_button = SnippetChooserBlock(
        Button,
        null=True,
        blank=True,
        required=False,
        help_text="Button displayed at features-block")
    features_features = blocks.StreamBlock(
        [('feature', Features_FeatureBlock(null=True, blank=False))],
        null=True,
        blank=False)
Ejemplo n.º 39
0
    def test_clean(self):
        required_block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
        nonrequired_block = SnippetChooserBlock(AdvertWithCustomPrimaryKey, required=False)
        test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')

        self.assertEqual(required_block.clean(test_advert), test_advert)
        with self.assertRaises(ValidationError):
            required_block.clean(None)

        self.assertEqual(nonrequired_block.clean(test_advert), test_advert)
        self.assertEqual(nonrequired_block.clean(None), None)
Ejemplo n.º 40
0
    def test_clean(self):
        required_block = SnippetChooserBlock(Advert)
        nonrequired_block = SnippetChooserBlock(Advert, required=False)
        test_advert = Advert.objects.get(text='test_advert')

        self.assertEqual(required_block.clean(test_advert), test_advert)
        with self.assertRaises(ValidationError):
            required_block.clean(None)

        self.assertEqual(nonrequired_block.clean(test_advert), test_advert)
        self.assertEqual(nonrequired_block.clean(None), None)
Ejemplo n.º 41
0
 def test_reference_model_by_string(self):
     block = SnippetChooserBlock('tests.Advert')
     test_advert = Advert.objects.get(text='test_advert')
     self.assertEqual(block.to_python(test_advert.id), test_advert)