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

populate body_footer field in ntb_NINJS [SDNTB-861] #471

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 5 additions & 4 deletions server/ntb/publish/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@

import re
import logging
import superdesk.etree as sd_etree

from lxml import etree
from typing import Dict, List, Optional, Tuple


Expand Down Expand Up @@ -93,6 +89,11 @@ def repl_embedded(match):
EMBED_RE.sub(repl_embedded, article.get("body_html") or "")
)

# SDNTB-861
if article.get("body_footer"):
html += strip_invalid_chars(
EMBED_RE.sub(repl_embedded, article["body_footer"] or "")
)
# it is a request from SDNTB-388 to use normal space instead of non breaking spaces
# so we do this replace
html = html.replace(" ", " ")
Expand Down
7 changes: 5 additions & 2 deletions server/ntb/tests/publish/ntb_ninjs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<p><a>test</a>NTBMEDIA TO REMOVE</p>

<p>(©MyCompany2023)</p>
<p>footer this is</p>
""".strip()

with open(
Expand Down Expand Up @@ -185,6 +186,7 @@ class Ninjs2FormatterTest(TestCase):
"version_creator": "ObjectId(" "5640a5eef40235008465242b" ")",
"abstract": "<p>abstract this is</p>",
"body_html": TEST_BODY,
"body_footer": "<p>footer this is</p>",
"dateline": {
"located": {
"dateline": "city",
Expand Down Expand Up @@ -321,8 +323,8 @@ def test_format_item(self):
],
"bodies": [
{
"charcount": 148,
"wordcount": 26,
"charcount": 162,
"wordcount": 29,
"value": TEST_BODY_EXPECTED,
"contenttype": "text/html",
}
Expand Down Expand Up @@ -444,6 +446,7 @@ def test_publish_table(self):
{
"fields_meta": text_item_with_table["fields_meta"],
"body_html": text_item_with_table["body_html"],
"body_footer": "",
}
)
assert "<table>" in ninjs["bodies"][0]["value"]
Expand Down
Loading