plone.app.discussion/plone/app/discussion/vocabularies.py

101 lines
2.5 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from plone.app.discussion.interfaces import _
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary
HAS_CAPTCHA = False
try:
2013-04-18 15:51:57 +02:00
import plone.formwidget.captcha # noqa
2012-01-14 07:47:07 +01:00
HAS_CAPTCHA = True # pragma: no cover
except ImportError:
pass
HAS_RECAPTCHA = False
try:
2013-04-18 15:51:57 +02:00
import plone.formwidget.recaptcha # noqa
2012-01-14 07:47:07 +01:00
HAS_RECAPTCHA = True # pragma: no cover
except ImportError:
pass
HAS_AKISMET = False
try:
2013-04-18 15:51:57 +02:00
import collective.akismet # noqa
2012-01-14 07:47:07 +01:00
HAS_AKISMET = True # pragma: no cover
except ImportError:
pass
HAS_NOROBOTS = False
try:
2013-04-18 15:51:57 +02:00
import collective.z3cform.norobots # noqa
2012-01-14 07:47:07 +01:00
HAS_NOROBOTS = True # pragma: no cover
except ImportError:
pass
def captcha_vocabulary(context):
"""Vocabulary with all available captcha implementations.
"""
terms = []
terms.append(
SimpleTerm(
value='disabled',
token='disabled',
title=_(u'Disabled')))
2012-01-14 07:47:07 +01:00
if HAS_CAPTCHA: # pragma: no cover
terms.append(
SimpleTerm(
value='captcha',
token='captcha',
title='Captcha'))
2012-01-14 07:47:07 +01:00
if HAS_RECAPTCHA: # pragma: no cover
terms.append(
SimpleTerm(
value='recaptcha',
token='recaptcha',
title='ReCaptcha'))
2012-01-14 07:47:07 +01:00
if HAS_AKISMET: # pragma: no cover
terms.append(
SimpleTerm(
value='akismet',
token='akismet',
title='Akismet'))
2012-01-14 07:47:07 +01:00
if HAS_NOROBOTS: # pragma: no cover
terms.append(
SimpleTerm(
value='norobots',
token='norobots',
title='Norobots'))
return SimpleVocabulary(terms)
2012-01-14 07:47:07 +01:00
def text_transform_vocabulary(context):
"""Vocabulary with all available portal_transform transformations.
"""
terms = []
terms.append(
SimpleTerm(
value='text/plain',
token='text/plain',
title='Plain text'))
terms.append(
SimpleTerm(
value='text/html',
token='text/html',
title='HTML'))
terms.append(
SimpleTerm(
value='text/x-web-markdown',
token='text/x-web-markdown',
title='Markdown'))
terms.append(
SimpleTerm(
value='text/x-web-intelligent',
token='text/x-web-intelligent',
title='Intelligent text'))
return SimpleVocabulary(terms)