Esempio n. 1
0
    def test_01_cleanse(self):
        from feincms.utils.cleanse import cleanse_html

        entries = [
            (u'<p>&nbsp;</p>', u''),
            (u'<span style="font-weight: bold;">Something</span><p></p>', u'<strong>Something</strong>'),
            (u'<p>abc <span>def <em>ghi</em> jkl</span> mno</p>', u'<p>abc def <em>ghi</em> jkl mno</p>'),
            (u'<span style="font-style: italic;">Something</span><p></p>', u'<em>Something</em>'),
            (u'<p>abc<br />def</p>', u'<p>abc<br />def</p>'),
            (u'<p><p><p>&nbsp;</p> </p><p><br /></p></p>', u' '),
            ]

        for a, b in entries:
            self.assertEqual(cleanse_html(a), b)
Esempio n. 2
0
 def save(self, *args, **kwargs):
     # TODO: Move this to the form?
     if getattr(self, 'cleanse', False):
         from feincms.utils.cleanse import cleanse_html
         self.text = cleanse_html(self.text)
     super(RichTextContent, self).save(*args, **kwargs)
Esempio n. 3
0
 def save(self, *args, **kwargs):
     if getattr(self, 'cleanse', False):
         from feincms.utils.cleanse import cleanse_html
         self.richtext = cleanse_html(self.richtext)
     super(SectionContent, self).save(*args, **kwargs)
Esempio n. 4
0
    def save(self, *args, **kwargs):
        if getattr(self, "cleanse", False):
            from feincms.utils.cleanse import cleanse_html

            self.text = cleanse_html(self.text)
        super(RichTextContent, self).save(*args, **kwargs)