Skip to content

Commit

Permalink
Merge pull request #8276 from cfpb/ans_content_block
Browse files Browse the repository at this point in the history
Ask CFPB: Move Tip to Ask
  • Loading branch information
anselmbradford authored Apr 3, 2024
2 parents fddfb03 + 612f34b commit 21f2af4
Show file tree
Hide file tree
Showing 30 changed files with 1,494 additions and 992 deletions.
31 changes: 31 additions & 0 deletions cfgov/ask_cfpb/jinja2/ask-cfpb/ask-answer-content.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{# ==========================================================================

Content block

==========================================================================

Description:

Outputs the blocks from an Ask content streamfield:

value: List of blocks from a Streamfield block.

========================================================================== #}

{% for block in value %}
{% set after_tip = value[loop.index - 2].block_type == 'tip' if loop.index > 1 else False %}
{% if not after_tip %}
<div class="row {{'inset-row' if block.block_type == 'tip' else block.block_type~'-row'}}"
{% if block.value.anchor_tag %}
id="{{ block.value.anchor_tag }}"
{% endif %}>
{% endif %}
{% if block.block_type == 'text' %}
{{ block.value.content | richtext | safe }}
{% else %}
{% include_block block %}
{% endif %}
{% if block.block_type != 'tip' or loop.last %}
</div>
{% endif %}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

========================================================================== #}


<aside class="m-inset m-inset__bordered">
<h4>{{ _('Tip') }}</h4>
{{ value.content | richtext | safe }}
</aside>
</aside>
71 changes: 37 additions & 34 deletions cfgov/ask_cfpb/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-19 11:38-0500\n"
"POT-Creation-Date: 2024-03-29 11:30-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -18,68 +18,67 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:9
#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:7
msgid "Consumer Financial Protection Bureau"
msgstr ""

#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:34
#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:28
msgid "last reviewed"
msgstr "revisado"

#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:78
#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:60
msgid "Read full answer"
msgstr "Leer más"

#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:82
msgid "Learn more about"
msgstr "Sepa más sobre"

#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:95
#: ask_cfpb/jinja2/ask-cfpb/see-all.html:83
#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:66
#: ask_cfpb/jinja2/ask-cfpb/see-all.html:84
msgid "Don't see what you're looking for?"
msgstr "¿No encuentra lo que busca?"

#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:98
#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:69
msgid "Browse related questions"
msgstr "Otras preguntas"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:19
#: ask_cfpb/jinja2/ask-cfpb/answer-page.html:82
msgid "Learn more about"
msgstr "Sepa más sobre"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:18
msgid "Search our library of answers"
msgstr "Buscar en nuestra lista de respuestas"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:28
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:27
msgid "Showing results for "
msgstr "Se muestran resultados para "

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:30
#: ask_cfpb/models/pages.py:259
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:29
#: ask_cfpb/models/pages.py:202
msgid "Showing"
msgstr "Se muestran"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:30
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:29
msgid "of"
msgstr "de"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:30
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:29
msgid "results for"
msgstr "resultados para"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:33
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:75
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:32
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:72
msgid "Search instead for"
msgstr "Busca de"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:33
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:75
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:32
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:72
msgid "/ask-cfpb/search"
msgstr "/es/obtener-respuestas/buscar"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:69
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:71
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:68
msgid "No results found for"
msgstr "No se encontraron resultados para"

#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:86
#: ask_cfpb/jinja2/ask-cfpb/answer-search-results.html:84
msgid "Please enter a search term in the box above."
msgstr "Por favor escriba su búsqueda arriba"

Expand Down Expand Up @@ -107,39 +106,43 @@ msgstr "Buscar"
msgid "Clear search"
msgstr "Borrar búsqueda"

#: ask_cfpb/jinja2/ask-cfpb/see-all.html:83
#: ask_cfpb/jinja2/ask-cfpb/see-all.html:85
msgid "/ask-cfpb/search/"
msgstr "/es/obtener-respuestas/buscar/"

#: ask_cfpb/jinja2/ask-cfpb/see-all.html:83
#: ask_cfpb/jinja2/ask-cfpb/see-all.html:85
msgid "Search our full library of answers"
msgstr "Buscar en toda la lista de respuestas"

#: ask_cfpb/models/pages.py:252
#: ask_cfpb/jinja2/ask-cfpb/tip.html:18
msgid "Tip"
msgstr ""

#: ask_cfpb/models/pages.py:195
msgid "for"
msgstr "para"

#: ask_cfpb/models/pages.py:256
#: ask_cfpb/models/pages.py:199
msgid "Showing "
msgstr "Se muestra "

#: ask_cfpb/models/pages.py:257
#: ask_cfpb/models/pages.py:200
msgid "result"
msgstr "resultado"

#: ask_cfpb/models/pages.py:260
#: ask_cfpb/models/pages.py:203
msgid "results"
msgstr "resultados"

#: ask_cfpb/models/pages.py:270 ask_cfpb/models/pages.py:278
#: ask_cfpb/models/pages.py:281
#: ask_cfpb/models/pages.py:213 ask_cfpb/models/pages.py:221
#: ask_cfpb/models/pages.py:224
msgid "within"
msgstr "en"

#: ask_cfpb/models/pages.py:273
#: ask_cfpb/models/pages.py:216
msgid "See all results within"
msgstr "Ver todos los resultados para"

#: ask_cfpb/templates/admin/export.html:3
msgid "Export Ask data"
msgstr ""
msgstr ""
22 changes: 22 additions & 0 deletions cfgov/ask_cfpb/migrations/0007_move_tip_to_ask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.24 on 2024-03-28 21:39

from django.db import migrations
import wagtail.blocks
import wagtail.contrib.typed_table_block.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):

