def test_split_words(self): text = """college scholarship essays - <a href=" https://collegeessays.us/ ">how to write a good introduction for a college essay</a> boston university college essay <a href=" https://collegeessays.us/ ">how to write an essay for college</a> https://collegeessays.us/ http://www.monkeyface.com/__media__/js/netsoltrademark.php?d=collegeessays.us""" self.assertEqual(split_words(text), { '__media__', 'a', 'an', 'boston', 'college', 'collegeessays', 'com', 'd', 'essay', 'essays', 'for', 'good', 'how', 'href', 'http', 'https', 'introduction', 'js', 'monkeyface', 'netsoltrademark', 'php', 'scholarship', 'to', 'university', 'us', 'write', 'www' })
def moderate(self, comment, content_object, request): """ Determine whether a given comment on a given object should be allowed to show up immediately, or should be marked non-public and await approval. Returns ``True`` if the comment should be moderated (marked non-public), ``False`` otherwise. """ # Soft delete checks are done first, so these comments are not mistakenly "just moderated" # for expiring the `close_after` date, but correctly get marked as spam instead. # This helps staff to quickly see which comments need real moderation. if self.akismet_check: akismet_result = akismet_check(comment, content_object, request) if akismet_result: # Typically action=delete never gets here, unless the service was having problems. if ( akismet_result in ( SpamStatus.ProbableSpam, SpamStatus.DefiniteSpam, ) and self.akismet_check_action in ("auto", "soft_delete", "delete") ): comment.is_removed = True # Set extra marker # SpamStatus.Unknown or action=moderate will end up in the moderation queue return True # Parent class check if super().moderate(comment, content_object, request): return True # Bad words check if self.moderate_bad_words: input_words = split_words(comment.comment) if self.moderate_bad_words.intersection(input_words): return True # Akismet check if self.akismet_check and self.akismet_check_action not in ("soft_delete", "delete"): # Return True if akismet marks this comment as spam and we want to moderate it. if akismet_check(comment, content_object, request): return True return False
def moderate(self, comment, content_object, request): """ Determine whether a given comment on a given object should be allowed to show up immediately, or should be marked non-public and await approval. Returns ``True`` if the comment should be moderated (marked non-public), ``False`` otherwise. """ # Soft delete checks are done first, so these comments are not mistakenly "just moderated" # for expiring the `close_after` date, but correctly get marked as spam instead. # This helps staff to quickly see which comments need real moderation. if self.akismet_check: akismet_result = akismet_check(comment, content_object, request) if akismet_result: # Typically action=delete never gets here, unless the service was having problems. if akismet_result in (SpamStatus.ProbableSpam, SpamStatus.DefiniteSpam) and \ self.akismet_check_action in ('auto', 'soft_delete', 'delete'): comment.is_removed = True # Set extra marker # SpamStatus.Unknown or action=moderate will end up in the moderation queue return True # Parent class check if super(FluentCommentsModerator, self).moderate(comment, content_object, request): return True # Bad words check if self.moderate_bad_words: input_words = split_words(comment.comment) if self.moderate_bad_words.intersection(input_words): return True # Akismet check if self.akismet_check and self.akismet_check_action not in ('soft_delete', 'delete'): # Return True if akismet marks this comment as spam and we want to moderate it. if akismet_check(comment, content_object, request): return True return False
def test_split_words(self): text = """college scholarship essays - <a href=" https://collegeessays.us/ ">how to write a good introduction for a college essay</a> boston university college essay <a href=" https://collegeessays.us/ ">how to write an essay for college</a> https://collegeessays.us/ http://www.monkeyface.com/__media__/js/netsoltrademark.php?d=collegeessays.us""" self.assertEqual( split_words(text), { "__media__", "a", "an", "boston", "college", "collegeessays", "com", "d", "essay", "essays", "for", "good", "how", "href", "http", "https", "introduction", "js", "monkeyface", "netsoltrademark", "php", "scholarship", "to", "university", "us", "write", "www", }, )