Beispiel #1
0
def test_removing_dvla_markup():
    assert strip_dvla_markup(
        (
            'some words & some more <words>'
            '<cr><h1><h2><p><normal><op><np><bul><tab>'
            '<CR><H1><H2><P><NORMAL><OP><NP><BUL><TAB>'
            '<tAb>'
        )
    ) == 'some words & some more <words>'
 def __str__(self):
     return Markup(
         self.jinja_template.render({
             'admin_base_url':
             self.admin_base_url,
             'logo_file_name':
             self.logo_file_name,
             'subject':
             self.subject,
             'message':
             Take(
                 Field(
                     strip_dvla_markup(self.content),
                     self.values,
                     html='escape',
                     markdown_lists=True,
                     redact_missing_personalisation=self.
                     redact_missing_personalisation,
                 )).then(strip_pipes).then(
                     make_markdown_take_notice_of_multiple_newlines).then(
                         notify_letter_preview_markdown).
             then(strip_characters_inserted_to_force_newlines).then(
                 do_nice_typography).then(remove_trailing_linebreak).then(
                     replace_hyphens_with_non_breaking_hyphens).then(
                         tweak_dvla_list_markup),
             'address':
             Take(
                 Field(self.address_block,
                       (self.values_with_default_optional_address_lines
                        if all(
                            Columns(self.values).get(key) for key in {
                                'address line 1',
                                'address line 2',
                                'postcode',
                            }) else self.values),
                       html='escape',
                       with_brackets=False)
             ).then(strip_pipes).then(remove_empty_lines).then(
                 remove_whitespace_before_punctuation).then(nl2li),
             'contact_block':
             Take(
                 Field(
                     '\n'.join(line.strip()
                               for line in self.contact_block.split('\n')),
                     self.values,
                     redact_missing_personalisation=self.
                     redact_missing_personalisation,
                     html='escape',
                 )).then(remove_whitespace_before_punctuation).then(
                     nl2br).then(strip_pipes),
             'date':
             datetime.utcnow().strftime('%-d %B %Y')
         }))
 def _message(self):
     return Take(
         Field(
             strip_dvla_markup(self.content),
             self.values,
             html='escape',
             markdown_lists=True,
             redact_missing_personalisation=self.
             redact_missing_personalisation,
         )).then(strip_pipes).then(add_trailing_newline).then(
             notify_letter_preview_markdown).then(do_nice_typography).then(
                 replace_hyphens_with_non_breaking_hyphens).then(
                     tweak_dvla_list_markup)
Beispiel #4
0
 def __str__(self):
     return Markup(
         self.jinja_template.render({
             'admin_base_url':
             self.admin_base_url,
             'logo_file_name':
             self.logo_file_name,
             'subject':
             self.subject,
             'message':
             Take.as_field(
                 strip_dvla_markup(self.content),
                 self.values,
                 html='escape',
                 markdown_lists=True).then(strip_pipes).then(
                     prepare_newlines_for_markdown).then(
                         notify_letter_preview_markdown).as_string,
             'address':
             Take.as_field(
                 self.address_block,
                 (self.values_with_default_optional_address_lines if all(
                     Columns(self.values).get(key) for key in {
                         'address line 1',
                         'address line 2',
                         'postcode',
                     }) else self.values),
                 html='escape',
                 with_brackets=False).then(strip_pipes).then(
                     remove_empty_lines).then(nl2br).as_string,
             'contact_block':
             Take.as_field(
                 '\n'.join(line.strip()
                           for line in self.contact_block.split('\n')),
                 self.values,
                 html='escape',
             ).then(nl2br).then(strip_pipes).as_string,
             'date':
             datetime.utcnow().strftime('%-d %B %Y')
         }))