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

enable urls from rich text in planning xml [STTNHUB-252] #1870

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Changes from 2 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
27 changes: 20 additions & 7 deletions server/planning/feed_parsers/superdesk_planning_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
POST_STATE,
)

from planning.content_profiles.utils import get_planning_schema, is_field_editor_3
from superdesk.text_utils import plain_text_to_html

utc = pytz.UTC
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -86,8 +89,10 @@ def parse(self, tree: Element, provider=None):
"_id": guid,
}

self.parse_item_meta(tree, item)
self.parse_content_meta(tree, item)
planning_type = get_planning_schema("planning")

self.parse_item_meta(tree, item, planning_type)
self.parse_content_meta(tree, item, planning_type)
self.parse_news_coverage_set(tree, item)
self.parse_news_coverage_status(tree, item)

Expand All @@ -96,7 +101,7 @@ def parse(self, tree: Element, provider=None):
except Exception as ex:
raise ParserError.parseMessageError(ex, provider)

def parse_item_meta(self, tree, item):
def parse_item_meta(self, tree, item, planning_type):
"""Parse itemMeta tag

:param tree: tree
Expand All @@ -110,7 +115,9 @@ def parse_item_meta(self, tree, item):

editor_note = meta.find(self.qname("edNote"))
if editor_note is not None and editor_note.text:
item["ednote"] = editor_note.text
item["ednote"] = (
plain_text_to_html(editor_note.text) if is_field_editor_3("edNote", planning_type) else editor_note.text
)

item_class_elt = meta.find(self.qname("itemClass"))
if item_class_elt is not None:
Expand All @@ -122,7 +129,7 @@ def parse_item_meta(self, tree, item):
except (AttributeError, IndexError):
item["pubstatus"] = POST_STATE.USABLE

def parse_content_meta(self, tree, item):
def parse_content_meta(self, tree, item, planning_type):
"""Parse contentMeta tag

:param tree: tree
Expand All @@ -144,11 +151,17 @@ def parse_content_meta(self, tree, item):
slugline_elt = content_meta.find(self.qname("headline"))
if slugline_elt is not None and slugline_elt.text:
item["slugline"] = slugline_elt.text
item["name"] = slugline_elt.text
item["name"] = (
plain_text_to_html(slugline_elt.text) if is_field_editor_3("name", planning_type) else slugline_elt.text
)

description_elt = content_meta.find(self.qname("description"))
if description_elt is not None and description_elt.text:
item["description_text"] = description_elt.text
item["description_text"] = (
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
plain_text_to_html(description_elt.text)
if is_field_editor_3("description_text", planning_type)
else description_elt.text
)

# Assigning the planning date from subject
subject_elt = content_meta.find(self.qname("subject"))
Expand Down
Loading