Skip to content

BE: MozFest Spaces Cards#7456

Merged
b-ggs merged 7 commits intofeature/BE-FE-spaces-cardsfrom
feature/7428-mozfest-space-cards
Sep 28, 2021
Merged

BE: MozFest Spaces Cards#7456
b-ggs merged 7 commits intofeature/BE-FE-spaces-cardsfrom
feature/7428-mozfest-space-cards

Conversation

@b-ggs
Copy link
Collaborator

@b-ggs b-ggs commented Sep 23, 2021

Related PRs/issues #7428

Created a new StructBlock field called SpaceCardListBlock containing a heading and a list of child blocks named SpaceCardBlock that have their own titles, plain-text bodies, images, and links to either a Wagtail page or an external URL.

Also added a card template similar to an existing card block.

Screen Shot 2021-09-24 at 7 00 57 PM

Checklist

Changes in Models:

  • Did I squash my migration?

@@ -0,0 +1,23 @@
# Generated by Django 3.1.11 on 2021-09-22 13:02
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's usually helpful to give migrations names.

You can name your migrations with python manage.py makemigrations -n some_name_here.

Outputs: 0021_some_name_here.py

Comment on lines +8 to +17
class SpaceCardBlockStructValue(blocks.StructValue):
@property
def link(self):
link_url = self.get('link_url')
link_page = self.get('link_page')

if link_url:
return link_url
elif link_page:
return link_page.url
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a common enough structure that it might makes sense to move this to somewhere shared.

Comment on lines +31 to +54
link_page = blocks.PageChooserBlock(
required=False,
help_text='Page that this card should link out to.',
)

link_url = blocks.URLBlock(
required=False,
help_text='URL that this card should link out to.',
)

def clean(self, value):
errors = {}

link_page = value.get('link_page')
link_url = value.get('link_url')

if (link_page and link_url) or (not link_page and not link_url):
errors['link_page'] = ErrorList(['Please specify either a link page or a link URL.'])
errors['link_url'] = ErrorList(['Please specify either a link page or a link URL.'])

if errors:
raise StructBlockValidationError(errors)

return super().clean(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you put these here instead of SpaceCardBlockStructValue because of the field order in the editor?

@mofodevops mofodevops temporarily deployed to foundation-s-feature-74-pbziix September 24, 2021 11:02 Inactive
@mofodevops mofodevops temporarily deployed to foundation-s-feature-74-xpwjwp September 24, 2021 11:02 Inactive
@b-ggs b-ggs requested a review from Pomax September 24, 2021 11:04
@b-ggs
Copy link
Collaborator Author

b-ggs commented Sep 24, 2021

Hey @SharmaineLim and @Pomax! Whenever it's convenient, would you mind reviewing this new StructBlock field? Thank you!

Copy link
Contributor

@SharmaineLim SharmaineLim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, LGTM. See comment.

Comment on lines +19 to +35
image = ImageChooserBlock()

title = blocks.CharBlock(
help_text='Heading for the card.'
)

body = blocks.TextBlock(
help_text='Body text of the card.'
)

link = blocks.StreamBlock(
[
('internal', blocks.PageChooserBlock(help_text='Page that this card should link out to.')),
('external', blocks.URLBlock(help_text='URL that this card should link out to.')),
],
max_num=1,
)
Copy link
Contributor

@SharmaineLim SharmaineLim Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, something to check: do pages here already have listing_image, listing_title and listing_summary (or similar)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new StructBlock shares the most similarity to CardGrid.

@mofodevops mofodevops temporarily deployed to foundation-s-feature-74-xpwjwp September 28, 2021 05:47 Inactive
@b-ggs b-ggs merged commit 9d41409 into feature/BE-FE-spaces-cards Sep 28, 2021
@b-ggs b-ggs deleted the feature/7428-mozfest-space-cards branch September 28, 2021 05:47
@wilhitem wilhitem added this to the MozFest 2021 TBX milestone Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants