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

79 lines
2.1 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
2022-05-01 23:14:09 +02:00
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
2022-05-01 23:14:09 +02:00
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
2022-05-01 23:14:09 +02:00
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
2022-05-01 23:14:09 +02:00
2012-01-14 07:47:07 +01:00
HAS_NOROBOTS = True # pragma: no cover
except ImportError:
pass
def captcha_vocabulary(context):
2022-05-01 23:14:09 +02:00
"""Vocabulary with all available captcha implementations."""
terms = []
2022-05-01 23:14:09 +02:00
terms.append(SimpleTerm(value="disabled", token="disabled", title=_(u"Disabled")))
2012-01-14 07:47:07 +01:00
if HAS_CAPTCHA: # pragma: no cover
2022-05-01 23:14:09 +02:00
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(
2022-05-01 23:14:09 +02:00
SimpleTerm(value="recaptcha", token="recaptcha", title="ReCaptcha")
)
2012-01-14 07:47:07 +01:00
if HAS_AKISMET: # pragma: no cover
2022-05-01 23:14:09 +02:00
terms.append(SimpleTerm(value="akismet", token="akismet", title="Akismet"))
2012-01-14 07:47:07 +01:00
if HAS_NOROBOTS: # pragma: no cover
2022-05-01 23:14:09 +02:00
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):
2022-05-01 23:14:09 +02:00
"""Vocabulary with all available portal_transform transformations."""
terms = []
2022-05-01 23:14:09 +02:00
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(
2022-05-01 23:14:09 +02:00
value="text/x-web-markdown", token="text/x-web-markdown", title="Markdown"
)
)
terms.append(
SimpleTerm(
2022-05-01 23:14:09 +02:00
value="text/x-web-intelligent",
token="text/x-web-intelligent",
title="Intelligent text",
)
)
return SimpleVocabulary(terms)