Ticket #2678: profanities.patch

File profanities.patch, 1.6 KB (added by mcroydon, 9 years ago)

Patch to move profanities list to settings file

  • django/core/validators.py

     
    226226    check for whether each profanity exists within the string, so 'fuck' will
    227227    catch 'motherfucker' as well. Raises a ValidationError such as:
    228228        Watch your mouth! The words "f--k" and "s--t" are not allowed here.
     229    If ``PROFANITIES_LIST`` is defined in the settings file, that list of will
     230    be used, otherwise a default list of profanities will be used.
    229231    """
    230     bad_words = ['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit'] # all in lower case
     232    if hasattr(settings, "PROFANITIES_LIST"):
     233        bad_words = settings.PROFANITIES_LIST
     234    else:
     235        bad_words = ['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit'] # all in lower case
    231236    field_data = field_data.lower() # normalize
    232237    words_seen = [w for w in bad_words if field_data.find(w) > -1]
    233238    if words_seen:
  • docs/settings.txt

     
    596596only used if ``CommonMiddleware`` is installed (see the `middleware docs`_).
    597597See also ``APPEND_SLASH``.
    598598
     599PROFANITIES_LIST
     600----------------
     601
     602Default: ``['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit']``
     603
     604A list of profanities that will trigger a validation error when the ``hasNoProfanities``
     605validator is called.
     606
    599607ROOT_URLCONF
    600608------------
    601609
Back to Top