Skip to content

Commit

Permalink
rename to LinkWithoutLabelBlock to match other block naming
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfmiranda committed Jun 14, 2024
1 parent 9f34050 commit 909b45f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
26 changes: 16 additions & 10 deletions network-api/networkapi/reports/tests/test_block_type_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ def test_view(self):
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

block = object_list[3]
self.assertEqual(block["block"], "wagtail.blocks.field_block.CharBlock")
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.link_block.LinkWithoutLabelBlock"
)
self.assertEqual(block["count"], 2)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertEqual(block["type_label"], "Custom")
self.assertTrue(block["is_custom_block"])
self.assertListEqual([primary_page.content_type, campaign_page.content_type], block["content_types"])

block = object_list[4]
Expand Down Expand Up @@ -176,10 +178,12 @@ def test_page_unpublished(self):
self.assertListEqual([campaign_page.content_type], block["content_types"])

block = object_list[3]
self.assertEqual(block["block"], "wagtail.blocks.field_block.CharBlock")
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.link_block.LinkWithoutLabelBlock"
)
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertEqual(block["type_label"], "Custom")
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

block = object_list[4]
Expand Down Expand Up @@ -225,7 +229,7 @@ def test_page_deleted(self):
)

# Two pages have crated ImageBlocks
# Each ImageBlock has a ImageChooserBlock and a CharBlock
# Each ImageBlock has a ImageChooserBlock and a LinkWithoutLabelBlock
# These should be in alphabetical order since they all have the same count
block = object_list[1]
self.assertEqual(
Expand All @@ -246,10 +250,12 @@ def test_page_deleted(self):
self.assertListEqual([campaign_page.content_type], block["content_types"])

block = object_list[3]
self.assertEqual(block["block"], "wagtail.blocks.field_block.CharBlock")
self.assertEqual(
block["block"], "networkapi.wagtailpages.pagemodels.customblocks.link_block.LinkWithoutLabelBlock"
)
self.assertEqual(block["count"], 1)
self.assertEqual(block["type_label"], "Core")
self.assertFalse(block["is_custom_block"])
self.assertEqual(block["type_label"], "Custom")
self.assertTrue(block["is_custom_block"])
self.assertListEqual([campaign_page.content_type], block["content_types"])

block = object_list[4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from wagtail import blocks

from .image_block import ImageBlock
from .link_block import LinkBlockWithoutLabel
from .link_block import LinkWithoutLabelBlock


class RadioSelectBlock(blocks.ChoiceBlock):
Expand All @@ -14,7 +14,7 @@ def __init__(self, *args, **kwargs):
class AnnotatedImageBlock(ImageBlock):
caption = blocks.CharBlock(required=False)
caption_url = blocks.ListBlock(
LinkBlockWithoutLabel(), min_num=0, max_num=1, help_text="Optional URL that this caption should link out to."
LinkWithoutLabelBlock(), min_num=0, max_num=1, help_text="Optional URL that this caption should link out to."
)
image_width = RadioSelectBlock(
choices=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class Meta:
register(BaseLinkBlockAdapter(), LinkBlock)


class LinkBlockWithoutLabel(LinkBlock):
class LinkWithoutLabelBlock(LinkBlock):
def __init__(self, local_blocks=None, **kwargs):
super().__init__(local_blocks, **kwargs)
self.child_blocks = self.base_blocks.copy()
self.child_blocks.pop("label")


register(BaseLinkBlockAdapter(), LinkBlockWithoutLabel)
register(BaseLinkBlockAdapter(), LinkWithoutLabelBlock)

0 comments on commit 909b45f

Please sign in to comment.