'fgDefault',
    'fgTValidator']


def finalizeFormNorobotsFieldSchema(schema):
    
    # overrided in addFormNorobotsField
    schema['title'].default = 'Are you a human ?'
    # overrided in addFormNorobotsField
    schema['description'].default = 'In order to avoid spam, please answer the question below.'
    
    for field in HIDDEN_FIELDS:
        schema[field].widget.visible = {'view': 'invisible',
                                        'edit': 'invisible'}

FormNorobotsFieldSchema = BaseFieldSchemaStringDefault.copy()
finalizeFormNorobotsFieldSchema(FormNorobotsFieldSchema)


def addFormNorobotsField(self, id, **kwargs):
    obj = FormNorobotsField(id)
    notify(ObjectCreatedEvent(obj))
    self._setObject(id, obj)
    obj = self._getOb(id)
    obj.initializeArchetype(**kwargs)
    
    obj.setTitle(obj.translate(_(u'Are you a human ?')))
    obj.setDescription(obj.translate(_(u'In order to avoid spam, please answer the question below.')))
    
    
    notify(ObjectModifiedEvent(obj))
Beispiel #2
0
class PFGSelectionStringField(FGSelectionField):
    """Selection String Field"""

    schema = BaseFieldSchemaStringDefault.copy() + Schema((
        vocabularyField.copy(),
        vocabularyOverrideField.copy(),
        StringField(
            name='fgFormat',
            searchable=0,
            required=0,
            default='flex',
            enforceVocabulary=1,
            vocabulary='formatVocabDL',
            widget=SelectionWidget(
                label='Presentation Widget',
                i18n_domain="ploneformgen",
                label_msgid="label_fgformat_text",
                description_msgid="help_fgformat_text"))))

    schema['fgVocabulary'].widget.description = _(
        "Use one line per option. Format: 'value|label|description'.")

    finalizeFieldSchema(schema, folderish=True, moveDiscussion=False)

    portal_type = 'PFGSelectionStringField'
    implements(IPFGSelectionStringField)

    def __init__(self, oid, **kwargs):
        """ initialize class """

        FGSelectionField.__init__(self, oid, **kwargs)

        # set a preconfigured field as an instance attribute
        self.fgField = StringVocabularyField(
            name='fg_selection_field',
            searchable=0,
            required=0,
            widget=SelectionStringWidget(),
            vocabulary='_get_selection_vocab',
            enforceVocabulary=1,
            write_permission=View)

    def htmlValue(self, REQUEST):
        """ Return value instead of key """
        utils = getToolByName(self, 'plone_utils')
        charset = utils.getSiteEncoding()
        value = REQUEST.form.get(self.__name__, '')
        vu = value.decode(charset)
        vocabulary = self.fgField.Vocabulary(self)
        item = dict(vocabulary).get(vu)
        if self.fgFormat == 'radio' or (self.fgFormat == 'flex' and len(vocabulary) <= 4):
            name = '{}_{}'.format(self.__name__, vu)
        else:
            name = '{}_SELECT'.format(self.__name__)
        desc = REQUEST.form.get(name, None)
        if item is None:
            return vu
        elif desc is None:
            return safe_unicode(cgi.escape(item[0].encode(charset)))
        else:
            return '{}<br />{}'.format(safe_unicode(cgi.escape(item[0].encode(charset))), safe_unicode(cgi.escape(desc.decode(charset))))
from zope.interface import implements
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary
from AccessControl import ClassSecurityInfo
from Products.ATContentTypes.content import schemata
from Products.Archetypes import atapi
from Products.CMFCore.permissions import View
from Products.PloneFormGen.content.fieldsBase import BaseFormField, BaseFieldSchemaStringDefault
from jazkarta.shop.interfaces import IProduct
from .interfaces import IJazShopSelectStringField, IJazShopMultiSelectStringField
from .interfaces import IJazShopArbitraryPriceStringField
from .config import PROJECTNAME


JazShopSelectFieldSchema = BaseFieldSchemaStringDefault.copy() + atapi.Schema((
    atapi.StringField('availableProducts',
        searchable=False,
        required=False,
        widget=atapi.MultiSelectionWidget(),
        vocabulary_factory='jazkarta.pfg.jazshop.available_products',
        enforceVocabulary=False,
    ),
    atapi.StringField('selectionFormat',
        vocabulary=('select', 'radio'),
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(format='radio'),
        required=True,
    ),
))
Beispiel #4
0
    'description',
    'required',
    'hidden',
    'fgTDefault',
    'fgTEnabled',
    'fgDefault',
    'fgTValidator']


def finalizeCaptchaFieldSchema(schema):
    schema['title'].default = 'key'
    for field in HIDDEN_FIELDS:
        schema[field].widget.visible = {'view': 'invisible',
                                        'edit': 'invisible'}

