Exemplo n.º 1
0
 def getFields(self):
     fields = []
     for schema_name, schema in self._getSchemas():
         for field_name, field in getFieldsInOrder(schema):
             if IChoice.providedBy(field):
                 fields.append(StringField(
                     schema_name + '.' + field.__name__,
                     required=field.required,
                     schemata='categorization',
                     widget=atapi.SelectionWidget(
                         label = field.title,
                         description = field.description,
                         ),
                     vocabulary = atapi.DisplayList([(t.value, t.title or t.token) for t in field.vocabulary]),
                     ))
             elif ISet.providedBy(field) and IChoice.providedBy(field.value_type): # XXX should be set
                 fields.append(LinesField(
                     schema_name + '.' + field.__name__,
                     required=field.required,
                     schemata='categorization',
                     widget=atapi.MultiSelectionWidget(
                         label = field.title,
                         description = field.description,
                         ),
                     vocabulary = atapi.DisplayList([(t.value, t.title or t.token) for t in field.value_type.vocabulary]),
                     ))
     return fields
Exemplo n.º 2
0
    def __init__(self, oid, **kwargs):
        BaseFormField.__init__(self, oid, **kwargs)

        self.fgField = atapi.StringField('fg_product_select_field',
            searchable=False,
            required=False,
            widget=atapi.SelectionWidget(),
            vocabulary='_get_selection_vocabulary',
            enforceVocabulary=False,
            write_permission=View,
            )
Exemplo n.º 3
0
class ProgrammeFields(grok.Adapter):

    # This applies to all AT Content Types, change this to
    # the specific content type interface you want to extend
    grok.context(IProgrammeFieldsEnabled)
    grok.name('wcc.programmeplanner.programmefields')
    grok.implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender)
    grok.provides(IOrderableSchemaExtender)

    layer = IProductSpecific

    fields = [
        # add your extension fields here
        ExtensionStringField(
            'event_type',
            vocabulary_factory='wcc.programmeplanner.event_type',
            storage=atapi.AttributeStorage(),
            widget=atapi.SelectionWidget(label=u'Event Type'),
            required=False,
            schemata='default'),
        ExtensionStringField(
            'focus_group',
            vocabulary_factory='wcc.programmeplanner.focus_group',
            storage=atapi.AttributeStorage(),
            widget=atapi.SelectionWidget(label=u'Focus Group', ),
            required=False,
            schemata='default')
    ]

    def __init__(self, context):
        self.context = context

    def getFields(self):
        return self.fields

    def getOrder(self, schematas):
        # you may reorder the fields in the schemata here
        return schematas
Exemplo n.º 4
0
class IconExtender(object):
    """Schema extender for Icons.
    """

    fields = [
        ImageExtensionField(
            'iconimage',
            schemata='settings',
            mode="w",
            write_permission="Manage portal",
            required=False,
            validators=(('isNonEmptyFile', V_REQUIRED),
                        ('checkNewsImageMaxSize', V_REQUIRED)),
            widget=atapi.ImageWidget(
                label=u"Icon Image",
                description=u"You can upload an icon image. This image will be"
                u" used as the icon for the content.",
                show_content_type=False,
            ),
        ),
        StringExtensionField(
            'iconpool',
            schemata='settings',
            mode="w",
            write_permission="Manage portal",
            default='__empty__',
            required=False,
            vocabulary=IconVocabulary(),
            widget=atapi.SelectionWidget(
                label=u"Icon Pool",
                description=u"You can select an icon from the pool. This image"
                u" will be used as the icon for the content.",
            )),
    ]

    layer = ICustomIconLayer

    def __init__(self, context):
        self.context = context

    def getFields(self):
        return self.fields

    def getOrder(self, original):
        neworder = OrderedDict()
        for schemata in original.keys():
            neworder[schemata] = original[schemata]
        return neworder
