Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Update AnnotatedImageBlock to use LinkBlock" #12522

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
Loading