예제 #1
0
  'friends_groups',
  'friends_hometown',
  'friends_interests',
  'friends_likes',
  'friends_location',
  'friends_notes',
  'friends_photos',
  'friends_questions',
  'friends_relationships',
  'friends_relationship_details',
  'friends_religion_politics',
  'friends_status',
  'friends_subscriptions',
  'friends_videos',
  'friends_website',
  'friends_work_history',
]


ExtendedPermissionsVocabulary = SimpleVocabulary([
  SimpleTerm(term, term, unicode(term)) for term in extended_permissions_list
])

UserPermissionsVocabulary = SimpleVocabulary([
  SimpleTerm(term, term, unicode(term)) for term in user_permissions_list
])

FriendsPermissionsVocabulary = SimpleVocabulary([
  SimpleTerm(term, term, unicode(term)) for term in friends_permissions_list
])
예제 #2
0
# -*- coding: utf-8 -*-
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

import pycountry

countries = [
    SimpleTerm(value=country.alpha3, token=country.alpha3, title=country.name)
    for country in pycountry.countries
]
country_vocabulary = SimpleVocabulary(countries)

platforms = [u'all platforms', u'Mac OS X', u'Windows', u'Linux/BSD/Unix']
platform_vocabulary = SimpleVocabulary(
    [SimpleTerm(value=a, token=a, title=a) for a in platforms])
예제 #3
0
 def __call__(self, context):
     '''
     Return all the tipologies defined in the PrenotazioniFolder
     '''
     return SimpleVocabulary(self.get_terms(context))
예제 #4
0
# items = [ ('low', _('secret')),
#           ('mid', _('more secret')),
#           ('height', _('most secret'))
#           ]
items = [
    ('60', _('no secret')),
    ('65', _('inner')),
    ('70', _('normal secret')),
    ('80', _('more secret')),
    ('90', _('most secret')),
    ('100', _('Null')),
]
terms = [
    SimpleTerm(value=pair[0], token=pair[0], title=pair[1]) for pair in items
]
Vocabulary = SimpleVocabulary(terms)


@provider(IVocabularyFactory)
def safe_level_factory(context):
    return Vocabulary


