Skip to content

Commit

Permalink
Revert "Update NTB NITF publishing formats with new metadata from iMa…
Browse files Browse the repository at this point in the history
…trics. [SDNTB-647] (#385)"

This reverts commit ed451e3.
  • Loading branch information
petrjasek committed Nov 11, 2020
1 parent 5898b20 commit 690db72
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 48 deletions.
14 changes: 4 additions & 10 deletions server/data/vocabularies.json
Original file line number Diff line number Diff line change
Expand Up @@ -10614,15 +10614,13 @@
"display_name": "Subscriber Types",
"type": "unmanageable",
"selection_type": "do not show",
"init_version": 3,
"init_version": 2,
"items": [
{"is_active": true, "name": "All", "qcode": "all",
"formats": [
{"name": "Wufoo", "qcode": "wufoo"},
{"name": "NTB NITF Multi Service", "qcode": "ntbnitf"},
{"name": "NTB NITF Multi Service with media references", "qcode": "ntbnitfmedia"},
{"name": "NTB NITF 2.0 Multi Service", "qcode": "ntbnitf20"},
{"name": "NTB NITF 2.0 Multi Service with media references", "qcode": "ntbnitfmedia20"},
{"name": "NTB NITF Multi Service with media references", "qcode": "ntbnitfmedia"},
{"name": "NTB NITF Multi File", "qcode": "ntbnitfmultifile"},
{"name": "NTB NITF 1.0", "qcode": "ntbnitf10"},
{"name": "NINJS", "qcode": "ninjs"},
Expand All @@ -10639,9 +10637,7 @@
"formats": [
{"name": "Wufoo", "qcode": "wufoo"},
{"name": "NTB NITF Multi Service", "qcode": "ntbnitf"},
{"name": "NTB NITF Multi Service with media references", "qcode": "ntbnitfmedia"},
{"name": "NTB NITF 2.0 Multi Service", "qcode": "ntbnitf20"},
{"name": "NTB NITF 2.0 Multi Service with media references", "qcode": "ntbnitfmedia20"},
{"name": "NTB NITF Multi Service with media references", "qcode": "ntbnitfmedia"},
{"name": "NTB NITF Multi File", "qcode": "ntbnitfmultifile"},
{"name": "NTB NITF 1.0", "qcode": "ntbnitf10"},
{"name": "NINJS", "qcode": "ninjs"},
Expand All @@ -10659,9 +10655,7 @@
"formats": [
{"name": "Wufoo", "qcode": "wufoo"},
{"name": "NTB NITF Multi Service", "qcode": "ntbnitf"},
{"name": "NTB NITF Multi Service with media references", "qcode": "ntbnitfmedia"},
{"name": "NTB NITF 2.0 Multi Service", "qcode": "ntbnitf20"},
{"name": "NTB NITF 2.0 Multi Service with media references", "qcode": "ntbnitfmedia20"},
{"name": "NTB NITF Multi Service with media references", "qcode": "ntbnitfmedia"},
{"name": "NTB NITF Multi File", "qcode": "ntbnitfmultifile"},
{"name": "NTB NITF 1.0", "qcode": "ntbnitf10"},
{"name": "AAP ANPA", "qcode": "AAP ANPA"},
Expand Down
6 changes: 3 additions & 3 deletions server/ntb/publish/ntb_nitf.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ def _format_pubdata(self, article, head):
article['pubdata'] = pubdata # needed to access pubdata when formatting body content

def _format_subjects(self, article, tobject):
subjects = [s for s in article.get('subject', []) if s.get("scheme") == "topics"]
subjects = [s for s in article.get('subject', []) if s.get("scheme") == "subject_custom"]
for subject in subjects:
name_key = 'tobject.subject.matter' if subject.get('name') else 'tobject.subject.type'
name_key = 'tobject.subject.matter' if subject.get('parent', None) else 'tobject.subject.type'
etree.SubElement(
tobject,
'tobject.subject',
{'tobject.subject.refnum': subject.get('iptc_subject', ''),
{'tobject.subject.refnum': subject.get('qcode', ''),
name_key: subject.get('name', '')})

def _format_datetimes(self, article, head):
Expand Down
30 changes: 0 additions & 30 deletions server/ntb/publish/ntb_nitf_multiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@

from superdesk.publish.publish_service import PublishService
from .ntb_nitf import NTBNITFFormatter
from lxml import etree


def _format_subjects_with_qcode(article, tobject):
subjects = [s for s in article.get('subject', []) if s.get("scheme") == "topics"]
for subject in subjects:
name_key = 'tobject.subject.matter' if subject.get('name') else 'tobject.subject.type'
etree.SubElement(
tobject,
'tobject.subject',
{'tobject.subject.refnum': subject.get('qcode', ''),
name_key: subject.get('name', '')})


class NTBNITFMultiServiceFormatter(NTBNITFFormatter):
Expand All @@ -47,23 +35,5 @@ def _get_media_source(self, data):
return super()._get_media_source(data)


class NTBNITFMultiServiceFormatter20(NTBNITFMultiServiceFormatter):

FORMAT_TYPE = 'ntbnitf20' # default ntb nitf formatter

def _format_subjects(self, article, tobject):
_format_subjects_with_qcode(article, tobject)


class NTBNITFMultiServiceMediaFormatter20(NTBNITFMultiServiceMediaFormatter):

FORMAT_TYPE = 'ntbnitfmedia20'

def _format_subjects(self, article, tobject):
_format_subjects_with_qcode(article, tobject)


PublishService.register_file_extension(NTBNITFMultiServiceFormatter.FORMAT_TYPE, 'xml')
PublishService.register_file_extension(NTBNITFMultiServiceMediaFormatter.FORMAT_TYPE, 'xml')
PublishService.register_file_extension(NTBNITFMultiServiceFormatter20.FORMAT_TYPE, 'xml')
PublishService.register_file_extension(NTBNITFMultiServiceMediaFormatter20.FORMAT_TYPE, 'xml')
9 changes: 4 additions & 5 deletions server/ntb/tests/publish/ntb_nitf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@
"f": 1,
"i": 1},
"name": "Forskning"},
{"scheme": "topics",
"name": "tyveri og innbrudd",
"qcode": "20000104",
"parent": "20000082",
"iptc_subject": "02001003"}],
{"scheme": "subject_custom",
"qcode": "02001003",
"parent": "02000000",
"name": "tyveri og innbrudd"}],
"associations": {

"featuremedia": {
Expand Down

0 comments on commit 690db72

Please sign in to comment.