Exemplo n.º 5
0
                  )),
 atapi.StringField(name='chamado',
                   required=False,
                   searchable=True,
                   widget=atapi.StringWidget(
                       label=_(u"Chamado"),
                       description=_(u"Número do chamado"),
                       size=10,
                   )),
 atapi.StringField(
     name='ordem_servico',
     required=False,
     searchable=True,
     widget=atapi.SelectionWidget(
         label=_(u"Ordem de serviço"),
         description=_(u"Número da ordem de serviço"),
         format='select',
     ),
     vocabulary='getOS',
 ),
 atapi.BooleanField(
     name='federativo',
     required=False,
     searchable=True,
     default=True,
     widget=atapi.BooleanWidget(
         label=_(u"Federativo"),
         description=
         _(u"Federativo quando é utilizado em 15 ou mais tribunais da Justiça Eleitoral."
           ),
     )),
             u"Choose Plone Groups which members should receive the newsletter."
         ),
         i18n_domain='EasyNewsletter',
         size=10,
     )),
 atapi.StringField(
     'subscriberSource',
     schemata='settings',
     vocabulary="get_subscriber_sources",
     default='default',
     widget=atapi.SelectionWidget(
         label=_(u"EasyNewsletter_label_externalSubscriberSource",
                 default="External subscriber source"),
         description=_(
             u"EasyNewsletter_help_externalSubscriberSource",
             default=u"Some packages provide an external subscriber source \
                 for EasyNewsletter. If one is installed you can choose it here."
         ),
         i18n_domain='EasyNewsletter',
         size=10,
     )),
 atapi.StringField(
     'deliveryService',
     schemata='settings',
     vocabulary="get_delivery_services",
     default='mailhost',
     widget=atapi.SelectionWidget(
         label=_(u"EasyNewsletter_label_externalDeliveryService",
                 default=u"External delivery service"),
         description=_(
             u"EasyNewsletter_help_externalDeliveryService",
Exemplo n.º 7
0
from mj.agenda import agendaMessageFactory as _

from mj.agenda.interfaces.interfaces import IMJEvento
from mj.agenda.config import PROJECTNAME


MJEventoSchema = ATFolder.schema.copy() + ATEventSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-
    atapi.StringField(
        name='event_categoria',
        required=False,
        searchable=True,
        schemata='categorization',
        widget=atapi.SelectionWidget(
            label=_(u"Categoria do evento"),
            description=_(u"Selecione a categoria do evento"),
            format='select',),
        vocabulary='getCategoria',
    ),

))


schemata.finalizeATCTSchema(MJEventoSchema, moveDiscussion=False)


class MJEvento(ATFolder, CalendarSupportMixin):
    """
    """

    implements(IMJEvento, IATFolder, IATEvent)
Exemplo n.º 8
0
     vocabulary_display_path_bound=sys.maxint,
     allowed_types=('AnalysisCategory', ),
     relationship='ClientRestrictedCategories',
     widget=atapi.ReferenceWidget(
         checkbox_bound=0,
         label=_("Restrict categories"),
         description=_("Show only selected categories in client views"),
     ),
 ),
 atapi.StringField('DefaultARSpecs',
                   schemata="Preferences",
                   default='ar_specs',
                   vocabulary=DEFAULT_AR_SPECS,
                   widget=atapi.SelectionWidget(
                       label=_("Default AR Specifications"),
                       description=_("DefaultARSpecs_description"),
                       format='select',
                   )),
 atapi.BooleanField(
     'DefaultDecimalMark',
     schemata="Preferences",
     default=True,
     widget=atapi.BooleanWidget(
         label=_("Default decimal mark"),
         description=_(
             "The decimal mark selected in Bika Setup will be used."),
     )),
 atapi.StringField(
     'DecimalMark',
     schemata="Preferences",
     vocabulary=DECIMAL_MARKS,
Exemplo n.º 9
0
     searchable=True,
     widget=atapi.StringWidget(label=_("Client ID"), ),
 ),
 atapi.BooleanField(
     'MemberDiscountApplies',
     default=False,
     write_permission=ManageClients,
     widget=atapi.BooleanWidget(label=_("Member discount applies"), ),
 ),
 atapi.StringField(
     'ClientType',
     required=1,
     default='noncorporate',
     write_permission=ManageClients,
     vocabulary=CLIENT_TYPES,
     widget=atapi.SelectionWidget(label=_("Client Type"), ),
 ),
 atapi.LinesField(
     'EmailSubject',
     schemata=PMF('Preferences'),
     default=[
         'ar',
     ],
     vocabulary=EMAIL_SUBJECT_OPTIONS,
     widget=atapi.MultiSelectionWidget(
         description=_('Items to be included in email subject lines'),
         label=_("Email subject line"),
     ),
 ),
 atapi.ReferenceField(
     'DefaultCategories',
Exemplo n.º 10
0
from Products.Archetypes import atapi
from Products.ATContentTypes.content.folder import ATFolder
from eea.relations.events import ObjectInitializedEvent
from Products.TALESField import TALESString

from eea.relations.content.interfaces import IContentType

EditSchema = ATFolder.schema.copy() + atapi.Schema((
    atapi.StringField(
        'ct_type',
        schemata="default",
        vocabulary_factory='eea.relations.voc.PortalTypesVocabulary',
        validators=('eea.relations.contenttype', ),
        widget=atapi.SelectionWidget(
            label='Portal type',
            label_msgid='widget_portal_type_title',
            description='Select portal type',
            description_msgid='widget_portal_type_description',
            i18n_domain="eea")),
    atapi.StringField('ct_interface',
                      schemata="default",
                      vocabulary_factory='eea.relations.voc.ObjectProvides',
                      validators=('eea.relations.contenttype', ),
                      widget=atapi.SelectionWidget(
                          label='Interface',
                          label_msgid='widget_interface_title',
                          description='Select interface',
                          description_msgid='widget_interface_description',
                          i18n_domain="eea")),
    TALESString(
        'ct_default_location',
        schemata="default",
Exemplo n.º 11
0
 # -*- Your Archetypes field definitions here ... -*-
 atapi.StringField(
     'address',
     storage=atapi.AnnotationStorage(),
     widget=atapi.StringWidget(
         label=_(u"Address"),
         description=_(u"Organization's address"),
     ),
     required=False,
     searchable=1,
 ),
 atapi.StringField(
     'country',
     storage=atapi.AnnotationStorage(),
     widget=atapi.SelectionWidget(
         label=_(u"Country"),
         description=_(u"Organization's country"),
     ),
     vocabulary_factory='contacts.countries',
     required=False,
     searchable=1,
 ),
 atapi.StringField(
     'state',
     storage=atapi.AnnotationStorage(),
     widget=atapi.SelectionWidget(
         label=_(u"State"),
         description=_(u"Organization's state"),
     ),
     vocabulary_factory='contacts.states',
     required=False,
     searchable=1,
Exemplo n.º 12
0
         label=_(u'amount_label', default=u'Amount'),
         description=_(
             u'amount_help',
             default=
             u"Insert the amount of remuneration (the amount is meant in Euro, format X.YY)"
         ),
         size=40,
     ),
 ),
 atapi.StringField(
     'amount_type',
     required=True,
     vocabulary='amountTypeVocab',
     widget=atapi.SelectionWidget(
         label=_(u'amount_type', default=u'Amount type'),
         description=_(u'amount_type_help',
                       default=u"Select the type of amount"),
     ),
 ),
 atapi.StringField(
     'norm',
     required=True,
     storage=atapi.AnnotationStorage(migrate=True),
     vocabulary='normVocabulary',
     widget=atapi.SelectionWidget(
         label=_(u'norm_label', default=u'Norm'),
         description=_(
             u'norm_help',
             default=u"Insert a short text to describe the norm."),
     ),
 ),
_opportunityTypes = (
    (_(u'Request for Application'), u'RFA'),
    (_(u'Program Announcement'), u'PA'),
    (_(u'Notice'), u'Notice'),
)

FundingOpportunitySchema = folder.ATFolderSchema.copy() + atapi.Schema((
    atapi.StringField(
        'opportunityType',
        required=True,
        enforceVocabulary=True,
        vocabulary_display_path_bound=-1,
        vocabulary_factory=u'edrnsite.funding.OpportunityTypeVocabulary',
        storage=atapi.AnnotationStorage(),
        widget=atapi.SelectionWidget(
            label=_(u'Opportunity Type'),
            description=_(u'The kind of opportunity being made available'),
        ),
    ),
    atapi.BooleanField(
        'reissuable',
        required=False,
        storage=atapi.AnnotationStorage(),
        widget=atapi.BooleanWidget(
            label=_(u'Reissuable'),
            description=
            _(u'True if this funding opportunity may be reissued, false otherwise.'
              ),
        ),
    ),
))
FundingOpportunitySchema['title'].storage = atapi.AnnotationStorage()
Exemplo n.º 14
0
from Products.DataGridField import DataGridField, DataGridWidget
from Products.DataGridField.Column import Column
from zope.component import getUtility
from zope.interface import implements
from plone.app.blob.field import FileField
from zope.schema.interfaces import IVocabularyFactory
from plone.app.folder.folder import ATFolder, ATFolderSchema
from mpdg.govbr.observatorio import MessageFactory as _
from mpdg.govbr.observatorio.config import PROJECTNAME
from mpdg.govbr.observatorio.content.interfaces import IBoaPratica

BoaPratica_schema = ATFolderSchema.copy() + atapi.Schema((
    atapi.StringField(
        name='esfera',
        default=u'federal',
        widget=atapi.SelectionWidget(label=_(u"Essa prática é esfera"), ),
        required=True,
        vocabulary='vocEsfera',
    ),
    atapi.StringField(
        name='uf',
        title=u'UF',
        widget=atapi.SelectionWidget(label=_(u"UF"), ),
        required=False,
        vocabulary="vocBrasilEstados",
    ),
    atapi.StringField(
        name='orgparticipantes',
        widget=atapi.StringWidget(label=_(u"Órgãos participantes"), ),
        required=False,
    ),
Exemplo n.º 15
0
            label='Nota',
        ),
    ),


    atapi.BooleanField(
        name='monitorar',
        widget=atapi.BooleanWidget(
            label='Monitorar',
        ),
    ),

    atapi.LinesField(
        name='vcg',
        widget=atapi.SelectionWidget(
            label="Vocabulário Controlado",
            description="Selecione uma opção.",
        ),
        enforceVocabulary=True,
        vocabulary=NamedVocabulary("""vcg"""),
        required=True,
        searchable=True,
    ),

    atapi.LinesField(
        name='abrangencia',
        widget=atapi.InAndOutWidget(
            label="Abrangência",
            description="Selecione uma ou mais opções.",
        ),
        enforceVocabulary=True,
        vocabulary=NamedVocabulary("""abrangencia"""),
Exemplo n.º 16
0
    atapi.BooleanField(
        name='redirect',
        widget=atapi.BooleanWidget(
            description=_(
                "help_redirect",
                default="If checked the feed item will be automatically "
                "redirected if you don't have the edit permission."),
            label=_('label_redirect',
                    default='Automatic redirect of feed items'))),
    atapi.StringField(
        name='defaultTransition',
        vocabulary='getAvailableTransitions',
        widget=atapi.SelectionWidget(
            format='select',
            description=_(
                'help_default_transition',
                default="When updating this feed's item the transition "
                "selected below will be performed."),
            label=_('label_default_transition', default='Default transition'),
        )),
), )

FeedfeederFolder_schema = ATBTreeFolder.schema.copy() + \
    schema.copy()


class FeedfeederFolder(ATBTreeFolder):
    """
      Verify class test
      >>> from zope.interface.verify import verifyClass
      >>> verifyClass(IFeedsContainer, FeedfeederFolder)
      True
Exemplo n.º 17
0
        for brain in brains:
            ct_to = brain.Title
            break

        value = '%s -> %s' % (ct_from, ct_to)
        return value, {}

RelationSchema = atapi.Schema((
    atapi.StringField('from',
        schemata="default",
        vocabulary_factory='eea.relations.voc.ContentTypes',
        required=True,
        widget=atapi.SelectionWidget(
            format='select',
            label='From',
            label_msgid='widget_from_title',
            description='Select content-type',
            description_msgid='widget_from_description',
            i18n_domain="eea"
        )
    ),
    atapi.StringField('to',
        schemata="default",
        vocabulary_factory='eea.relations.voc.ContentTypes',
        required=True,
        widget=atapi.SelectionWidget(
            format='select',
            label='To',
            label_msgid='widget_to_title',
            description='Select content-type',
            description_msgid='widget_to_description',
            i18n_domain="eea"
Exemplo n.º 18
0
class ProductSchemaExtender(object):

    _fields = [
        ExtendedStringField(
            schemata='shop',
            name='product_category',
            required=False,
            enforceVocabulary=True,
            vocabulary_factory='jazkarta.shop.product_categories',
            widget=atapi.SelectionWidget(
                label="Product Category",
                description="Select a product category",
                description_msgid='help_product_category',
            )),
        ExtendedFixedPointField(
            schemata='shop',
            name='price',
            default="0.00",
            #        min=Decimal("0.00"),
            widget=atapi.DecimalWidget(
                label="Unit Price",
                description="",
                description_msgid='help_price',
            )),
        ExtendedIntegerField(
            schemata='shop',
            name='stock_level',
            required=False,
            #            min=0,
            widget=atapi.IntegerWidget(
                label="Stock Level",
                description=
                "Number of items remaining in warehouse. Leave blank for no limit.",
                description_msgid='help_stock_level',
            )),
        ExtendedBooleanField(
            schemata='shop',
            name='taxable',
            widget=atapi.BooleanWidget(
                label="Taxable?",
                description=
                "Mark the box if this product is subject to sales tax.",
                description_msgid='help_taxable',
            ),
            default=True,
        ),
        ExtendedFloatField(schemata='shop',
                           name='weight',
                           required=False,
                           widget=atapi.StringWidget(
                               label="Weight (lbs)",
                               description="Used to calculate shipping.",
                               description_msgid='help_weight',
                           ))
    ]

    def __init__(self, context):
        self.context = context

    def getFields(self):
        return self._fields
Exemplo n.º 19
0
periodVocabulary = atapi.DisplayList((
    ('today', _(u'Today')),
    ('this_month', _(u'This month')),
    ('this_year', _(u'This year')),
))

PeriodCriteriaSchema = ATBaseCriterionSchema + atapi.Schema((atapi.StringField(
    'period',
    required=1,
    write_permission=ChangeTopics,
    default='today',
    vocabulary=periodVocabulary,
    widget=atapi.SelectionWidget(
        label=_(u'label_date_criteria_value', default=u'Which period'),
        description=_(
            u'help_date_criteria_value',
            default=u'Select the period inside which the date must be.')),
), ))


class ATPeriodCriteria(ATBaseCriterion):
    """A relative date criterion"""

    implements(IATPeriodCriteria)

    security = ClassSecurityInfo()
    schema = PeriodCriteriaSchema
    meta_type = 'ATPeriodCriteria'
    archetype_name = 'Period Date Criteria'
    shortDesc = _(u'Period of time')
Exemplo n.º 20
0
            i18n_domain='EasyNewsletter',
            size=10,
        )
    ),

    atapi.StringField(
        'subscriberSource',
        schemata='settings',
        vocabulary="get_subscriber_sources",
        default='default',
        widget=atapi.SelectionWidget(
            label=_(
                u"EasyNewsletter_label_externalSubscriberSource",
                default="External subscriber source"),
            description=_(
                u"EasyNewsletter_help_externalSubscriberSource",
                default=u"Some packages provide an external subscriber source \
                    for EasyNewsletter. If one is installed you can \
                    choose it here."),
            i18n_domain='EasyNewsletter',
            size=10,
        )
    ),

    atapi.StringField(
        'deliveryService',
        schemata='settings',
        vocabulary="get_delivery_services",
        default='mailhost',
        widget=atapi.SelectionWidget(
            label=_(
                u"EasyNewsletter_label_externalDeliveryService",
Exemplo n.º 21
0
from zope.interface import implements

OVERBOOKED_MESSAGE = _(
    'overbook_message',
    default=u"Siamo spiacenti, è già stato preso un appuntamento "
    u"nella stessa fascia oraria, premere il pulsante "
    u"ANNULLA per effettuare una nuova richiesta di "
    u"prenotazione")

PrenotazioneSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
    atapi.StringField(
        'tipologia_prenotazione',
        storage=atapi.AnnotationStorage(),
        vocabulary='getElencoTipologie',
        widget=atapi.SelectionWidget(
            label=_(u"Tipologia della prenotazione"),
            condition='object/getElencoTipologie',
        ),
        required=False,
    ),
    atapi.DateTimeField(
        'data_prenotazione',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u'Data prenotazione'),
            visible={
                'edit': 'hidden',
                'view': 'visible'
            },
        ),
        required=True,
    ),
Exemplo n.º 22
0
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,
    ),
))

schemata.finalizeATCTSchema(JazShopSelectFieldSchema, moveDiscussion=False)


def get_available_products_vocab(context):
    terms = []
    products = context.portal_catalog(
        object_provides=IProduct.__identifier__,
        sort_on='sortable_title',
        sort_order='ascending')
    for product in products:
        terms.append(SimpleTerm(
Exemplo n.º 23
0
    'IntegerField', 'FloatField', 'FixedPointField', 'BooleanField',
    'ImageField'
]

field_instances = []

for f in fields:
    field_instances.append(getattr(Field, f)(f.lower()))

schema = atapi.Schema(
    tuple(field_instances) + (
        atapi.LinesField(
            'selectionlinesfield1',
            vocabulary='_get_selection_vocab',
            enforceVocabulary=1,
            widget=atapi.SelectionWidget(label='Selection'),
        ),
        atapi.LinesField(
            'selectionlinesfield2',
            vocabulary='_get_selection_vocab',
            widget=atapi.SelectionWidget(label='Selection',
                                         i18n_domain="attesti18n"),
        ),
        atapi.LinesField(
            'selectionlinesfield3',
            vocabulary='_get_selection_vocab2',
            widget=atapi.MultiSelectionWidget(label='MultiSelection',
                                              i18n_domain="attesti18n"),
        ),
        atapi.TextField(
            'textarea_appendonly',
Exemplo n.º 24
0
    ),

    #sub-classes that use this schema may alter this field
    # to use a selection widget and a vocabulary
    # if not, it's a simple string field where you type in the playerId (aka ui_conf) manually.
    atapi.StringField(
        'playerId',
        searchable=0,
        accessor="getPlayer",
        mutator="setPlayer",
        mode='rw',
        default_method="getDefaultPlayerId",
        vocabulary_factory="rfa.kaltura.video_players",
        widget=atapi.SelectionWidget(label="Player",
                                     label_msgid="label_kplayerid_msgid",
                                     description="Choose the player to use",
                                     description_msgid="desc_kplayerid_msgid",
                                     i18n_domain="kaltura_video"),
    ),
    atapi.StringField(
        'partnerId',
        searchable=0,
        mode='rw',
        default_method="getDefaultPartnerId",
        widget=atapi.StringWidget(
            label="Partner Id",
            label_msgid="label_kpartnerid_msgid",
            description="Kaltura Partner Id (use default if unsure)",
            description_msgid="desc_kpartnerid_msgid",
            i18n_domain="kaltura_video"),
    ),
Exemplo n.º 25
0
                                SharepointChoiceColumn,)
from msgraph.drives import Drive

from collective.pfgsharepoint import _, PROJECTNAME
from collective.pfgsharepoint.utils import getClient

logger = logging.getLogger('collective.pfgsharepoint')

SharePointAdapterSchema = FormAdapterSchema.copy() + atapi.Schema((
    atapi.StringField('sharepoint_tenant',
                      required=True,
                      write_permission=ModifyPortalContent,
                      read_permission=ModifyPortalContent,
                      vocabulary_factory="collective.pfgsharepoint.vocabularies.SharepointTenants",
                      widget=atapi.SelectionWidget(
                          label=u'SharePoint Tenant',
                      )),
    atapi.StringField('sharepoint_site',
                      required=False,
                      write_permission=ModifyPortalContent,
                      read_permission=ModifyPortalContent,
                      vocabulary='getSites',
                      widget=atapi.SelectionWidget(
                          label=u'SharePoint Site ID',
                      )),
    atapi.StringField('sharepoint_list',
                      required=False,
                      write_permission=ModifyPortalContent,
                      read_permission=ModifyPortalContent,
                      vocabulary='getLists',
                      widget=atapi.SelectionWidget(
Exemplo n.º 26
0
TaskRequestSchema = folder.ATFolderSchema.copy() + atapi.Schema((
    atapi.StringField(
        'agencyContact',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"Agency contact person"),
            description=
            _(u"The contact details of people within the agency who can be contacted regarding this task."
              ),
        ),
    ),
    atapi.StringField('priority',
                      storage=atapi.AnnotationStorage(),
                      widget=atapi.SelectionWidget(
                          label=_(u"Priority"),
                          description=_(u"The priority of this task."),
                          format="select",
                      ),
                      default=_(u"Medium"),
                      vocabulary=["High", "Medium", "Low"]),
    atapi.DateTimeField(
        'dueDate',
        storage=atapi.AnnotationStorage(),
        widget=atapi.CalendarWidget(
            label=_(u"Due Date"),
            show_hm=False,
            show_ymd=True,
            starting_year=datetime.now().year,
            description=_(u"The date that this task must completed"),
        ),
    ),
     widget=atapi.TextAreaWidget(
         label=_(u"label_psc_description", default=u"Description"),
         description=_(u"help_psc_description", default=u""),
         i18n_domain='ploneservicescenter',
     ),
     required=1,
     searchable=1,
 ),
 atapi.StringField(
     'country',
     vocabulary=country.vocab,
     validateVocabulary=True,
     countries=country.countries,
     widget=atapi.SelectionWidget(
         label=_(u"label_psc_country_cat", default=u"Country"),
         description=_(u"help_services_country",
                       default=u"Select a country"),
         i18n_domain='ploneservicescenter',
         macro_edit="country_widget"),
     required=0,
     index=('KeywordIndex:schema', ),
 ),
 atapi.LinesField(
     'industry',
     validators=IndustriesValidator('validateIndustries'),
     widget=atapi.MultiSelectionWidget(
         label=_(u"label_psc_industry_cat", default=u"Industry"),
         description=_(u"help_services_industry",
                       default=u"Select a industry from the below list."),
         i18n_domain='ploneservicescenter',
     ),
     required=0,
Exemplo n.º 28
0
     'attendeesCanEdit',
     storage=atapi.AnnotationStorage(),
     widget=atapi.BooleanWidget(
         label=_(u"Allow Attendees to Edit?"),
         description=
         _(u"If checked, allows listed attendees to edit this Meeting object and add/edit contained items"
           ),
     ),
     default=True,
 ),
 atapi.StringField(
     'notifyAttendeesByEmail',
     storage=atapi.AnnotationStorage(),
     widget=atapi.SelectionWidget(
         label=_(u"Notify Attendees by Email?"),
         description=
         _(u"Select which type of email notification to send to listed attendees"
           ),
     ),
     required=True,
     default=_(u"None"),
     vocabulary=[
         'None',
         'One-time only',
         'On every edit',
     ],
 ),
 atapi.ReferenceField(name='previousMeeting',
                      widget=atapi.ReferenceWidget(
                          label='Previous Meeting', ),
                      allowed_types=('Meeting', ),
                      multiValued=0,
Exemplo n.º 29
0
from gcommons.Core import CoreMessageFactory as _
from gcommons.Core.interfaces import IComment
from gcommons.Core.config import PROJECTNAME

CommentSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
    atapi.ComputedField('title',
                        searchable=1,
                        expression='context._compute_title()',
                        accessor='Title'),
    atapi.StringField(
        'commentType',
        widget=atapi.SelectionWidget(
            label="Type",
            description=
            "Describe correctly the type of comment. Different types will be visible for different users.",
            label_msgid="gcommons_comment_type",
            description_msgid="gcommons_help_comment_type",
        ),
        required=True,
        vocabulary="getCommentTypesVocabulary",
        searchable=True),
    atapi.ReferenceField('refDraft',
                         relationship='refDraft',
                         multiValued=False,
                         default_method='getDefaultRefDraft',
                         widget=ReferenceBrowserWidget(visible={
                             'edit': 'invisible',
                             'view': 'visible'
                         })),
    atapi.TextField(
Exemplo n.º 30
0
class LaTeXCodeInjectionExtender(object):
    adapts(ILaTeXCodeInjectionEnabled)
    implements(IOrderableSchemaExtender)

    _fields = []

    add_field(LaTeXCodeField(
            name='preLatexCode',
            schemata='LaTeX',
            default_content_type='text/plain',
            allowable_content_types='text/plain',
            write_permission=ModifyLaTeXInjection,

            widget=atapi.TextAreaWidget(
                label=_(u'pre_latex_code_label',
                        default=u'LaTeX code above content'),
                description=_(u'pre_latex_code_help',
                              default=u''))))

    add_field(LaTeXCodeField(
            name='postLatexCode',
            schemata='LaTeX',
            default_content_type='text/plain',
            allowable_content_types='text/plain',
            write_permission=ModifyLaTeXInjection,

            widget=atapi.TextAreaWidget(
                label=_(u'post_latex_code_label',
                        default=u'LaTeX code beneath content'),
                description=_(u'post_latex_code_help',
                              default=u''))))

    add_field(ExtensionStringField(
            name='preferredColumnLayout',
            schemata='LaTeX',
            default=NO_PREFERRED_LAYOUT,
            write_permission=ModifyLaTeXInjection,
            vocabulary=((NO_PREFERRED_LAYOUT,
                         _('injection_label_no_preferred_column_layout',
                           default='No preferred column layout')),

                        (ONECOLUMN_LAYOUT,
                         _('injection_label_one_column_layout',
                           default='One column layout')),

                        (TWOCOLUMN_LAYOUT,
                         _('injection_label_two_column_layout',
                           default='Two column layout'))),

            widget=atapi.SelectionWidget(
                label=_(u'injection_label_preferred_column_layout',
                        default=u'Preferred layout'),
                description=_(
                    u'injection_help_preferred_column_layout',
                    default=u'When choosing a one or two column layout, the '
                    u'layout will switched for this content and all '
                    u'subsequent contents in the PDF, if necessary. '
                    u'If "no preferred layout" is selected the currently '
                    u'active layout is kept.'))))

    add_field(
        interfaces=[IChapter, ISimpleLayoutBlock],
        field=ExtensionBooleanField(
            name='latexLandscape',
            schemata='LaTeX',
            default=False,
            write_permission=ModifyLaTeXInjection,

            widget=atapi.BooleanWidget(
                label=_(u'injection_label_landscape',
                        default=u'Use landscape'))))

    add_field(
        interfaces=[IChapter, ISimpleLayoutBlock],
        field=ExtensionBooleanField(
            name='preLatexClearpage',
            schemata='LaTeX',
            default=False,
            write_permission=ModifyLaTeXInjection,

            widget=atapi.BooleanWidget(
                label=_(u'injection_label_insert_clearpage_before_content',
                        default=u'Insert page break before this content'))))

    add_field(
        interfaces=[IChapter, ISimpleLayoutBlock],
        field=ExtensionBooleanField(
            name='postLatexClearpage',
            schemata='LaTeX',
            default=False,
            write_permission=ModifyLaTeXInjection,

            widget=atapi.BooleanWidget(
                label=_(u'injection_label_insert_clearpage_after_content',
                        default=u'Insert page break after this content'))))

    add_field(
        interfaces=[IChapter, ISimpleLayoutBlock],
        field=ExtensionBooleanField(
            name='preLatexNewpage',
            schemata='LaTeX',
            default=False,
            write_permission=ModifyLaTeXInjection,

            widget=atapi.BooleanWidget(
                label=_(u'injection_label_insert_newpage_before_content',
                        default=u'Insert column break before this content'),
                description=_(u'This option inserts a column break when '
                              u'two column layout is active.'))))

    add_field(
        # hideFromTOC is only useful when we have a showTitle checkbox too
        condition=hide_from_toc_condition,
        insert_after='showTitle',
        field=ExtensionBooleanField(
            name='hideFromTOC',
            default=False,
            required=False,

            widget=atapi.BooleanWidget(
                label=_(u'injection_label_hide_from_toc',
                        default=u'Hide from table of contents'),
                description=_(u'injection_help_hide_from_toc',
                              default=u'Hides the title from the table of '
                              u'contents and does not number the heading.'))))

    def __init__(self, context):
        self.context = context

    def getFields(self):
        if not self._context_is_within_book():
            return []

        fields = []

        for item in self._fields:
            condition = item.get('condition')
            if condition and not condition(self.context):
                continue

            interfaces = item.get('interfaces')
            if interfaces:
                provided = [iface for iface in interfaces
                            if iface.providedBy(self.context)]
                if len(provided) == 0:
                    continue

            fields.append(item.get('field'))

        return fields

    def getOrder(self, schematas):
        for item in self._fields:
            insert_after = item.get('insert_after')
            if not insert_after:
                continue

            field = item.get('field')
            if field.schemata not in schematas:
                continue

            schemata = schematas[field.schemata]
            if insert_after not in schemata or field.__name__ not in schemata:
                continue

            schemata.remove(field.__name__)
            schemata.insert(schemata.index(insert_after) + 1, field.__name__)

        return schematas

    def _context_is_within_book(self):
        # In some cases REQUEST is no available.
        if not hasattr(self.context, 'REQUEST'):
            return False

        if IWithinBookLayer.providedBy(self.context.REQUEST):
            return True
        return False