Skip to content

Commit

Permalink
populate body_footer field in ntb_NINJS [SDNTB-861] (#471)
Browse files Browse the repository at this point in the history
* populate body_footer field in ntb_NINJS [SDNTB-861]

* update logic
  • Loading branch information
devketanpro authored Jan 4, 2024
1 parent 7d78784 commit 77ffc9f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions server/ntb/publish/ntb_ninjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def _transform_to_ninjs(self, article, subscriber, recursive=True):
ninjs["descriptions"] = self.format_descriptions(ninjs)

if article.get("body_html"):
body_footer = article.get('body_footer', '').strip()
if body_footer:
article['body_html'] += body_footer
ninjs["bodies"] = self.format_bodies(article)

if ninjs.get("subject"):
Expand Down
4 changes: 0 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
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 77ffc9f

Please sign in to comment.