Add Monitor article pages to CMS #15751#16084
Conversation
bedrock/products/migrations/0005_monitorcalltoactionsnippet_monitorarticleindexpage_and_more.py
Outdated
Show resolved
Hide resolved
41d21d2 to
ddc31d5
Compare
3968083 to
adaf3ac
Compare
|
Does this need the |
bedrock/mozorg/templates/mozorg/cms/about/blocks/leadership_block.html
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16084 +/- ##
==========================================
+ Coverage 79.55% 79.70% +0.15%
==========================================
Files 160 160
Lines 8436 8514 +78
==========================================
+ Hits 6711 6786 +75
- Misses 1725 1728 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Yes, I think the richtext changes will benefit springfield |
0bcec71 to
0b0e03a
Compare
d6de04c to
d5b44b0
Compare
stevejalim
left a comment
There was a problem hiding this comment.
Spotted a couple of things to fix up - happy to re-review later, or to chat about them
465fd48 to
2e2bbc8
Compare
stevejalim
left a comment
There was a problem hiding this comment.
Backend/Wagtail-focused review: r+wc - nothing blocking
I'll leave an FE dev to test drive themselves, too
Nice one @stephaniehobson!
| </body> | ||
| </html> | ||
| """ | ||
| expected_html = """ |
There was a problem hiding this comment.
This is fine/workable as is, but you mentioned in Slack how it made you a bit 🤢 -- so you may find Python's textwrap.dedent to be handy, but don't feel like you have to shoehorn that in right now
There was a problem hiding this comment.
It did not immediately work so I'll leave it for a future improvement.
bedrock/products/models.py
Outdated
| max_length=60, | ||
| blank=True, | ||
| ) | ||
| split_content = RichTextField(null=True, blank=True, features=["bold", "italic", "link", "ul", "ol"]) |
There was a problem hiding this comment.
Nit: we should move this features list in to a setting eg RICHTEXT_FEATURES_MINIMAL
bedrock/products/models.py
Outdated
|
|
||
| parent_page_types = ["MonitorArticleIndexPage"] # must be child of MonitorArticleIndexPage | ||
|
|
||
| def get_context(self, request): |
There was a problem hiding this comment.
If we can't add a test for this now, please feel free to ticket up adding one and pop my face on it. Happy to help
alexgibson
left a comment
There was a problem hiding this comment.
When I create a new Monitor article index page and fill out the required fields, I get the following error:
Traceback (most recent call last):
File "/Users/alexgibson/.pyenv/versions/3.12.6/envs/bedrock/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/alexgibson/.pyenv/versions/3.12.6/envs/bedrock/lib/python3.12/site-packages/wagtail/models/__init__.py", line 717, in _get_response
response = obj.serve_preview(request, preview_mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alexgibson/Documents/GitHub/bedrock/bedrock/cms/models/base.py", line 88, in serve_preview
return self._render_with_fluent_string_support(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alexgibson/Documents/GitHub/bedrock/bedrock/cms/models/base.py", line 69, in _render_with_fluent_string_support
context = self.get_context(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: TypeError at /en-US/products/monitor/
Exception Value: MonitorArticleIndexPage.get_context() takes 2 positional arguments but 3 were given
|
I can't reproduce the error but I made a change that will fix it hopefully 🤞 |
My gut said that this was triggered by Alex using the live preview, which would pass an extra argument to So the fix here is to fully match the signature for I've done that in 69477ef and pushed it up. |
This fixed the issue for me ^ |
alexgibson
left a comment
There was a problem hiding this comment.
A couple of small issues / suggestions but otherwise everything works as described. nice work!
- Add Monitor landing and article page models - Add Monitor landing and article page templates - Including a sub nav - Including a sticky table of contents - Add wagtail_richtext filter to help style markup in articles - Adds appropriate Protocol class to ul and ols - Adds an id to headings - Adds a space around em dashes - Adds rel and target attributes to external links
...so that we don't end up changing the spec of the wagtail.models.Page class, which in turn generates a migration that we cannot (and should not) add to the codebase
- Add Monitor landing and article page models - Add Monitor landing and article page templates - Including a sub nav - Including a sticky table of contents - Add wagtail_richtext filter to help style markup in articles - Adds appropriate Protocol class to ul and ols - Adds an id to headings - Adds a space around em dashes - Adds rel and target attributes to external links
…gtail expedts ...and that calls to super().get_context() also pass those through to the superclass (eg wagtail.Page) This fixes a blow-up with Monitor pages when being live previewed, and also tightens up existing pages that use get_context
69477ef to
7c60676
Compare
|
|
||
| sub_title = wagtail_factories.CharBlockFactory | ||
| articles_heading = wagtail_factories.CharBlockFactory | ||
| split_heading = wagtail_factories.CharBlockFactory |
There was a problem hiding this comment.
This is throwing an error because it's too long {'split_heading': ['Ensure this value has at most 60 characters (it has 69).']}. Is there a way to give the restriction to the Factory? Or should I hard code something?
There was a problem hiding this comment.
You can stop the tests blowing up by setting a hard-coded value for the CharBlockFactory
split_heading = wagtail_factories.CharBlockFactory(value="Test split heading")
There are a couple of places where this would need adding.
However, I don't think we should fix the tests like that.
I think (and wish I'd thought it sooner) that having a 60-char limit (or any hard limit) on strings that will get translated could easily bite us later when they flow back from Smartling, because:
- To my understanding
wagtail-localizedoesn't enforce a characarter limit - Therefore nor does our
wagtail-localize-smartlingintegration - I've not seen anything in Smartling itself that limits the length of translated strings, either
I think all of those above are the right design decision, because the Finnish, say, for a word is likely to be longer than the English source in some cases.
If we have a 60 char limit and the translated version is 61, the Wagtail<->Smartling sync will definitely break because the translated field is too long.
I think instead the better, more robust path is to remove the hard limit on the headings and add help_text="Please aim for no more than 60 characters maximum" or similar to each field.
I know there's a risk of translations creating bad flows/line breaks, but the translators in Smartling do get a live view of the content they are translating, including Snippets.
Hope that helps. DM me if you need me and time is tight
There was a problem hiding this comment.
Updated to remove the character limits temporarily. We should discuss how to have some kind of limit, at least in English but that can wait.
3a5a6e8 to
a956389
Compare
a956389 to
a138aaa
Compare
|
Updated! |
* Add Monitor article pages to CMS - Add Monitor landing and article page models - Add Monitor landing and article page templates - Including a sub nav - Including a sticky table of contents - Add wagtail_richtext filter to help style markup in articles - Adds appropriate Protocol class to ul and ols - Adds an id to headings - Adds a space around em dashes - Adds rel and target attributes to external links - Add new Monitor CMS pages to the allowlist so they can be added when DEV=False - add test for add_bedrock_attributes helper - review fixes - fix get_context error? - Ensure that get_context() signatures on our page models match what Wagtail expedts - ...and that calls to super().get_context() also pass those through to the superclass (eg wagtail.Page) - This fixes a blow-up with Monitor pages when being live previewed, and also tightens up existing pages that use get_context - Add tests --------- Co-authored-by: Steve Jalim <stevejalim@mozilla.com> Co-authored-by: Stephanie Hobson <shobson@mozilla.com>

One-line summary
Add Monitor article pages to CMS
Significant changes and points to review
Issue / Bugzilla link
#15751
Testing
CMS
Mozilla Products(this should be included in local db)Monitor article index page, with a slug ofmonitor. Fill in the other required fields.Monitor article page. (Content is in New Product Introduction Page: Monitor #15751 if you want real data) Testing the following:contentfieldHTML & CSS
prefers-reduced-motion: reduce