@implementer(IVocabularyFactory)
class ExcludeProjectKeywordsVocabulary(object):
    """Vocabulary factory listing all catalog keywords from the 'Subject' index

        >>> from plone.app.vocabularies.tests.base import DummyCatalog
        >>> from plone.app.vocabularies.tests.base import create_context
        >>> from plone.app.vocabularies.tests.base import DummyContent
        >>> from plone.app.vocabularies.tests.base import Request
예제 #5
0
    """ pick up the list of platforms from parent """

    platforms_list = getattr(context.__parent__, 'available_platforms', [])
    terms = []
    for value in platforms_list:
        terms.append(
            SimpleTerm(value,
                       token=value.encode('unicode_escape'),
                       title=value))
    return SimpleVocabulary(terms)


directlyProvides(vocabAvailPlatforms, IContextSourceBinder)

yesnochoice = SimpleVocabulary([
    SimpleTerm(value=0, title=_(u'No')),
    SimpleTerm(value=1, title=_(u'Yes')),
])


@provider(IContextAwareDefaultFactory)
def getContainerTitle(self):
    return (self.aq_inner.title)


@provider(IContextAwareDefaultFactory)
def contactinfoDefault(context):
    return context.contactAddress


@provider(IContextAwareDefaultFactory)
def legal_declaration_title(context):
 def __call__(self, context):
     saconnect = ISQLAlchemyConnectionStrings(
         component.getUtility(ISiteRoot))
     items = [SimpleTerm(name, name, name) for name in saconnect.keys()]
     return SimpleVocabulary(items)
예제 #7
0
# -*- coding: utf-8 -*-
import random
from DateTime import DateTime
# from plone.app.textfield import RichText
from plone.dexterity.content import Container
from plone.supermodel import model
from zope import schema
from zope.interface import implementer
from plone import api as ploneapi
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from edi.schrift import _

schrifttyp = SimpleVocabulary([
    SimpleTerm(value=u'dp-pruefstellen-info', title=_(u'DP-Prüfstellen-Info')),
    SimpleTerm(value=u'dp-info', title=_(u'DP-Info'))
])


def genWebcode():
    aktuell = unicode(DateTime()).split(' ')[0]
    neujahr = '%s/01/01' % str(DateTime()).split(' ')[0][:4]
    konstante = unicode(aktuell[2:4])
    zufallszahl = unicode(random.randint(100000, 999999))
    code = konstante + zufallszahl
    results = ploneapi.content.find(Webcode=code,
                                    created={
                                        "query": [neujahr, aktuell],
                                        "range": "minmax"
                                    })
    while results:
        zufallszahl = unicode(random.randint(100000, 999999))
예제 #8
0
 def __call__(self, context):
     items = [
         # value, token, title
         SimpleTerm(value, value, title) for value, title in GENDERS
     ]
     return SimpleVocabulary(items)
예제 #9
0
 def __call__(self, context):
     items = [
         # value, token, title
         SimpleTerm(value, value, title) for value, title in NAME_ENTRY_MODES
     ]
     return SimpleVocabulary(items)
예제 #10
0
)

FONT_CHOICES = (
    (u'Georgia-Helvetica', _(u'Georgia & Helvetica Neue')),
    (u'Bevan-PotanoSans', _(u'Bevan & Potano Sans')),
    (u'Merriweather-NewsCycle', _(u'Merriweather & News Cycle')),
    (u'NewsCycle-Merriweather', _(u'News Cycle & Merriweather')),
    (u'PoiretOne-Molengo', _(u'Poiret One & Molengo')),
    (u'Arvo-PTSans', _(u'Arvo & PT Sans')),
    (u'PTSerif-PTSans', _(u'PT Serif & PT Sans')),
    (u'DroidSerif-DroidSans', _(u'Droid Serif & Droid Sans')),
    (u'Lekton-Molengo', _(u'Lekton & Molengo')),
    (u'NixieOne-Ledger', _(u'Nixie One & Ledger')),
    (u'AbrilFatface-Average', _(u'Abril Fatface & Average')),
    (u'PlayfairDisplay-Muli', _(u'Playfair Display & Muli')),
    (u'Rancho-Gudea', _(u'Rancho & Gudea')),
    (u'BreeSerif-OpenSans', _(u'Bree Serif & Open Sans')),
    (u'SansitaOne-Kameron', _(u'Sansita One & Kameron')),
    (u'Pacifico-Arimo', _(u'Pacifico & Arimo')),
    (u'PT', _(u'PT Sans & PT Narrow & PT Serif')),
)

MAP_VOCAB = SimpleVocabulary([
    SimpleVocabulary.createTerm(t[0], t[0].encode('ascii'), t[1])
    for t in MAP_STYLES
])
FONT_VOCAB = SimpleVocabulary([
    SimpleVocabulary.createTerm(t[0], t[0].encode('ascii'), t[1])
    for t in FONT_CHOICES
])
예제 #11
0
from plone.uuid.interfaces import IUUID
from Products.CMFCore.utils import getToolByName
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.schema.interfaces import IVocabularyFactory
from zope.component import getUtility
from zope.component.hooks import getSite

from collective.rcse.i18n import _, _t
from collective.rcse import cache
from collective.rcse.settings import IPersonalPreferences, themes as s_themes
from collective.rcse.utils import sudo

themes = s_themes

gender = SimpleVocabulary([
    SimpleTerm(value=u"female", title=_(u"Female")),
    SimpleTerm(value=u"male", title=_(u"Male")),
])

image_position = SimpleVocabulary([
    SimpleTerm(value=u"top-left", title=_(u"Top left")),
    SimpleTerm(value=u"top-right", title=_(u"Top right")),
    SimpleTerm(value=u"bottom-left", title=_(u"Bottom left")),
    SimpleTerm(value=u"bottom-right", title=_(u"Bottom right")),
])

languages = SimpleVocabulary([
    SimpleTerm(value=u"English", title=_(u"English")),
    SimpleTerm(value=u"French", title=_(u"French")),
    SimpleTerm(value=u"Italian", title=_(u"Italian")),
    SimpleTerm(value=u"Spanish", title=_(u"Spanish")),
])
예제 #12
0
from ploneintranet.core import ploneintranetCoreMessageFactory as _
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


todo_priority = SimpleVocabulary(
    [
        SimpleTerm(value=-1, title=_(u'No priority')),
        SimpleTerm(value=0, title=_(u'Low')),
        SimpleTerm(value=1, title=_(u'Medium')),
        SimpleTerm(value=2, title=_(u'High'))
    ]
)
예제 #13
0
from zope.browserpage.viewpagetemplatefile import \
    ViewPageTemplateFile as Zope3PageTemplateFile
from zope.component import getMultiAdapter, getUtility
from zope.interface import Invalid, invariant
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary

from wla.publications import _
from wla.publications.utils import trusted, validateaddress

greetings = SimpleVocabulary(
    [
     SimpleTerm(value='--NOVALUE--', title=_(u'select value')),
     SimpleTerm(value='An', title=_(u'An')),
     SimpleTerm(value='Ehepaar', title=_(u'Ehepaar')),
     SimpleTerm(value='Familie', title=_(u'Familie')),
     SimpleTerm(value='Firma', title=_(u'Firma')),
     SimpleTerm(value='Frau', title=_(u'Frau')),
     SimpleTerm(value='Herr', title=_(u'Herr')),
     SimpleTerm(value='Herr und Frau', title=_(u'Herr und Frau')),

     ]
    )

titles = SimpleVocabulary(
    [SimpleTerm(value='--NOVALUE--', title=_(u'select value')),
     SimpleTerm(value='Dr.', title=_(u'Dr.')),
     SimpleTerm(value='Professor', title=_(u'Professor')),
     SimpleTerm(value='Prof. Dr.', title=_(u'Prof. Dr.'))

     ]
    )
예제 #14
0
 def __call__(self, *args, **kwargs):
     voc = super(SortingCatalogIndexesVocabulary, self).__call__()
     terms = voc._terms
     terms.extend((SimpleTerm('sort_on', 'sort_on', 'Sort On'),
                   SimpleTerm('sort_order', 'sort_order', 'Sort Order')))
     return SimpleVocabulary(terms)
예제 #15
0
# allow types from locallyAllowedTypes only
ENABLED = 1


def ST(key, title):
    return SimpleTerm(value=key, title=title)


# reuse the translations that we had in atcontenttypes
AMF = MessageFactory('atcontenttypes')

possible_constrain_types = SimpleVocabulary([
    ST(
        ACQUIRE,
        AMF('constraintypes_acquire_label',
            default='Use parent folder settings')),
    ST(DISABLED,
       AMF('constraintypes_disable_label', default='Use portal default')),
    ST(ENABLED, AMF('constraintypes_enable_label', default='Select manually'))
])


@implementer(IVocabularyFactory)
class ValidTypes:
    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)
예제 #16
0
class IPerson(model.Schema):
    """ Marker interface and Dexterity Python Schema for Person
        Reference Schema Popolo-spec Person JSON Schema
        https://www.popoloproject.com/specs/person.html
    """
    # If you want, you can load a xml model created TTW here
    # and customize it in Python:

    # model.load('person.xml')

    # directives.widget(level=RadioFieldWidget)
    # level = schema.Choice(
    #     title=_(u'Sponsoring Level'),
    #     vocabulary=LevelVocabulary,
    #     required=True
    # )

    dexteritytextindexer.searchable('name')
    name = schema.TextLine(
        title=_(u'Name'),
        description=_(u'A person\'s preferred full name'),
    )

    dexteritytextindexer.searchable('summary')
    summary = schema.Text(
        title=_(u'Summary'),
        description=_(u'One line description of this person'),
    )

    gender = schema.Choice(
        title=_(u'Gender'),
        vocabulary=SimpleVocabulary([
            SimpleTerm(value=u'male', title=_(u'Male')),
            SimpleTerm(value=u'female', title=_(u'Female')),
            SimpleTerm(value=u'other', title=_(u'Other'))
        ]),
        required=False,
    )

    birth_date = schema.Date(
        title=_(u'Date of Birth'),
        required=False,
    )

    death_date = schema.Date(
        title=_(u'Date of Death'),
        required=False,
    )

    image = field.NamedImage(
        title=_(u"Headshot"),
        description=_(u'Image file of a headshot person'),
        required=False,
    )

    dexteritytextindexer.searchable('biography')
    biography = RichText(
        title=_(u'Biography'),
        description=_(u'Detailed biography of this person'),
        required=False,
    )

    dexteritytextindexer.searchable('notes')
    notes = RichText(title=_(u'Notes'), required=False)
예제 #17
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)
예제 #18
0
 def __call__(self, context):
     terms = [
         SimpleVocabulary.createTerm(value, value, label)
         for value, label in self.values_list
     ]
     return SimpleVocabulary(terms)
 def __call__(self, context=None):
     items = [SimpleTerm(k, k, v) for k, v in uf]
     return SimpleVocabulary(items)
예제 #20
0
class IBundleRegistry(zope.interface.Interface):

    jscompilation = schema.ASCIILine(
        title=_(u"URL of the last js compilation"), required=False)

    csscompilation = schema.ASCIILine(
        title=_(u"URL of the last css compilation"), required=False)

    last_compilation = schema.Datetime(
        title=_(u"Last compiled date"),
        description=_(u"Date time of the last compilation of this bundle"),
        required=False)

    expression = schema.ASCIILine(
        title=_(u"Expression to render"),
        description=_(
            u"In case its a bundle we can have a condition to render it (it "
            "does not apply if the bundle is merged)."),
        required=False)

    conditionalcomment = schema.ASCIILine(
        title=_(u"Conditional comment"),
        description=_(
            u"In case you want to render this resource on conditional comment "
            "(it does not apply if the bundle is merged)."),
        required=False)

    resources = schema.List(
        title=_(u"Loaded resources"),
        description=_(
            u"The resources that are going to be loaded on this bundle in order"
        ),
        value_type=schema.ASCIILine(title=_(u"Resource name")),
        required=False)

    enabled = schema.Bool(title=_(u"It's enabled?"),
                          default=True,
                          required=False)

    compile = schema.Bool(
        title=_(u"Does your bundle contains any RequireJS or LESS file?"),
        description=
        _(u"If its true and you modify this bundle you need to build it before production"
          ),
        default=True,
        required=False)

    depends = schema.ASCIILine(
        title=_(u"Depends on another bundle"),
        description=
        _(u"In case you want to be the last: *, in case its the first should be empty"
          ),
        required=False)

    develop_javascript = schema.Bool(title=_(u'Develop JavaScript'),
                                     default=False)

    develop_css = schema.Bool(title=_(u'Develop CSS'), default=False)

    stub_js_modules = schema.List(
        title=_(u'Stub JavaScript modules'),
        description=_(
            u'Define list of modules that will be defined empty '
            u'on RequireJS build steps to prevent loading modules multiple times.'
        ),
        value_type=schema.ASCIILine(title=_(u"Resource name")),
        required=False,
        missing_value=[],
        default=[])

    merge_with = schema.Choice(
        title=_(u"Merge with"),
        description=_(
            u"In production mode, bundles are merged together to reduce the "
            "quantity of JS and CSS resources loaded by the browser. Choose "
            "'default' if this bundle must be available for all the visitors, "
            "choose 'logged-in' if it must be available for logged-in users "
            "only, or leave it empty if it must not be merged."),
        vocabulary=SimpleVocabulary([
            SimpleTerm('', '', _(u"")),
            SimpleTerm('default', 'default', 'default'),
            SimpleTerm('logged-in', 'logged-in', 'logged-in')
        ]),
        default=u"",
        required=False)

    load_async = schema.Bool(
        title=_(u"Load asynchronously"),
        description=
        _("Load the JavaScript files asynchronously by adding an ``async`` attribute to the script tag."
          ),
        default=False,
        required=False)

    load_defer = schema.Bool(
        title=_(u"Load deferred"),
        description=
        _("Load the JavaScript files deferred after the document has been parsed but before ``DOMContentLoaded`` by adding a ``defer`` attribute to the script tag."
          ),
        default=False,
        required=False)
예제 #21
0
class IGlobalMediaSettings(Interface):
    additional_video_formats = schema.List(
        title=_("Additional Video Formats"),
        description=_('additional_video_formats_help',
                      default=u"To provide better HTML5 support, different video "
                              u"formats are generated via avconv (formerly ffmpeg). "
                              u"If you'd prefer to save on disc space, but provide "
                              u"less HTML5 support, change the additional video "
                              u"formats that are generated here"),
        default=['ogg', 'webm'],
        value_type=schema.Choice(
            vocabulary=SimpleVocabulary(VIDEO_FORMATS_VOCAB)
        )
    )
    async_quota_size = schema.Int(
        title=_("Async Quota Size"),
        description=_("Number of conversions to run at a time. "
                      "The quota name assigned is `wildcard.media`."),
        default=3)

    force = schema.Bool(
        title=_("Force video conversion"),
        description=_(
            "always_convert_help",
            default=u"Force the video through the full conversion "
                    u"process, even if it is already in the final video format."
                    u" This may be useful if you always want to transcode to a "
                    u"given video size."
        ),
        default=False,
    )

    avconv_in_mp4 = schema.TextLine(
        title=_("MP4: infile parameters"),
        description=_(
            'avconv_in_mp4_help',
            default=u"Pass optional infile parameters to aconv during the "
                    u"MP4 conversion process."
        ),
        default=u'',
        required=False,
    )

    avconv_out_mp4 = schema.TextLine(
        title=_("MP4: outfile parameters"),
        description=_(
            'avconv_out_mp4_help',
            default=u"Pass optional outfile parameters to aconv during the "
                    u"MP4 conversion process."
        ),
        default=u'',
        required=False,
    )

    avconv_in_webm = schema.TextLine(
        title=_("WebM: infile parameters"),
        description=_(
            'avconv_in_webm_help',
            default=u"Pass optional infile parameters to aconv during the "
                    u"WebM conversion process."
        ),
        default=u'',
        required=False,
    )

    avconv_out_webm = schema.TextLine(
        title=_("WebM: outfile parameters"),
        description=_(
            'avconv_out_webm_help',
            default=u"Pass optional outfile parameters to aconv during the "
                    u"WebM conversion process."
        ),
        default=u'',
        required=False,
    )

    avconv_in_ogg = schema.TextLine(
        title=_("OGG: infile parameters"),
        description=_(
            'avconv_in_ogg_help',
            default=u"Pass optional infile parameters to aconv during the "
                    u"OGG conversion process."
        ),
        default=u'',
        required=False,
    )

    avconv_out_ogg = schema.TextLine(
        title=_("OGG: outfile parameters"),
        description=_(
            'avconv_out_ogg_help',
            default=u"Pass optional outfile parameters to aconv during the "
                    u"OGG conversion process."
        ),
        default=u'',
        required=False,
    )


    default_video_width = schema.Int(
        title=_(u'Default video width'),
        default=720)

    default_video_height = schema.Int(
        title=_(u'Default video height'),
        default=400)
예제 #22
0
# -*- coding: utf-8 -*-
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
from plone.z3cform import layout
from plonetheme.siguv import _
from zope import schema
from zope.interface import Interface
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

NavigationStatusVocabulary = SimpleVocabulary([
    SimpleTerm(value=u'enabled',
               title=_(u'siguv_settings_navigation_status_enabled',
                       default=u'Enabled')),
    SimpleTerm(value=u'disabled',
               title=_(u'siguv_settings_navigation_status_disabled',
                       default=u'Disabled')),
    SimpleTerm(value=u'collapsed',
               title=_(u'siguv_settings_navigation_status_collapsed',
                       default=u'Collapsed'))
], )


class ISettings(Interface):

    navigation_status = schema.Choice(
        title=_(u'controlpanel_siguv_settings_navigation_status_title',
                default='Navigation Status'),
        description=_(
            u'controlpanel_siguv_settings_navigation_status_description',
            default=
예제 #23
0
def userid_factory_vocabulary(context):
    items = []
    for name, factory in getUtilitiesFor(IUserIDFactory):
        items.append([factory.title, name])
    items = [SimpleTerm(name, name, title) for title, name in sorted(items)]
    return SimpleVocabulary(items)
        title=u'Percent',
        default=False,
    )


CALCULATION_METHODS = SimpleVocabulary([
    SimpleTerm(value='weight', token='weight', title=u'By weight'),
    SimpleTerm(value='usps:USPS Priority Mail',
               token='usps_prioritymail',
               title=u'USPS Priority Mail'),
    SimpleTerm(value='usps:USPS Media Mail',
               token='usps_mediamail',
               title=u'USPS Media Mail'),
    SimpleTerm(value='ups:UPS Next Day',
               token='ups_nextday',
               title=u'UPS Next Day'),
    SimpleTerm(value='ups:UPS 2nd Day', token='ups_2day',
               title=u'UPS 2nd Day'),
    SimpleTerm(value='ups:UPS 3 Day Select',
               token='ups_3day',
               title=u'UPS 3 Day Select'),
    SimpleTerm(value='ups:UPS Standard',
               token='ups_standard',
               title=u'UPS Standard'),
    SimpleTerm(value='free', token='free', title=u'Free shipping'),
])


class IShippingMethod(model.Schema):
    name = schema.TextLine(title=u'Name')
    zones = schema.Set(
예제 #25
0
 def __call__(self, context):
     items = super(PortalTypesVocabulary, self).__call__(context)
     items = [i for i in items if i.token not in ('Glossary', 'Term')]
     return SimpleVocabulary(items)
예제 #26
0
 def __call__(self, context):
     languages = get_all_languages()
     items = [(l, languages[l].get('name', l)) for l in languages]
     items.sort(key=lambda language: language[1])
     items = [SimpleTerm(i[0], i[0], i[1]) for i in items]
     return SimpleVocabulary(items)
예제 #27
0
 def __call__(self, context):
     """Returns a SimpleVocabulary of gram stains
     """
     items = map(lambda g: SimpleTerm(g[0], title=g[1]), GRAM_STAIN_OPTIONS)
     return SimpleVocabulary(items)
예제 #28
0
 def __call__(self, context):
     language = get_language(context)
     languages = get_all_languages(filter=[language])
     items = [(l, languages[l].get('name', l)) for l in languages]
     items = [SimpleTerm(i[0], i[0], i[1]) for i in items]
     return SimpleVocabulary(items)
예제 #29
0
 def __call__(self, context):
     return SimpleVocabulary(self.terms)
예제 #30
0
import unittest
from collective.regjsonify.interfaces import IJSONifier
#from collective.regjsonify.interfaces import IJSONFieldDumper
#from collective.regjsonify.fields import Base as JSONifyBase
from collective.regjsonify.testing import REG_JSONIFY_INTEGRATION_TESTING
from plone.registry import Registry
from plone.registry.field import PersistentField
from z3c.form.object import registerFactoryAdapter
from zope import interface
from zope import schema
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

test_vocab = SimpleVocabulary((SimpleTerm(value=1,
                                          token='sunny',
                                          title=u'Sunny'),
                               SimpleTerm(value=2,
                                          token='raining',
                                          title=u'Raining')))


class TestPersistentObject(PersistentField, schema.Object):
    pass


class IUnknown(interface.Interface):
    data_1 = schema.TextLine(title=u"Some text", default=u"Foo bar")
    data_2 = schema.TextLine(title=u"Other text", default=u"Baz qux")
    data_3 = schema.Tuple(title=u"Subtuple")


class Unknown(object):