From e3658f944f6d77cfaa5065d7e9f1a570858952f3 Mon Sep 17 00:00:00 2001 From: Mayur Dhamanwala Date: Thu, 18 Aug 2016 19:09:45 +1000 Subject: [PATCH] Removing the duplicate Legal flag. --- .../publish/formatters/aap_bulletinbuilder_formatter.py | 4 +--- .../formatters/aap_bulletinbuilder_formatter_tests.py | 8 ++++++-- server/aap/publish/formatters/unicodetoascii.py | 2 +- server/aap/publish/formatters/unicodetoascii_test.py | 2 ++ 4 files changed, 10 insertions(+), 6 deletions(-) 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(''), '')