Пример #1
0
 def __iter__(self):
     terms = [
         SimpleTerm(value=v, token="token%s" % v, title="Title %s" % v)
         for v in self.values
     ]
     return iter(terms)
Пример #2
0
 def __call__(self, context):
     DummyRenderer = Renderer(context, None, None, None, None)
     renderers = [a for a in getAdapters((DummyRenderer,), IPortletContainerRenderer)]
     terms = [SimpleTerm(k, title=v.title) for k, v in renderers]
     return SimpleVocabulary(terms)
Пример #3
0
"""Module where all interfaces, events and exceptions live."""

from collective.clamav import _
from zope import schema
from zope.interface import Interface
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


class ICollectiveClamavLayer(IDefaultBrowserLayer):
    """Marker interface that defines a browser layer."""


clamdConnectionType = SimpleVocabulary([
    SimpleTerm(title=u'Unix Socket', value='socket'),
    SimpleTerm(title=u'Network', value='net')
], )


class IAVScannerSettings(Interface):
    """ Schema for the clamav settings
    """
    clamav_connection = schema.Choice(
        title=_(u'Connection type to clamd'),
        description=_(u'Choose whether clamd is accessible through local '
                      u'UNIX sockets or network.'),
        vocabulary=clamdConnectionType)

    clamav_socket = schema.ASCIILine(
        title=_(u'Clamd local socket file'),
Пример #4
0
 def __init__(self, context=None):  # pylint: disable=unused-argument
     catalog = get_utility(ICatalog)
     index = catalog['zfile_application']
     terms = [SimpleTerm(v, title=v) for v in index.unique_values()]
     super().__init__(terms)
Пример #5
0
 def createTerm(cls, brain, context):
     return SimpleTerm(brain, brain.UID, brain.UID)
Пример #6
0
 def __call__(self, context):
     items = [SimpleTerm(key, item) for key, item in ACTIVITIES]
     return SimpleVocabulary(items)
Пример #7
0
 def dummy_source_vocab(self, context):
     return SimpleVocabulary([
         SimpleTerm(value=u'foo', title=u'Foo'),
         SimpleTerm(value=u'bar', title=u'Bar')
     ])
Пример #8
0
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


# XXX
# acquire locallyAllowedTypes from parent (default)
ACQUIRE = -1

# use default behavior of PortalFolder which uses the FTI information
DISABLED = 0

# allow types from locallyAllowedTypes only
ENABLED = 1


ST = lambda key, txt, default: SimpleTerm(value=key,
                                          title=PC_(txt, default=default))

possible_constrain_types = SimpleVocabulary([
    ST(ACQUIRE,
       u'constraintypes_mode_acquire',
       u'Use parent folder settings'),
    ST(DISABLED,
       'label_constraintypes_allow_standard',
       u'Use portal default'),
    ST(ENABLED,
       u'label_constraintypes_specify_manually',
       u'Select manually')
])


@implementer(IVocabularyFactory)
Пример #9
0
 def __call__(self, context):
     constrain_aspect = context.context
     items = []
     for type_ in constrain_aspect.getDefaultAddableTypes():
         items.append(SimpleTerm(value=type_.getId(), title=type_.Title()))
     return SimpleVocabulary(items)
Пример #10
0
 def search(self, query):
     terms = [SimpleTerm(query, query)]
     return iter(terms)
Пример #11
0
 def __init__(self, context):  # pylint: disable=unused-argument
     terms = []
     for name in sorted(get_all_styles()):
         terms.append(SimpleTerm(name))
     super().__init__(terms)
Пример #12
0
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from plone.indexer import indexer
from Products.statusmessages.interfaces import IStatusMessage

from plone.indexer import indexer


def isValidURL(value):
    if value.find("http://") == 0 or value.find("https://") == 0:
        return True
    else:
        raise Invalid(_(u"Por favor ingrese un una url que incluya HTTP"))


tiposVocab = SimpleVocabulary([
    SimpleTerm(value=u'imagen', title='Imagen'),
    SimpleTerm(value=u'audio', title='Audio'),
    SimpleTerm(value=u'video', title='Video'),
    SimpleTerm(value=u'texto', title='Texto'),
    SimpleTerm(value=u'web', title='Página web')
])
tipoEnlaceVocab = SimpleVocabulary([
    SimpleTerm(value=0, title='A Greenstone'),
    SimpleTerm(value=1, title='Independiente'),
])


class IEnlacegs(form.Schema):
    """A conference program. Programs can contain Sessions.
    """
    cuerpo = RichText(
Пример #13
0
# -*- coding: utf-8 -*-

from collective.sidebar import _
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

positionTerms = [
    SimpleTerm(value=u'left', title=_(u'choice_left', default=u'Left')),
    SimpleTerm(value=u'right', title=_(u'choice_right', default=u'Right')),
]

PositionVocabulary = SimpleVocabulary(positionTerms)

fonts = [
    SimpleTerm(value=u'Bootstrap', title=u'Bootstrap'),
    SimpleTerm(value=u'Glyphicons', title=u'Glyphicons'),
    SimpleTerm(value=u'Fontello', title=u'Fontello'),
    SimpleTerm(value=u'Font Awesome', title=u'Font Awesome'),
    SimpleTerm(value=u'Font Awesome Pro', title=u'Font Awesome Pro'),
    SimpleTerm(value=u'Font Awesome Light', title=u'Font Awesome Light'),
    SimpleTerm(value=u'Font Awesome Duotone', title=u'Font Awesome Duotone'),
]

IconFontVocabulary = SimpleVocabulary(fonts)
Пример #14
0
 def search(self, query):
     terms = [
         SimpleTerm(value=v, token="token%s" % v, title="Title %s" % v)
         for v in self.values
     ]
     return [t for t in terms if query in str(t.token)]
Пример #15
0
 def dummy_source_vocab(self, context):
     return SimpleVocabulary([
         SimpleTerm(value=u"foo", title=u"Foo"),
         SimpleTerm(value=u"bar", title=u"Bar"),
     ])
Пример #16
0
 def make_term(groupInfo):
     retval = SimpleTerm(groupInfo.id, groupInfo.id, groupInfo.name)
     return retval
Пример #17
0
def make_terms(items):
    """ Create zope.schema terms for vocab from tuples """
    terms = [ SimpleTerm(value=pair[0], token=pair[0], title=pair[1]) for pair in items ]
    return terms
Пример #18
0
from plone.formwidget.autocomplete import AutocompleteMultiFieldWidget
from plone.formwidget.autocomplete import AutocompleteFieldWidget

from z3c.relationfield.schema import RelationList, RelationChoice
from plone.formwidget.contenttree import ObjPathSourceBinder
from collective.z3cform.datagridfield import DictRow, DataGridFieldFactory
from edi.restreader.restaccess import possibleGefahrstoffe

from nva.praeventionswissen.vocabularies import durchbruchzeit, material, ausfuehrung, profilierung
from nva.praeventionswissen.vocabularies import pruefung374alt, pruefung374neu, chemikalienpruefung, pruefung375_5_2016
from nva.praeventionswissen.vocabularies import pruefung_weitere_chemie, rankvalue, biologische_gefaehrdung
from nva.praeventionswissen.vocabularies import pruefung_normen_mechanik, gefaehrdungen
from nva.praeventionswissen.vocabularies import collectGefahrstoffe

ranks = [
    SimpleTerm(u'nicht_relevant', u'nicht_relevant', u'nicht relevant'),
    SimpleTerm(u'gering', u'gering', u'gering'),
    SimpleTerm(u'mittel', u'mittel', u'mittel'),
    SimpleTerm(u'hoch', u'hoch', u'hoch'),
]
rankvalue = SimpleVocabulary(ranks)


class IGefahrstoffe(form.Schema):

    gefahrstoff = schema.Choice(title=u"Gefahrstoff / Chemikalie",
                                source=collectGefahrstoffe)
    zeit = schema.Choice(title=u"Kontaktzeit", vocabulary=durchbruchzeit)


class ITaetigkeit(form.Schema, IImageScaleTraversable):
Пример #19
0
 def __call__(self, context):
     items = [SimpleTerm(key, item) for key, item in TYPES.items()]
     return SimpleVocabulary(items)
Пример #20
0
    def __call__(self, context):

        return SimpleVocabulary([SimpleTerm(x, title=x) for x in self.items])
Пример #21
0
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
############################################################################
from __future__ import absolute_import, unicode_literals
from zope.interface import Interface
from zope.schema import TextLine, Choice
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.viewlet.interfaces import IViewletManager
from . import GSMessageFactory as _

replyToVocab = SimpleVocabulary([
    SimpleTerm('group', 'group',
               _('reply-to-group', 'Group: replies go to the group.')),
    SimpleTerm(
        'sender', 'sender',
        _('reply-to-sender',
          'Author: replies just go to the author of the post.')),
    SimpleTerm(
        'both', 'both',
        _('reply-to-both',
          'Both: replies go to the group, with an extra email to the author.')
    ),
])


class IGroupProperties(Interface):
    title = TextLine(title=_('form-label-group-name', 'Group Name'),
                     description=_('form-label-group-name-help',
Пример #22
0
# -*- coding: utf-8 -*-
from plone.app.textfield import RichText
from plone.dexterity.content import Item
from plone.supermodel import model
from zope import schema
from zope.interface import implementer
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary
from edi.substanceforms.vocabularies import vocabularies
from jinja2 import Template
from edi.substanceforms.lib import DBConnect
from edi.substanceforms.helpers import get_vocabulary

terms = [SimpleTerm(value=i, token=i, title=i) for i in vocabularies]

vocabvocab = SimpleVocabulary(terms)

# from edi.substanceforms import _


class IPreselect(model.Schema):
    """ Marker interface and Dexterity Python Schema for Preselect
    """

    preselects = schema.List(
        title=
        u'Liste mit Preselects, die ausgeführt werden sollen, um eine Ergebnisliste zu erzeugen',
        description=
        u"Bitte bearchten Sie, dass die Variable der WHERE-Klausel mit {{ value }} übergeben wird.",
        value_type=schema.TextLine(),
        required=True)
Пример #23
0
 def __call__(self, context):
     terms = []
     for i in self._terms:
         terms.append(SimpleTerm(**i))
     return SimpleVocabulary(terms)
Пример #24
0
 def toTerm(self, obj):
     """See `IVocabulary`."""
     return SimpleTerm(obj, obj.id, obj.displayname)
Пример #25
0
class ICollectionPortlet(IPortletDataProvider):
    """A portlet which renders the results of a collection object.
    """

    header = schema.TextLine(title=_(u"Portlet header"),
                             description=_(u"Title of the rendered portlet"),
                             required=True)

    target_collection = schema.Choice(
        title=_(u"Target collection"),
        description=_(u"Find the collection which provides the items to list"),
        required=True,
        source=SearchableTextSourceBinder(
            {'object_provides': IATTopic.__identifier__},
            default_query='path:'))

    limit = schema.Int(
        title=_(u"Limit"),
        description=_(
            u"Specify the maximum number of items to show in the portlet. "
            "Leave this blank to show all items."),
        required=False)

    show_more = schema.Choice(
        title=_(u"Show more... link"),
        description=
        _(u"If enabled, a more... link will appear in the footer of the portlet. "
          "You can determine if it should link to the underlying Collection or show "
          "the Collection's contents in the current context."),
        required=False,
        vocabulary=SimpleVocabulary(
            terms=(SimpleTerm(value='', title='No'),
                   SimpleTerm(value='direct', title='Link to collection'),
                   SimpleTerm(value='context',
                              title='Show contents in context')), ),
        default='')

    show_dates = schema.Bool(
        title=_(u"Show dates"),
        description=
        _(u"If enabled, effective dates will be shown underneath the items listed."
          ),
        required=True,
        default=False)

    show_rss = schema.Bool(
        title=_(u'Show RSS link'),
        description=
        _(u'If enabled, a link to the RSS representaion of the collection will we added at the bottom of the portlet.'
          ),
        required=True,
        default=False,
    )

    rss_explanation_path = schema.TextLine(
        title=_(u'RSS explanation path'),
        description=
        _(u'Enter a relative path to a page that gives general RSS information. This is optional.'
          ),
        required=False,
    )
Пример #26
0
class ITalk(form.Schema):
    """A conference talk. Talks are managed inside tracks of the Program.
    """

    length = SimpleVocabulary([
        SimpleTerm(value=u'30', title=_(u'30 minutes')),
        SimpleTerm(value=u'45', title=_(u'45 minutes')),
        SimpleTerm(value=u'60', title=_(u'60 minutes'))
    ])

    #    talktrack = SimpleVocabulary(
    #       [SimpleTerm(value=u'UX', title=_(u'Usability')),
    #        SimpleTerm(value=u'Core-Development', title=_(u'Development in the Core')),
    #        SimpleTerm(value=u'Extension-Development', title=_(u'Development of Extensions')),]
    #        )

    title = schema.TextLine(
        title=_(u"Title"),
        description=_(u"Talk title"),
    )

    description = schema.Text(title=_(u"Talk summary"), )

    form.primary('details')
    details = RichText(title=_(u"Talk details"), required=True)

    # use an autocomplete selection widget instead of the default content tree
    form.widget(speaker=AutocompleteFieldWidget)
    speaker = RelationChoice(
        title=_(u"Presenter"),
        source=ObjPathSourceBinder(object_provides=ISpeaker.__identifier__),
        required=False,
    )
    form.widget(speaker=AutocompleteFieldWidget)
    speaker2 = RelationChoice(
        title=_(u"Co-Presenter"),
        source=ObjPathSourceBinder(object_provides=ISpeaker.__identifier__),
        required=False,
    )
    form.widget(track=AutocompleteFieldWidget)
    track = RelationChoice(
        title=_(u"Track"),
        source=ObjPathSourceBinder(object_provides=ITrack.__identifier__),
        required=False,
    )

    #
    #    start = schema.Datetime(
    #            title=_(u"Startdate"),
    #            description =_(u"Start date"),
    #            required=False,
    #        )
    #
    #    end = schema.Datetime(
    #            title=_(u"Enddate"),
    #            description =_(u"End date"),
    #            required=False,
    #        )
    #    talktrack= schema.Choice(
    #               title=_(u"Choose the Track for the Talk"),
    #               vocabulary=talktrack,
    #               required=True,
    #               )

    length = schema.Choice(
        title=_(u"Length"),
        vocabulary=length,
        required=True,
    )
    dexterity.write_permission(order='collective.conference.ModifyTrack')
    order = schema.Int(
        title=_(u"Orderintrack"),
        description=_(u"Order in the track: write in an Integer from 1 to 12"),
        min=1,
        max=12,
        required=False,
    )

    slides = NamedBlobFile(
        title=_(u"Presentation slides"),
        description=_(u"Please upload your presentation"),
        required=False,
    )

    creativecommonslicense = schema.Bool(
        title=_(
            u'label_creative_commons_license',
            default=
            u'License is Creative Commons Attribution-Share Alike 3.0 License.'
        ),
        description=_(
            u'help_creative_commons_license',
            default=
            u'You agree that your talk and slides are provided under the Creative Commons Attribution-Share Alike 3.0 License.'
        ),
        default=True)

    dexterity.read_permission(reviewNotes='cmf.ReviewPortalContent')
    dexterity.write_permission(reviewNotes='cmf.ReviewPortalContent')
    reviewNotes = schema.Text(
        title=u"Review notes",
        required=False,
    )
Пример #27
0
def FileStorageTypeVocabulary(context):
    terms = [
        SimpleTerm(value=ZODBFile, title='ZODB File', token='ZODBFile'),
        SimpleTerm(value=BlobFile, title='Blob File', token='BlobFile'),
    ]
    return SimpleVocabulary(terms)
Пример #28
0
def available_cc_positions():
    position_choices = SimpleVocabulary(
        [SimpleTerm(value=u'top', title=_(u'Top')),
         SimpleTerm(value=u'bottom', title=_(u'Bottom'))]
    )
    return position_choices
Пример #29
0

KEY = "cstgate.document"


def not_document_being_translated(frm):
    return not frm.document_being_translated()


def document_translated(frm):
    return frm.document_translated()


model_vocabulary = SimpleVocabulary(
    [
        SimpleTerm("generic_en2es_GPU", title="generic_en2es_GPU"),
        SimpleTerm("generic_es2en_GPU", title="generic_es2en_GPU"),
    ]
)

translation_mode_vocabulary = SimpleVocabulary(
    [
        SimpleTerm("HumanTranslation", "HumanTranslation"),
        SimpleTerm("MachineTranslation", "MachineTranslation"),
        SimpleTerm("PostEditedTranslation", "PostEditedTranslation"),
    ]
)


class ITGateTranslation(Interface):
    model = Choice(title=_(u"Translation model"), source=model_vocabulary)
Пример #30
0
class IDXTestDocumentSchema(model.Schema):

    # zope.schema fields
    test_ascii_field = schema.ASCII(required=False)
    test_asciiline_field = schema.ASCIILine(required=False)
    test_bool_field = schema.Bool(required=False)
    test_bytes_field = schema.Bytes(required=False)
    test_bytesline_field = schema.BytesLine(required=False)
    test_choice_field = schema.Choice(values=[u"foo", u"bar"], required=False)
    test_choice_field_with_vocabulary = schema.Choice(
        vocabulary=SimpleVocabulary([
            SimpleTerm(u"value1", "token1", u"title1"),
            SimpleTerm(u"value2", "token2", u"title2"),
        ]),
        required=False,
    )

    test_choice_with_non_iterable_source = schema.Choice(
        required=False, source=my_non_iterable_source)
    test_choice_with_source = schema.Choice(required=False,
                                            source=my_iterable_source)
    test_choice_with_context_source = schema.Choice(
        required=False, source=my_context_source_binder)
    test_choice_with_querysource = schema.Choice(required=False,
                                                 source=my_querysource)
    test_choice_with_context_querysource = schema.Choice(
        required=False, source=my_context_querysource_binder)

    test_date_field = schema.Date(required=False)
    test_datetime_field = schema.Datetime(required=False)
    test_datetime_tz_field = schema.Datetime(
        required=False,
        defaultFactory=lambda: timezone("Europe/Zurich").localize(
            datetime(2017, 10, 31, 10, 0)),
    )
    test_decimal_field = schema.Decimal(required=False)
    test_dict_field = schema.Dict(required=False)
    test_float_field = schema.Float(required=False)
    test_frozenset_field = schema.FrozenSet(required=False)
    test_int_field = schema.Int(required=False)
    test_list_field = schema.List(required=False)
    test_list_field_with_choice_with_vocabulary = schema.List(
        value_type=schema.Choice(vocabulary=SimpleVocabulary([
            SimpleTerm(u"value1", "token1", u"title1"),
            SimpleTerm(u"value2", "token2", u"title2"),
            SimpleTerm(u"value3", "token3", u"title3"),
        ])),
        required=False,
    )
    test_set_field = schema.Set(required=False)
    test_set_field_with_choice_with_vocabulary = schema.Set(
        value_type=schema.Choice(vocabulary=SimpleVocabulary([
            SimpleTerm(u"value1", "token1", u"title1"),
            SimpleTerm(u"value2", "token2", u"title2"),
            SimpleTerm(u"value3", "token3", u"title3"),
        ])),
        required=False,
    )
    test_text_field = schema.Text(required=False)
    test_textline_field = schema.TextLine(required=False)
    test_time_field = schema.Time(required=False)
    test_timedelta_field = schema.Timedelta(required=False)
    test_tuple_field = schema.Tuple(required=False)
    test_nested_list_field = schema.List(required=False,
                                         value_type=schema.Tuple())
    test_nested_dict_field = schema.Dict(required=False,
                                         key_type=schema.ASCIILine(),
                                         value_type=schema.Tuple())
    test_list_choice_with_context_vocabulary_field = schema.List(
        title=u"Field",
        value_type=schema.Choice(
            vocabulary="plone.restapi.testing.context_vocabulary"),
        required=False,
    )

    # plone.app.textfield
    test_richtext_field = RichText(
        required=False, allowed_mime_types=["text/html", "text/plain"])

    # plone.namedfile fields
    test_namedfile_field = namedfile.NamedFile(required=False)
    test_namedimage_field = namedfile.NamedImage(required=False)
    test_namedblobfile_field = namedfile.NamedBlobFile(required=False)
    test_namedblobimage_field = namedfile.NamedBlobImage(required=False)

    primary("test_primary_namedfile_field")
    test_primary_namedfile_field = namedfile.NamedFile(required=False)

    # z3c.relationfield
    test_relationchoice_field = RelationChoice(
        required=False, source=CatalogSource(id=["doc1", "doc2"]))
    test_relationlist_field = RelationList(
        required=False,
        value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
    )

    # Test fields for validation
    test_required_field = schema.TextLine(required=True)
    test_readonly_field = schema.TextLine(required=False, readonly=True)
    test_maxlength_field = schema.TextLine(required=False, max_length=10)
    test_constraint_field = schema.TextLine(required=False,
                                            constraint=lambda x: u"00" in x)
    test_datetime_min_field = schema.Datetime(required=False,
                                              min=datetime(2000, 1, 1))
    test_time_min_field = schema.Time(required=False, min=time(1))
    test_timedelta_min_field = schema.Timedelta(required=False,
                                                min=timedelta(100))
    test_list_value_type_field = schema.List(required=False,
                                             value_type=schema.Int())
    test_dict_key_type_field = schema.Dict(required=False,
                                           key_type=schema.Int())

    read_permission(test_read_permission_field="cmf.ManagePortal")
    test_read_permission_field = schema.TextLine(required=False)
    write_permission(test_write_permission_field="cmf.ManagePortal")
    test_write_permission_field = schema.TextLine(required=False)

    read_permission(test_read_permission_field="cmf.ManagePortal")
    test_read_permission_field = schema.TextLine(required=False)

    test_invariant_field1 = schema.TextLine(required=False)
    test_invariant_field2 = schema.TextLine(required=False)

    test_missing_value_field = schema.TextLine(required=False,
                                               missing_value=u"missing",
                                               default=u"default")

    test_missing_value_required_field = schema.TextLine(
        required=True, missing_value=u"missing", default=u"some value")

    @invariant
    def validate_same_value(data):
        if data.test_invariant_field1 != data.test_invariant_field2:
            raise Invalid(u"Must have same values")

    # Test fields with default values
    test_default_value_field = schema.TextLine(required=True,
                                               default=u"Default")

    @provider(IContextAwareDefaultFactory)
    def default_factory(context):
        return u"DefaultFactory"

    test_default_factory_field = schema.TextLine(
        required=True, defaultFactory=default_factory)