diff --git a/server/aap/macros/generate_slugline_story_by_desk.py b/server/aap/macros/generate_slugline_story_by_desk.py index 8c9ac575c..b5b869f35 100644 --- a/server/aap/macros/generate_slugline_story_by_desk.py +++ b/server/aap/macros/generate_slugline_story_by_desk.py @@ -139,7 +139,8 @@ def process(self, articles): article['abstract'] = article.get('abstract') or '' article['slugline'] = article.get('slugline') or '' article['source'] = article.get('source') or '' - article['dateline_city'] = (article.get('dateline', {}).get('located', {}).get('city') or '').upper() + article['dateline_city'] = \ + (((article.get('dateline') or {}).get('located') or {}).get('city') or '').upper() def generate_published_slugline_story_by_desk(item, **kwargs): diff --git a/server/aap/macros/generate_slugline_story_by_desk_test.py b/server/aap/macros/generate_slugline_story_by_desk_test.py index 01afd24d6..4dfa4b602 100644 --- a/server/aap/macros/generate_slugline_story_by_desk_test.py +++ b/server/aap/macros/generate_slugline_story_by_desk_test.py @@ -48,7 +48,7 @@ def setUp(self): } }, { - '_id': '2', 'type': 'text', 'abstract': 'abstract item 2', 'slugline': 'slugline item 2', + '_id': '2', 'type': 'text', 'abstract': 'abstract "item 2"', 'slugline': 'slugline item 2', 'dateline': { 'text': 'Sydney, 01 Jan AAP -', 'located': { @@ -253,6 +253,6 @@ def test_generate_body_html(self): } generate_published_slugline_story_by_desk(item) - self.assertTrue('SYDNEY abstract item 2 (slugline item 2)' in item['body_html']) + self.assertTrue('SYDNEY abstract "item 2" (slugline item 2)' in item['body_html']) self.assertTrue('SYDNEY abstract item 2a (slugline item 2a)' in item['body_html']) self.assertTrue('SYDNEY abstract item 7 (slugline item 7)' in item['body_html']) diff --git a/server/aap/publish/formatters/aap_bulletinbuilder_formatter.py b/server/aap/publish/formatters/aap_bulletinbuilder_formatter.py index f4982e375..eeff8aa8a 100644 --- a/server/aap/publish/formatters/aap_bulletinbuilder_formatter.py +++ b/server/aap/publish/formatters/aap_bulletinbuilder_formatter.py @@ -39,8 +39,6 @@ def format(self, article, subscriber, codes=None): """ try: formatted_article = deepcopy(article) - formatted_article['slugline'] = self.get_text_content(to_ascii(self.append_legal(article=formatted_article, - truncate=True))).strip() pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber) body_html = to_ascii(self.append_body_footer(formatted_article)).strip('\r\n') @@ -71,7 +69,7 @@ def format(self, article, subscriber, codes=None): formatted_article['first_subject'] = set_subject(category, formatted_article) formatted_article['slugline'] = self.get_text_content( to_ascii(SluglineMapper().map(article=formatted_article, - category=category.get('qcode').upper(), truncate=True))).strip() + category=category.get('qcode').upper(), truncate=True)).strip()) odbc_item = { 'id': formatted_article.get(config.ID_FIELD), diff --git a/server/aap/publish/formatters/aap_bulletinbuilder_formatter_tests.py b/server/aap/publish/formatters/aap_bulletinbuilder_formatter_tests.py index eee5abb04..0c8407c42 100644 --- a/server/aap/publish/formatters/aap_bulletinbuilder_formatter_tests.py +++ b/server/aap/publish/formatters/aap_bulletinbuilder_formatter_tests.py @@ -79,9 +79,13 @@ def test_strip_html(self): config.VERSION: 2, 'source': 'AAP', 'headline': 'This is a test headline ', - 'slugline': 'This is a test slugline ', + 'slugline': 'slugline', 'abstract': '

abstract

', 'type': 'text', + 'anpa_category': [{'qcode': 'a', 'name': 'Australian General News'}], + 'flags': { + 'marked_for_legal': True + }, 'body_html': ('

The story body line 1
Line 2

' '

abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi' ' abcdefghi abcdefghi abcdefghi more

' @@ -101,7 +105,7 @@ def test_strip_html(self): self.assertEqual(test_article['body_text'], body_text) self.assertEqual(test_article['abstract'], 'abstract') self.assertEqual(test_article['headline'], 'This is a test headline') - self.assertEqual(test_article['slugline'], 'This is a test slugline') + self.assertEqual(test_article['slugline'], 'Legal: slugline') def test_strip_html_case1(self): article = { diff --git a/server/aap/publish/formatters/unicodetoascii.py b/server/aap/publish/formatters/unicodetoascii.py index 0fc37d6df..67eb3fa9f 100644 --- a/server/aap/publish/formatters/unicodetoascii.py +++ b/server/aap/publish/formatters/unicodetoascii.py @@ -17,7 +17,7 @@ def to_ascii(input_str): try: - return unidecode.unidecode(input_str) + return unidecode.unidecode(input_str) if input_str else '' except: logger.exception('Cannot convert input {} to ascii'.format(input_str)) return input_str diff --git a/server/aap/publish/formatters/unicodetoascii_test.py b/server/aap/publish/formatters/unicodetoascii_test.py index dbc08fc4b..d2a1111a8 100644 --- a/server/aap/publish/formatters/unicodetoascii_test.py +++ b/server/aap/publish/formatters/unicodetoascii_test.py @@ -33,3 +33,5 @@ def TestCase(self): self.assertEqual(to_ascii('ʺ'), '"') self.assertEqual(to_ascii('̀'), '') self.assertEqual(to_ascii('ˮ'), '"') + self.assertEqual(to_ascii(None), '') + self.assertEqual(to_ascii(''), '') diff --git a/server/templates/article_killed_override.json b/server/templates/article_killed_override.json index a0b78df08..cae2fe408 100644 --- a/server/templates/article_killed_override.json +++ b/server/templates/article_killed_override.json @@ -1,3 +1,3 @@ { - "body_html": "

Please kill story slugged {{ slugline }} headlined {{headline}} ex {{ city }} at {%if desk_name.strip().lower() == 'new zealand'%}{{versioncreated | format_datetime('Pacific/Auckland', '%d %b %Y %H:%S %Z')}}{% else %}{{versioncreated | format_datetime('Australia/Sydney', '%d %b %Y %H:%S %Z')}}{% endif %}.

{{body_html | escape}}" + "body_html": "

Please kill story slugged {{ slugline.replace('\"', '\\\"') }} headlined {{headline.replace('\"', '\\\"')}} ex {{ city }} at {%if desk_name.strip().lower() == 'new zealand'%}{{versioncreated | format_datetime('Pacific/Auckland', '%d %b %Y %H:%S %Z')}}{% else %}{{versioncreated | format_datetime('Australia/Sydney', '%d %b %Y %H:%S %Z')}}{% endif %}.

{{body_html.replace('\"', '\\\"') | escape}}" } \ No newline at end of file diff --git a/server/templates/skeds_body_html.json b/server/templates/skeds_body_html.json index cdb44735f..8cfb77d05 100644 --- a/server/templates/skeds_body_html.json +++ b/server/templates/skeds_body_html.json @@ -2,7 +2,7 @@ "slugline": "{{desk_name}} skeds {{now | format_datetime('Australia/Sydney', '%b %-d')}}", "abstract": "{{desk_name}} skedlines, {{now | format_datetime('Australia/Sydney', '%B %-d')}}", "headline": "{{desk_name}} skedlines, {{now | format_datetime('Australia/Sydney', '%B %-d')}}", - "body_html": "

{{desk_name}} skeds for {{now | format_datetime('Australia/Sydney', '%A, %B %-d')}}:


{% for item in items %}

{{item.dateline_city}} {{item.abstract|striptags}} ({{item.slugline}}) {{item.anpa_take_key}} {{item.versioncreated | format_datetime('Australia/Sydney', '%H:%S')}}


{% endfor %}", + "body_html": "

{{desk_name}} skeds for {{now | format_datetime('Australia/Sydney', '%A, %B %-d')}}:


{% for item in items %}

{{item.dateline_city}} {{item.abstract.replace('\"', '\\\"') | striptags}} ({{item.slugline.replace('\"', '\\\"')}}) {{item.anpa_take_key.replace('\"', '\\\"')}} {{item.versioncreated | format_datetime('Australia/Sydney', '%H:%S')}}


{% endfor %}", "anpa_category": [{"qcode" : "v", "name" : "Advisories", "is_active" : true}], "subject": [{"qcode" : "99001000", "scheme" : null, "name" : "advisory", "parent" : "99000000"}] }