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 all commits
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
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
Loading