Example #1
0
def plainattr(obj, attr_name):
    v = getattr(obj, attr_name)
    try:
        field = obj._meta.get_field(attr_name)
        if getattr(field, "richtext", False):
            v = plaintext(v, obj)
    except FieldDoesNotExist:
        pass
    return v
Example #2
0
def plainattr(obj, attr_name):
    v = getattr(obj, attr_name)
    try:
        field = obj._meta.get_field(attr_name)
        if getattr(field, "richtext", False):
            v = plaintext(v, obj)
    except FieldDoesNotExist:
        pass
    return v
Example #3
0
 def prepare(self, object):
     self.prepared_data = QueuedSearchIndex.prepare(self, object)
     meta_fields = object._meta.get_all_field_names()
     for f in self.Meta.fields:
         if f in meta_fields and f in self.prepared_data:
             if getattr(object._meta.get_field(f), "richtext", False):
                 self.prepared_data[f] = plaintext(
                     self.prepared_data[f], object)
     return self.prepared_data
Example #4
0
def plaintext_filter(content, obj=None):
    """
    This template filter takes a string value and passes it through the
    function specified by the RICHTEXT_PLAIN_FILTER setting.
    """
    return plaintext(content, obj)
Example #5
0
def plaintext_filter(content, obj=None):
    """
    This template filter takes a string value and passes it through the
    function specified by the RICHTEXT_PLAIN_FILTER setting.
    """
    return plaintext(content, obj)
Example #6
0
 def prepare_description(self, obj):
     return plaintext(obj.description, obj)
Example #7
0
 def test_plaintext_test(self):
     html = plaintext("TEST", self.ctrl)
     self.assertEqual(html, "test")
Example #8
0
 def test_plaintext_disabled(self):
     html = plaintext(SIMPLE_TEXT, self.ctrl)
     self.assertEqual(html, SIMPLE_TEXT)
     self.assertFalse(isinstance(html, SafeData))
Example #9
0
 def test_plaintext_default_settings(self):
     html = plaintext(SIMPLE_TEXT, self.ctrl)
     self.assertEqual(html, u"a simple text")
     self.assertFalse(isinstance(html, SafeData))