Skip to content

Commit

Permalink
populate body_footer field in ntb_NINJS [SDNTB-861]
Browse files Browse the repository at this point in the history
  • Loading branch information
devketanpro committed Jan 4, 2024
1 parent 7d78784 commit 2cb51d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 2cb51d0

Please sign in to comment.