dependencies = [
('ask_cfpb', '0006_raw_html_affordances'),
]

operations = [
migrations.AlterField(
model_name='answerpage',
name='answer_content',
field=wagtail.fields.StreamField([('text', wagtail.blocks.StructBlock([('anchor_tag', wagtail.blocks.CharBlock(help_text="Add an optional anchor link tag to allow linking directly to this block. Tag should be unique and use dashes or underscores for separation instead of spaces (ie, 'block-one-tag')", label='Anchor tag', required=False)), ('content', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'h2', 'h3', 'link', 'ol', 'ul', 'document-link', 'image', 'embed'], label='Text'))])), ('table', wagtail.blocks.StructBlock([('heading', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock(required=False)), ('level', wagtail.blocks.ChoiceBlock(choices=[('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('h5', 'H5')])), ('icon', wagtail.blocks.CharBlock(help_text='Input the name of an icon to appear to the left of the heading. E.g., approved, help-round, etc. <a href="https://cfpb.github.io/design-system/foundation/iconography">See full list of icons</a>', required=False))], required=False)), ('text_introduction', wagtail.blocks.CharBlock(required=False)), ('options', wagtail.blocks.MultipleChoiceBlock(choices=[('is_full_width', 'Display the table at full width'), ('stack_on_mobile', 'Stack the table columns on mobile')], required=False)), ('data', wagtail.contrib.typed_table_block.blocks.TypedTableBlock([('text', wagtail.blocks.CharBlock()), ('numeric', wagtail.blocks.FloatBlock()), ('rich_text', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'ol', 'ul', 'link', 'document-link', 'superscript']))]))])), ('tip', wagtail.blocks.StructBlock([('content', wagtail.blocks.RichTextBlock(features=['link', 'document-link'], label='Tip'))], label='Tip (floats right)')), ('video_player', wagtail.blocks.StructBlock([('video_id', wagtail.blocks.RegexBlock(error_messages={'invalid': 'The YouTube video ID is in the wrong format.'}, help_text='Enter the YouTube video ID, which is located at the end of the video URL, after "v=". For example, the video ID for https://www.youtube.com/watch?v=1V0Ax9OIc84 is 1V0Ax9OIc84.', label='YouTube video ID', regex='^[\\w-]{11}$', required=False)), ('thumbnail_image', wagtail.images.blocks.ImageChooserBlock(help_text='Optional thumbnail image to show before and after the video plays. If the thumbnail image is not set here, the video player will default to showing the thumbnail that was set in (or automatically chosen by) YouTube.', required=False))])), ('how_to_schema', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Title of How To section', max_length=500)), ('title_tag', wagtail.blocks.ChoiceBlock(choices=[('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4')], help_text='Choose a tag for the title of the How To section.', label='Tag for How To section title')), ('show_title', wagtail.blocks.BooleanBlock(default=True, help_text='The How To schema requires a title to let search engines understand what it is about. If you do not want the title to be displayed in the page, uncheck this box and the title content will only be made available to crawlers and screen readers.', label='Show How To section title', required=False)), ('description', wagtail.blocks.RichTextBlock(blank=True, features=['ol', 'ul', 'bold', 'italic', 'link', 'document-link'], required=False)), ('step_title_tag', wagtail.blocks.ChoiceBlock(choices=[('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('b', 'Bold'), ('p', 'Paragraph')], help_text='Choose a tag for the title of each HowTo step.', label='Tag for step titles')), ('has_numbers', wagtail.blocks.BooleanBlock(default=False, help_text='Check this box to display numbers before step titles. ', label='Show numbers for steps', required=False)), ('steps', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('anchor_tag', wagtail.blocks.CharBlock(blank=True, help_text="Add an optional anchor link tag to allow linking directly to this step. Tag should be unique and use dashes or underscores for separation instead of spaces (ie, 'step-one-tag').", max_length=500, required=False)), ('title', wagtail.blocks.CharBlock(help_text='Enter a title for this HowTo step. You do not need to include a number in the title -- numbers will be added automatically in the template if the show numbers checkbox is checked.', max_length=500)), ('step_content', wagtail.blocks.StreamBlock([('text', wagtail.blocks.StructBlock([('content', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'h3', 'h4', 'link', 'ol', 'ul', 'document-link', 'image', 'embed'], label='Text'))])), ('table', wagtail.blocks.StructBlock([('heading', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock(required=False)), ('level', wagtail.blocks.ChoiceBlock(choices=[('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('h5', 'H5')])), ('icon', wagtail.blocks.CharBlock(help_text='Input the name of an icon to appear to the left of the heading. E.g., approved, help-round, etc. <a href="https://cfpb.github.io/design-system/foundation/iconography">See full list of icons</a>', required=False))], required=False)), ('text_introduction', wagtail.blocks.CharBlock(required=False)), ('options', wagtail.blocks.MultipleChoiceBlock(choices=[('is_full_width', 'Display the table at full width'), ('stack_on_mobile', 'Stack the table columns on mobile')], required=False)), ('data', wagtail.contrib.typed_table_block.blocks.TypedTableBlock([('text', wagtail.blocks.CharBlock()), ('numeric', wagtail.blocks.FloatBlock()), ('rich_text', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'ol', 'ul', 'link', 'document-link', 'superscript']))]))])), ('video_player', wagtail.blocks.StructBlock([('video_id', wagtail.blocks.RegexBlock(error_messages={'invalid': 'The YouTube video ID is in the wrong format.'}, help_text='Enter the YouTube video ID, which is located at the end of the video URL, after "v=". For example, the video ID for https://www.youtube.com/watch?v=1V0Ax9OIc84 is 1V0Ax9OIc84.', label='YouTube video ID', regex='^[\\w-]{11}$', required=False)), ('thumbnail_image', wagtail.images.blocks.ImageChooserBlock(help_text='Optional thumbnail image to show before and after the video plays. If the thumbnail image is not set here, the video player will default to showing the thumbnail that was set in (or automatically chosen by) YouTube.', required=False))]))]))])))], label='Google Schema - How To')), ('faq_schema', wagtail.blocks.StructBlock([('description', wagtail.blocks.RichTextBlock(blank=True, features=['ol', 'ul', 'bold', 'italic', 'link', 'document-link'], required=False)), ('questions', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('anchor_tag', wagtail.blocks.CharBlock(blank=True, help_text="Add an optional anchor link tag for this question. Tag should be unique and use dashes or underscores for separation instead of spaces (ie, 'question-one-tag')", max_length=500, required=False)), ('question', wagtail.blocks.CharBlock(max_length=500)), ('answer_content', wagtail.blocks.StreamBlock([('text', wagtail.blocks.StructBlock([('content', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'h3', 'h4', 'link', 'ol', 'ul', 'document-link', 'image', 'embed'], label='Text'))])), ('table', wagtail.blocks.StructBlock([('heading', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock(required=False)), ('level', wagtail.blocks.ChoiceBlock(choices=[('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('h5', 'H5')])), ('icon', wagtail.blocks.CharBlock(help_text='Input the name of an icon to appear to the left of the heading. E.g., approved, help-round, etc. <a href="https://cfpb.github.io/design-system/foundation/iconography">See full list of icons</a>', required=False))], required=False)), ('text_introduction', wagtail.blocks.CharBlock(required=False)), ('options', wagtail.blocks.MultipleChoiceBlock(choices=[('is_full_width', 'Display the table at full width'), ('stack_on_mobile', 'Stack the table columns on mobile')], required=False)), ('data', wagtail.contrib.typed_table_block.blocks.TypedTableBlock([('text', wagtail.blocks.CharBlock()), ('numeric', wagtail.blocks.FloatBlock()), ('rich_text', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'ol', 'ul', 'link', 'document-link', 'superscript']))]))])), ('video_player', wagtail.blocks.StructBlock([('video_id', wagtail.blocks.RegexBlock(error_messages={'invalid': 'The YouTube video ID is in the wrong format.'}, help_text='Enter the YouTube video ID, which is located at the end of the video URL, after "v=". For example, the video ID for https://www.youtube.com/watch?v=1V0Ax9OIc84 is 1V0Ax9OIc84.', label='YouTube video ID', regex='^[\\w-]{11}$', required=False)), ('thumbnail_image', wagtail.images.blocks.ImageChooserBlock(help_text='Optional thumbnail image to show before and after the video plays. If the thumbnail image is not set here, the video player will default to showing the thumbnail that was set in (or automatically chosen by) YouTube.', required=False))]))]))])))], label='Google Schema - FAQ'))], blank=True, use_json_field=True, verbose_name='Answer'),
),
]
20 changes: 15 additions & 5 deletions cfgov/ask_cfpb/models/blocks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from wagtail import blocks

from v1.atomic_elements import organisms
from v1.atomic_elements.schema import FAQ, HowTo, Tip
from v1.atomic_elements.organisms import Table, VideoPlayer
from v1.atomic_elements.schema import FAQ, HowTo


class Tip(blocks.StructBlock):
content = blocks.RichTextBlock(
features=["link", "document-link"], label="Tip"
)

class Meta:
icon = "title"
template = "ask-cfpb/tip.html"


class AskAnswerContent(blocks.StreamBlock):
Expand Down Expand Up @@ -38,11 +48,11 @@ class AskAnswerContent(blocks.StreamBlock):
),
]
)
table = organisms.Table()
table = Table()
tip = Tip(label="Tip (floats right)")
video_player = organisms.VideoPlayer()
video_player = VideoPlayer()
how_to_schema = HowTo(label="Google Schema - How To")
faq_schema = FAQ(label="Google Schema - FAQ")

class Meta:
template = "v1/includes/blocks/schema/content-block.html"
template = "ask-cfpb/ask-answer-content.html"
4 changes: 2 additions & 2 deletions cfgov/ask_cfpb/tests/test_blocks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.test import TestCase, override_settings

from ask_cfpb.models.blocks import AskAnswerContent
from v1.atomic_elements.schema import FAQ, HowTo, Tip
from ask_cfpb.models.blocks import AskAnswerContent, Tip
from v1.atomic_elements.schema import FAQ, HowTo


@override_settings(LANGUAGE_CODE="en-US", LANGUAGES=(("en", "English"),))
Expand Down
Loading

0 comments on commit 21f2af4

Please sign in to comment.