2010-08-31 19:29:26 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-08-25 16:03:29 +02:00
|
|
|
|
|
|
|
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
|
|
|
|
|
2010-12-16 00:52:56 +01:00
|
|
|
from plone.app.discussion.interfaces import _
|
2010-01-24 14:47:39 +01:00
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_CAPTCHA = False
|
2009-08-11 11:45:34 +02:00
|
|
|
try:
|
2010-07-13 12:40:45 +02:00
|
|
|
import plone.formwidget.captcha
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_CAPTCHA = True # pragma: no cover
|
2009-08-11 11:45:34 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_RECAPTCHA = False
|
2009-08-11 11:45:34 +02:00
|
|
|
try:
|
2010-07-13 12:40:45 +02:00
|
|
|
import plone.formwidget.recaptcha
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_RECAPTCHA = True # pragma: no cover
|
2009-08-11 11:45:34 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_AKISMET = False
|
|
|
|
try:
|
2010-07-13 11:22:05 +02:00
|
|
|
import collective.akismet
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_AKISMET = True # pragma: no cover
|
2010-06-10 15:11:33 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-09-10 15:02:56 +02:00
|
|
|
HAS_NOROBOTS = False
|
|
|
|
try:
|
|
|
|
import collective.z3cform.norobots
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_NOROBOTS = True # pragma: no cover
|
2010-09-10 15:02:56 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
|
2009-08-11 11:45:34 +02:00
|
|
|
def captcha_vocabulary(context):
|
|
|
|
"""Vocabulary with all available captcha implementations.
|
|
|
|
"""
|
|
|
|
terms = []
|
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2009-08-11 11:45:34 +02:00
|
|
|
value='disabled',
|
|
|
|
token='disabled',
|
2010-01-24 14:47:39 +01:00
|
|
|
title=_(u'Disabled')))
|
2009-08-11 11:45:34 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_CAPTCHA: # pragma: no cover
|
2009-08-11 11:45:34 +02:00
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2009-08-11 11:45:34 +02:00
|
|
|
value='captcha',
|
|
|
|
token='captcha',
|
|
|
|
title='Captcha'))
|
2010-09-20 12:03:38 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_RECAPTCHA: # pragma: no cover
|
2009-08-11 11:45:34 +02:00
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2009-08-11 11:45:34 +02:00
|
|
|
value='recaptcha',
|
|
|
|
token='recaptcha',
|
2010-12-16 00:52:56 +01:00
|
|
|
title='ReCaptcha'))
|
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_AKISMET: # pragma: no cover
|
2010-06-10 15:11:33 +02:00
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2010-06-10 15:11:33 +02:00
|
|
|
value='akismet',
|
|
|
|
token='akismet',
|
2010-09-20 12:03:38 +02:00
|
|
|
title='Akismet'))
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_NOROBOTS: # pragma: no cover
|
2010-12-16 00:52:56 +01:00
|
|
|
terms.append(
|
2010-09-10 15:02:56 +02:00
|
|
|
SimpleTerm(
|
|
|
|
value='norobots',
|
|
|
|
token='norobots',
|
|
|
|
title='Norobots'))
|
2010-08-25 16:03:29 +02:00
|
|
|
return SimpleVocabulary(terms)
|
2009-08-11 11:45:34 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
|
2010-08-25 16:03:29 +02: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'))
|
2012-06-15 17:27:11 +02:00
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
|
|
|
value='text/html',
|
|
|
|
token='text/html',
|
|
|
|
title='HTML'))
|
2011-08-05 12:08:39 +02:00
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
|
|
|
value='text/x-web-markdown',
|
|
|
|
token='text/x-web-markdown',
|
|
|
|
title='Markdown'))
|
2010-08-25 16:03:29 +02:00
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
|
|
|
value='text/x-web-intelligent',
|
|
|
|
token='text/x-web-intelligent',
|
|
|
|
title='Intelligent text'))
|
|
|
|
return SimpleVocabulary(terms)
|