CaptchaFieldSchema = BaseFieldSchemaStringDefault.copy()
finalizeCaptchaFieldSchema(CaptchaFieldSchema)


def addCaptchaField(self, id, **kwargs):
    obj = CaptchaField(id)
    notify(ObjectCreatedEvent(obj))
    self._setObject(id, obj)
    obj = self._getOb(id)
    obj.initializeArchetype(**kwargs)
    notify(ObjectModifiedEvent(obj))
    return obj.getId()


class CaptchaField(FGStringField):
from AccessControl import ClassSecurityInfo
from Products.CMFCore.permissions import View
from Products.Archetypes import atapi
from Products.ATContentTypes.content.base import registerATCT
from Products.PloneFormGen.content.fieldsBase import (
    finalizeFieldSchema,
    BaseFormField,
    BaseFieldSchemaStringDefault,
)
from . import config


email_schema = BaseFieldSchemaStringDefault.copy() + atapi.Schema((
))


del starrating_schema['hidden']
del starrating_schema['serverSide']


finalizeFieldSchema(starrating_schema, folderish=True, moveDiscussion=False)


class FormEmailField(BaseFormField):
    """Email Field.
    """
    meta_type = 'FormEmailField'
    security = ClassSecurityInfo()
    schema = email_schema

    def __init__(self, oid, **kwargs):
# -*- coding: utf-8 -*-
from AccessControl import ClassSecurityInfo
from collective.pfg.starrating import config
from Products.Archetypes import atapi
from Products.ATContentTypes.content.base import registerATCT
from Products.CMFCore.permissions import View
from Products.CMFCore.utils import getToolByName
from Products.PloneFormGen.content.fieldsBase import BaseFieldSchemaStringDefault
from Products.PloneFormGen.content.fieldsBase import BaseFormField
from Products.PloneFormGen.content.fieldsBase import finalizeFieldSchema
from Products.PloneFormGen.content.fieldsBase import StringVocabularyField
from Products.PloneFormGen.content.fieldsBase import vocabularyField
from Products.PloneFormGen.content.fieldsBase import vocabularyOverrideField

starrating_schema = BaseFieldSchemaStringDefault.copy() + atapi.Schema((
    vocabularyField,
    vocabularyOverrideField,
))

del starrating_schema['hidden']
del starrating_schema['serverSide']

finalizeFieldSchema(starrating_schema, folderish=True, moveDiscussion=False)


class FormStarRatingField(BaseFormField):
    """ Star Rating Field (radio buttons or select) """

    meta_type = 'FormStarRatingField'
    security = ClassSecurityInfo()
    schema = starrating_schema
from Products.Archetypes.public import IntegerWidget
from Products.Archetypes.public import DateTimeField
from Products.Archetypes.public import CalendarWidget

from Products.CMFCore.permissions import View, ModifyPortalContent

from zope.interface import implements

from AccessControl import ClassSecurityInfo
from DateTime import DateTime
import cgi

from collective.pfg.creditcardfields.config import PROJECTNAME
from collective.pfg.creditcardfields.interfaces import IFGCCExpirationDateField

ccexpdate_schema = BaseFieldSchemaStringDefault.copy() + Schema((
        IntegerField('fgStartingYear',
            searchable=0,
            required=0,
            default=DateTime().year(),
            widget=IntegerWidget(
                label='Starting Year',
                i18n_domain = "ploneformgen",
                label_msgid = "label_fgstartingyear_text",
                description = "The first year to offer in the year drop-down.",
                description_msgid = "help_fgstartingyear_text",
                ),
        ),
        IntegerField('fgEndingYear',
            searchable=0,
            required=0,
Beispiel #8
0
    'fgDefault',
    'fgTValidator']


def finalizeFormNorobotsFieldSchema(schema):
    
    # overrided in addFormNorobotsField
    schema['title'].default = 'Are you a human ?'
    # overrided in addFormNorobotsField
    schema['description'].default = 'In order to avoid spam, please answer the question below.'
    
    for field in HIDDEN_FIELDS:
        schema[field].widget.visible = {'view': 'invisible',
                                        'edit': 'invisible'}

FormNorobotsFieldSchema = BaseFieldSchemaStringDefault.copy()
finalizeFormNorobotsFieldSchema(FormNorobotsFieldSchema)


def addFormNorobotsField(self, id, **kwargs):
    obj = FormNorobotsField(id)
    notify(ObjectCreatedEvent(obj))
    self._setObject(id, obj)
    obj = self._getOb(id)
    obj.initializeArchetype(**kwargs)
    
    obj.setTitle(obj.translate(_(u'Are you a human ?')))
    obj.setDescription(obj.translate(_(u'In order to avoid spam, please answer the question below.')))
    
    
    notify(ObjectModifiedEvent(obj))