app/soc/logic/cleaning.py
changeset 1682 242ca517c340
parent 1681 b0e10552f5c2
child 1699 699f65fbf08a
equal deleted inserted replaced
1681:b0e10552f5c2 1682:242ca517c340
   286     raise forms.ValidationError('This URL is not a valid ATOM or RSS feed.')
   286     raise forms.ValidationError('This URL is not a valid ATOM or RSS feed.')
   287 
   287 
   288   return feed_url
   288   return feed_url
   289 
   289 
   290 
   290 
   291 def clean_document_content(self):
   291 def clean_html_content(field_name):
   292   """Clean method for cleaning document content.
   292   """Clean method for cleaning HTML content.
   293   """
   293   """
   294   content = self.cleaned_data.get('content')
   294 
   295 
   295   @check_field_is_empty(field_name)
   296   sanitizer = feedparser._HTMLSanitizer('utf-8')
   296   def wrapped(self):
   297   sanitizer.feed(content)
   297     """Decorator wrapper method.
   298   content = sanitizer.output()
   298     """
   299   content = content.strip().replace('\r\n', '\n')
   299 
   300 
   300     content = self.cleaned_data.get(field_name)
   301   return content
   301 
       
   302     if user_logic.isDeveloper():
       
   303       return content
       
   304 
       
   305     sanitizer = feedparser._HTMLSanitizer('utf-8')
       
   306     sanitizer.feed(content)
       
   307     content = sanitizer.output()
       
   308     content = content.strip().replace('\r\n', '\n')
       
   309 
       
   310     return content
       
   311 
       
   312   return wrapped
   302 
   313 
   303 def clean_url(field_name):
   314 def clean_url(field_name):
   304   """Clean method for cleaning a field belonging to a LinkProperty.
   315   """Clean method for cleaning a field belonging to a LinkProperty.
   305   """
   316   """
   306 
   317