Skip to content

Commit

Permalink
Finish code for contact cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-Crow committed Dec 5, 2024
1 parent 49175ad commit efb6bfa
Show file tree
Hide file tree
Showing 7 changed files with 8,208 additions and 108 deletions.

Large diffs are not rendered by default.

40 changes: 39 additions & 1 deletion content_manager/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,41 @@ def display(self):

image = self.get("image", "")
if contact and not image:
organization = contact.organization.image
image = contact.image

return {"name": name, "role": role, "organization": organization, "image": image}

def enlarge_link(self):
"""
Determine if we need (and can) enlarge the link on the card.
This requires:
- That a link is present
- That no other link is used on the card (such as a tag with a link, or a call-to-action)
"""
link = self.get("link")
tags = self.get("tags")
call_to_action = self.get("call_to_action", "")

if not (link and link.url()):
return False

enlarge = True
if len(call_to_action):
enlarge = False
elif len(tags):
print(tags)
print(tags.raw_data)
tags_list = tags.raw_data
for tag in tags_list:
if (
tag["value"]["link"]["page"] is not None
or tag["value"]["link"]["document"] is not None
or tag["value"]["link"]["external_url"] != ""
):
enlarge = False

return enlarge


class VerticalContactCardBlock(blocks.StructBlock):
contact = SnippetChooserBlock(
Expand All @@ -751,6 +782,13 @@ class VerticalContactCardBlock(blocks.StructBlock):
label=_("Link"),
required=False,
)
heading_tag = blocks.ChoiceBlock(
label=_("Heading level"),
choices=HEADING_CHOICES,
required=False,
default="h3",
help_text=_("Adapt to the page layout. Defaults to heading 3."),
)
name = blocks.CharBlock(label=_("Name"), max_length=255, required=False)
role = blocks.CharBlock(label=_("Role"), max_length=255, required=False)
organization = blocks.CharBlock(label=_("Organization"), max_length=255, required=False)
Expand Down
Binary file modified content_manager/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit efb6bfa

Please sign in to comment.