def get_replacement_as_list(self, replacement): if self.markdown_lists: return '\n\n' + '\n'.join('* {}'.format(item) for item in replacement) return unescaped_formatted_list(replacement, before_each='', after_each='')
def get_letter_validation_error(validation_message, invalid_pages=None, page_count=None): if not invalid_pages: invalid_pages = [] if validation_message not in LETTER_VALIDATION_MESSAGES: return {'title': 'Validation failed'} invalid_pages_are_or_is = 'is' if len(invalid_pages) == 1 else 'are' invalid_pages = unescaped_formatted_list(invalid_pages, before_each='', after_each='', prefix='page', prefix_plural='pages') return { 'title': LETTER_VALIDATION_MESSAGES[validation_message]['title'], 'detail': LETTER_VALIDATION_MESSAGES[validation_message]['detail'].format( invalid_pages=invalid_pages, invalid_pages_are_or_is=invalid_pages_are_or_is, page_count=page_count, letter_spec_guidance=url_for('.letter_specification')), 'summary': LETTER_VALIDATION_MESSAGES[validation_message]['summary'].format( invalid_pages=invalid_pages, invalid_pages_are_or_is=invalid_pages_are_or_is, page_count=page_count, letter_spec_guidance=url_for('.letter_specification'), ), }
def get_letter_validation_error(validation_message, invalid_pages=None, page_count=None): if validation_message not in LETTER_VALIDATION_MESSAGES: return {'title': 'Validation failed'} invalid_pages = unescaped_formatted_list(invalid_pages or [], before_each='', after_each='', prefix='page', prefix_plural='pages') return { 'title': LETTER_VALIDATION_MESSAGES[validation_message]['title'], 'detail': LETTER_VALIDATION_MESSAGES[validation_message]['detail'].format( invalid_pages=invalid_pages, page_count=page_count, ) }