Skip to content

Commit

Permalink
Revert "Update AnnotatedImageBlock to use LinkBlock (#12481)" (#12522)
Browse files Browse the repository at this point in the history
This reverts commit a3ec651.
  • Loading branch information
danielfmiranda authored Jun 21, 2024
1 parent 88b4540 commit ca012e0
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 18,367 deletions.

This file was deleted.

This file was deleted.

236 changes: 29 additions & 207 deletions network-api/networkapi/reports/tests/test_block_type_report.py

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions network-api/networkapi/utility/faker/streamfield_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,16 @@ def generate_image_field():
image_id = choice(Image.objects.all()).id
alt_text = " ".join(fake.words(nb=5))
caption = " ".join(fake.words(nb=5))
caption_external_url = [
{
"link_to": "external_url",
"external_url": fake.url(schemes=["https"]),
"new_window": True,
}
]
caption_url = fake.url(schemes=["https"])

return generate_field(
"image",
{"image": image_id, "altText": alt_text, "caption": caption, "caption_url": caption_external_url},
{
"image": image_id,
"altText": alt_text,
"caption": caption,
"captionURL": caption_url,
},
)


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from wagtail import blocks

from .image_block import ImageBlock
from .link_block import LinkWithoutLabelBlock


class RadioSelectBlock(blocks.ChoiceBlock):
Expand All @@ -13,9 +12,7 @@ def __init__(self, *args, **kwargs):

class AnnotatedImageBlock(ImageBlock):
caption = blocks.CharBlock(required=False)
caption_url = blocks.ListBlock(
LinkWithoutLabelBlock(), min_num=0, max_num=1, help_text="Optional URL that this caption should link out to."
)
captionURL = blocks.CharBlock(required=False, help_text="Optional URL that this caption should link out to.")
image_width = RadioSelectBlock(
choices=(
("normal", "Normal"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,3 @@ class Meta:


register(BaseLinkBlockAdapter(), 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(), LinkWithoutLabelBlock)
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@
<img src="{{ img.url }}" alt="{{ value.altText }}" class="tw-w-full {% if value.image_width == "full_width" %} tw-object-cover tw-object-center tw-max-h-[400px] large:tw-max-h-[550px] xlarge:tw-max-h-[650px] {% endif %}">
{% if value.caption %}
<figcaption class="tw-body-small tw-mt-4 tw-block {% if value.image_width == "full_width" %} tw-pl-6 {% endif %}">
{% if value.caption_url %}
{% with link=value.caption_url.0 %}
<a href="{{ link.url }}" {% if link.new_window %}target="_blank"{% endif %}>{{ value.caption }}</a>
{% endwith %}
{% else %}
{{ value.caption }}
{% endif %}
{% if value.captionURL %}<a href="{{ value.captionURL }}">{% endif %}
{{ value.caption }}
{% if value.captionURL %}</a>{% endif %}
</figcaption>
{% endif %}
</figure>
Expand Down

0 comments on commit ca012e0

Please sign in to comment.