Skip to content

Commit

Permalink
Removing the duplicate Legal flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayur Dhamanwala committed Aug 18, 2016
1 parent c3acc8e commit e3658f9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ def test_strip_html(self):
config.VERSION: 2,
'source': 'AAP',
'headline': 'This is a test headline&nbsp;<span></span>',
'slugline': 'This is a test slugline ',
'slugline': 'slugline',
'abstract': '<p>abstract</p>',
'type': 'text',
'anpa_category': [{'qcode': 'a', 'name': 'Australian General News'}],
'flags': {
'marked_for_legal': True
},
'body_html': ('<p>The story&nbsp;<span></span>body line 1<br>Line 2</p>'
'<p>abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi'
'<span> abcdefghi</span> abcdefghi abcdefghi more</p>'
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion server/aap/publish/formatters/unicodetoascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions server/aap/publish/formatters/unicodetoascii_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(''), '')

0 comments on commit e3658f9

Please sign in to comment.