class IBasic(model.Schema):

    # default fieldset
    title = schema.TextLine(
        title=_PMF(u'label_title', default=u'Title'),
        required=True
    )

    description = schema.Text(
        title=_PMF(u'label_description', default=u'Summary'),
        description=_PMF(
            u'help_description',
            default=u'Used in item listings and search results.'
        ),
        min_length=5,
        max_length=100,
        required=True,
        missing_value=u'',
    )

    directives.order_before(description='*')
    directives.order_before(title='*')

    directives.omitted('title', 'description')
    directives.no_omit(IEditForm, 'title', 'description')
    directives.no_omit(IAddForm, 'title', 'description')
Exemplo n.º 2
0
class IAnalyticBudget(model.Schema):
    """Budget field"""

    analytic_budget = schema.List(
        title=_(u"Analytic budget"),
        required=False,
        readonly=True,
        value_type=DictRow(title=_("Analytic budget"),
                           schema=IAnalyticBudgetSchema,
                           required=False),
    )
    form.widget("analytic_budget",
                AnalyticBudgetDataGridFieldFactory,
                display_table_css_class="listing nosort")

    projection = schema.List(
        title=_(u"Projection"),
        required=False,
        readonly=True,
        value_type=DictRow(title=_("Projection"),
                           schema=IProjectionSchema,
                           required=False),
    )
    form.widget("projection",
                ProjectionDataGridFieldFactory,
                display_table_css_class="listing nosort")

    form.order_before(projection='budget')
    form.order_before(analytic_budget='budget')
Exemplo n.º 3
0
class ISector(model.Schema, IUser, IBasic):
    """Sector object.

    A sector is a national organisation for a specific type of
    industry.
    """

    directives.order_before(title="*")
    directives.write_permission(title="euphorie.content.ManageCountry")

    directives.order_after(login="******")
    directives.write_permission(login="******")

    directives.order_before(password="******")

    directives.order_after(locked="password")
    directives.write_permission(locked="euphorie.content.ManageCountry")

    contact_name = schema.TextLine(
        title=_("label_contact_name", default="Contact name"), required=True
    )

    directives.order_after(contact_email="contact_name")

    logo = filefield.NamedBlobImage(
        title=_("label_logo", default="Logo"),
        description=_(
            "help_image_upload",
            default="Upload an image. Make sure your image is of format "
            "png, jpg or gif and does not contain any special "
            "characters. The minimum size is 1000 (width) x 430 (height) pixels.",
        ),
        required=False,
    )
Exemplo n.º 4
0
class IDocument(IProjectContent):
    """
    emc project  document content type
    """
    # self-defined title and description
#     title = schema.TextLine(
#         title=_(u'label_title', default=u'Title'),
#         required=True
#     )

    title = schema.Choice(
        title=_p(u'label_title'),
        source=DocTitle,
        required=True,
    )
    
    description = schema.Text(
        title=_p(u'label_description', default=u'Summary'),
        description=_p(
            u'help_description',
            default=u'Used in item listings and search results.'
        ),
        required=False,
        missing_value=u'',
    )
    
    directives.order_before(description='*')
    directives.order_before(title='*')

    directives.omitted('title', 'description')
    directives.no_omit(IEditForm, 'description')
    directives.no_omit(IAddForm, 'title', 'description')        
Exemplo n.º 5
0
class AddFormSchema(group_base.BaseAddFormSchema, VideoSchema):
    """Add form"""

    title = schema.TextLine(title=_(u"Title"))

    description = schema.Text(title=_(u"Description"), required=False)
    form.order_before(title='description')
    form.order_before(description='file')
Exemplo n.º 6
0
class ITranslatedTitle(model.Schema):
    """Behavior schema adding translated title fields to dexterity
    content.
    """

    form.order_before(title_de='*')
    searchable('title_de')
    title_de = TextLine(title=_(u'label_title_de', default=u'Title (German)'),
                        required=True)

    form.order_before(title_fr='*')
    searchable('title_fr')
    title_fr = TextLine(title=_(u'label_title_fr', default=u'Title (French)'),
                        required=True)
Exemplo n.º 7
0
class IRelatedContacts(model.Schema):

    form.order_before(location='IRichText.text')
    location = ContactChoice(
        title=_(u'Location'),
        source=ContactSourceBinder(portal_type=('organization', ), ),
        required=False,
    )

    form.order_after(organizer='IRelatedContacts.location')
    organizer = ContactChoice(
        title=_(u'Organizer'),
        source=ContactSourceBinder(portal_type=('person', 'organization'), ),
        required=False,
    )

    form.order_after(contact='IRelatedContacts.organizer')
    contact = ContactChoice(
        title=_(u'Contact'),
        source=ContactSourceBinder(portal_type=('person', 'organization'), ),
        required=False,
    )

    form.order_after(partners='IRelatedContacts.contact')
    partners = ContactList(
        title=_(u'Partners'),
        value_type=ContactChoice(title=_(u'Partner'),
                                 source=ContactSourceBinder(
                                     portal_type=('person',
                                                  'organization'), )),
        required=False,
    )
Exemplo n.º 8
0
class IOGMail(model.Schema):
    """Opengever specific behavior,
    which add a title Field to the form.
    """

    model.fieldset(u'common',
                   label=base_mf(u'fieldset_common', u'Common'),
                   fields=[u'title', 'original_message', 'message_source'])

    form.order_before(title='message')
    dexteritytextindexer.searchable('title')
    title = schema.TextLine(
        title=dossier_mf(u'label_title', default=u'Title'),
        required=False,
    )

    form.mode(original_message=DISPLAY_MODE)
    form.write_permission(original_message='cmf.ManagePortal')
    original_message = field.NamedBlobFile(
        title=_(u'label_original_message',
                default=u'Raw *.msg message before conversion'),
        required=False,
    )

    form.mode(message_source=DISPLAY_MODE)
    form.read_permission(message_source='cmf.ManagePortal')
    form.write_permission(message_source='cmf.ManagePortal')
    message_source = schema.Choice(
        title=_('label_message_source', default='Message source'),
        vocabulary=get_message_source_vocabulary(),
        required=False,
    )
Exemplo n.º 9
0
class IDocumentSchema(model.Schema):
    """Document Schema Interface."""

    model.fieldset(
        u'common',
        label=_(u'fieldset_common', u'Common'),
        fields=[
            u'title',
            u'file',
        ],
    )

    dexteritytextindexer.searchable('title')
    form.order_before(title='IDocumentMetadata.description')
    title = schema.TextLine(title=_(u'label_title', default=u'Title'),
                            required=False)

    model.primary('file')
    form.order_after(file='IDocumentMetadata.document_author')
    file = field.NamedBlobFile(
        title=_(u'label_file', default='File'),
        description=_(u'help_file', default=''),
        required=False,
    )

    @invariant
    def title_or_file_required(data):
        if not data.title and not data.file:
            raise Invalid(
                _(u'error_title_or_file_required',
                  default=u'Either the title or the file is '
                  'required.'))
Exemplo n.º 10
0
class IServiziCorrelati(model.Schema):

    servizi_correlati = RelationList(
        title=_("servizi_correlati_label", default="Servizi correlati"),
        description=_(
            "servizi_correlati_description",
            default="Questi servizi non verranno mostrati nel contenuto, ma"
            " permetteranno di vedere questo contenuto associato quando si"
            " visita il servizio",
        ),
        default=[],
        value_type=RelationChoice(
            title="Related", vocabulary="plone.app.vocabularies.Catalog"
        ),
        required=False,
    )
    form.widget(
        "servizi_correlati",
        RelatedItemsFieldWidget,
        vocabulary="plone.app.vocabularies.Catalog",
        pattern_options={
            "maximumSelectionSize": 10,
            "selectableTypes": ["Servizio"],
        },
    )

    model.fieldset(
        "correlati",
        label=_("correlati_label", default="Contenuti collegati"),
        fields=["servizi_correlati"],
    )
    form.order_before(servizi_correlati="IRelatedItems.relatedItems")
Exemplo n.º 11
0
class IExistingTileSchema(IContentTileSchema):

    form.order_before(title='use_query')
    title = schema.TextLine(title=u'Title heading',
                            description=u'Will be omitted if blank',
                            required=False,
                            default=u'')

    form.widget('display_fields', CheckBoxFieldWidget)
    display_fields = schema.Tuple(
        title=u'Display fields',
        description=u'Fields that should show from the content',
        default=('title', 'image', 'description'),
        value_type=schema.Choice(vocabulary=SimpleVocabulary([
            SimpleTerm('title', 'title', u'Title'),
            SimpleTerm('image', 'image', u'Image'),
            SimpleTerm('description', 'description', u'Overview/Summary'),
            SimpleTerm('date', 'date', u'Date'),
        ])))

    truncate_count = schema.Int(
        title=u'Overview/Summary Truncate',
        description=u'Number of words to truncate the overview/summary to',
        required=False,
        default=18)

    image_display_type = schema.Choice(
        title=u'Image display type',
        description=u'Does not apply to all display types',
        required=True,
        default=u'landscape',
        vocabulary=SimpleVocabulary([
            SimpleTerm('landscape', 'landscape', u'Landscape'),
            SimpleTerm('portrait', 'portrait', u'Portrait'),
            SimpleTerm('square', 'square', u'Square')
        ]))

    display_type = schema.Choice(title=u"Display Type",
                                 vocabulary=SimpleVocabulary([
                                     SimpleTerm('basic', 'basic', u'Basic'),
                                     SimpleTerm('backgroundimage',
                                                'backgroundimage',
                                                u'Background Image')
                                 ]),
                                 default='basic')

    form.widget('display_type',
                PreviewSelectFieldWidget,
                tile_name=DISPLAY_TYPE_KEY)
    display_type = schema.Choice(title=u"Display Type",
                                 source=TileViewsSource(DISPLAY_TYPE_KEY),
                                 default='default')

    form.widget(override_focal_point=FocalPointSelectFieldWidget)
    override_focal_point = schema.Text(title=u'Override Focal point',
                                       default=u'',
                                       required=False)
Exemplo n.º 12
0
class AddFormSchema(model.Schema):
    directives.order_before(where='what')
    where = schema.Choice(
        title=_(u"Where"),
        description=_(u"Warning, only groups can be added into Home"),
        vocabulary="collective.rcse.vocabulary.groups_with_home")
    what = schema.Choice(title=_(u"What"),
                         vocabulary="collective.rcse.vocabulary.addableTypes",
                         default="collective.rcse.group")
Exemplo n.º 13
0
class IGroupsProvider(Interface):
    """Behavior schema
    """
    order_before(groups='columns_display')
    groups = schema.List(title=_(u'Groups'),
                         description=_('roster_groups_help',
                                       default=u'group_id|Group title'),
                         value_type=schema.TextLine(title=_(u'Group'),
                                                    required=True),
                         required=False)
Exemplo n.º 14
0
class IArgomentiBando(IArgomentiSchema):
    """ """

    model.fieldset(
        "correlati",
        label=_("correlati_label", default="Contenuti collegati"),
        fields=["tassonomia_argomenti", "correlato_in_evidenza"],
    )
    form.order_before(tassonomia_argomenti="IRelatedItems.relatedItems")
    form.order_after(correlato_in_evidenza="IRelatedItems.relatedItems")
Exemplo n.º 15
0
class IBasic(model.Schema):
    # default fieldset
    title = schema.TextLine(title=_PMF(u'label_title', default=u'Title'),
                            required=True)

    description = schema.Text(
        title=_PMF(u'label_description', default=u'Description'),
        description=_PMF(u'help_description',
                         default=u'A short summary of the content.'),
        required=False,
        missing_value=u'',
    )

    form.order_before(description='*')
    form.order_before(title='*')

    form.omitted('title', 'description')
    form.no_omit(IEditForm, 'title', 'description')
    form.no_omit(IAddForm, 'title', 'description')
Exemplo n.º 16
0
        class IDummy(model.Schema):

            form.omitted('foo')
            form.omitted('bar')
            form.widget(foo='some.dummy.Widget')
            form.widget(baz='other.Widget')
            form.mode(bar='hidden')
            form.mode(foo='display')
            form.order_before(baz='title')
            form.order_after(baz='qux')
            form.order_after(qux='bar')
            form.order_before(foo='body')
            form.read_permission(foo='zope2.View', bar='zope2.View')
            form.read_permission(baz='random.Permission')
            form.write_permission(foo='cmf.ModifyPortalContent')
            form.write_permission(baz='another.Permission')

            foo = zope.schema.TextLine(title=u'Foo')
            bar = zope.schema.TextLine(title=u'Bar')
            baz = zope.schema.TextLine(title=u'Baz')
            qux = zope.schema.TextLine(title=u'Qux')
Exemplo n.º 17
0
class IPaginaDestaque(model.Schema):
    """Behavior adding a two-line title, a description and a links field
    """

    title_1 = schema.TextLine(
        title=_(u'label_title_1', default=u'Title 1'),
        required=True
    )

    title_2 = schema.TextLine(
        title=_(u'label_title_2', default=u'Title 2'),
        required=True
    )

    description = schema.Text(
        title=_(u'label_description', default=u'Summary'),
        description=_(
            u'help_description',
            default=u'Used in item listings and search results.'
        ),
        required=False,
        missing_value=u'',
    )

    form.widget(links=DataGridFieldFactory)
    links = schema.List(
        title=_(u'Footer links'),
        value_type=DictRow(title=_(u'Link'), schema=ILinkRow),
        required=False,
    )

    form.order_before(links='*')
    form.order_before(description='*')
    form.order_before(title_2='*')
    form.order_before(title_1='*')

    form.omitted('title_1', 'title_2', 'description', 'links')
    form.no_omit(IEditForm, 'title_1', 'title_2', 'description', 'links')
    form.no_omit(IAddForm, 'title_1', 'title_2', 'description', 'links')
Exemplo n.º 18
0
class ISetTitleOnly(model.Schema):
    """
       Marker/Form interface for SetTitleOnly
    """

    # -*- Your Zope schema definitions here ... -*-
    title = schema.TextLine(title=_(u'label_title', default=u'Title'),
                            required=True)

    form.order_before(title='*')

    form.omitted('title')
    form.no_omit(IEditForm, 'title')
    form.no_omit(IAddForm, 'title')
Exemplo n.º 19
0
        class IDummy(model.Schema):

            form.omitted('foo', 'bar')
            form.omitted(model.Schema, 'qux')
            form.no_omit(model.Schema, 'bar')
            form.widget(foo='some.dummy.Widget', baz='other.Widget')
            form.mode(bar='hidden')
            form.mode(model.Schema, bar='input')
            form.order_before(baz='title')
            form.order_after(qux='title')
            form.read_permission(foo='zope2.View')
            form.write_permission(foo='cmf.ModifyPortalContent')

            foo = zope.schema.TextLine(title=u'Foo')
            bar = zope.schema.TextLine(title=u'Bar')
            baz = zope.schema.TextLine(title=u'Baz')
            qux = zope.schema.TextLine(title=u'Qux')
Exemplo n.º 20
0
class IRizzoTheRatTile(ISocialContact, Interface):

    title = schema.TextLine(
        title=_(u"Title"),
        required=False
    )

    directions = schema.TextLine(
        title=_(u"Directions"),
        required=False,
    )

    hours = schema.TextLine(
        title=_(u"Hours"),
        required=False,
    )

    form.order_before(title='*')
Exemplo n.º 21
0
class IContact(IPrivateContactInformations, IContactInformations, IAddress):
    """ """

    directives.order_before(type="IBasic.title")
    directives.widget(type=RadioFieldWidget)
    type = schema.Choice(
        title=_("Type"),
        source="imio.directory.vocabulary.ContactTypes",
        required=True,
    )

    directives.order_after(subtitle="IBasic.title")
    subtitle = schema.TextLine(title=_("Subtitle"), required=False)

    logo = NamedBlobImage(title=_("Logo"), description=_(""), required=False)

    model.fieldset("categorization",
                   fields=["selected_entities", "facilities"])
    directives.widget(selected_entities=SelectFieldWidget)
    selected_entities = schema.List(
        title=_("Selected entities"),
        description=
        _("Select entities where this contact will be displayed. Current entity will always be selected."
          ),
        value_type=schema.Choice(
            vocabulary="imio.directory.vocabulary.EntitiesUIDs"),
        default=[],
        required=False,
    )

    facilities = schema.List(
        title=_("Facilities"),
        description=
        _("Important! These categories make it possible to highlight and geolocate certain basic services"
          ),
        value_type=schema.Choice(
            vocabulary="imio.directory.vocabulary.Facilities"),
        required=False,
    )
    directives.widget(facilities=SelectFieldWidget)

    read_permission(selected_entities="imio.directory.core.AddEntity")
    write_permission(selected_entities="imio.directory.core.AddEntity")
Exemplo n.º 22
0
class IDynamicUsers(model.Schema):
    
    model.fieldset(
        'settings',
        label=_p(u"Settings"),
        fields=['users']
    )    
    
    form.order_before(users='ITableOfContents.table_of_contents')
    form.write_permission(users='emc.project.add_team')
    users = schema.Tuple(
        title=_(u"Workflow setting"),
        description=_(u"Workflow next processor"),
        value_type=schema.TextLine(),
        required=False,
        missing_value=(), # important!
    )

    form.widget('users',AjaxSelectFieldWidget,vocabulary='plone.principalsource.Users')
Exemplo n.º 23
0
class ISurveyGroup(model.Schema, IBasic):
    title = schema.TextLine(
        title=_("label_title", default="Title"),
        description=_(
            "help_surveygroup_title",
            default="The title of this OiRA Tool. This title is used in "
            "the OiRA Tool overview in the clients.",
        ),
        required=True,
    )
    directives.order_before(title="*")

    directives.omitted("description")

    obsolete = schema.Bool(
        title=_("label_survey_obsolete", default="Obsolete OiRA tool"),
        description=_(
            "help_survey_obsolete",
            default="This OiRA Tool is obsolete; it has been retired or "
            "replaced with another OiRA Tool.",
        ),
        default=False,
        required=False,
    )

    directives.omitted(IEditForm, "evaluation_algorithm")
    evaluation_algorithm = schema.Choice(
        title=_("label_survey_evaluation_algorithm",
                default="Evaluation algorithm"),
        vocabulary=SimpleVocabulary([
            SimpleTerm(
                "kinney",
                title=_("algorithm_kinney", default="Standard three criteria"),
            ),
            SimpleTerm("french",
                       title=_("french", default="Simplified two criteria")),
        ]),
        default="kinney",
        required=True,
    )
Exemplo n.º 24
0
class IForwarding(ITask):
    """Schema interface for forwardings.
    """

    # common fieldset
    form.omitted('task_type')

    # only hide relatedItems - we need it for remembering which documents
    # should be moved after creation when creating forwarding from tabbed view.
    form.mode(relatedItems=HIDDEN_MODE)

    # additional fieldset
    form.omitted('expectedStartOfWork')
    form.omitted('expectedDuration')
    form.omitted('expectedCost')
    form.omitted('effectiveDuration')
    form.omitted('effectiveCost')

    # only hide date_of_completion, it's used
    form.mode(date_of_completion=HIDDEN_MODE)

    # make sure hidden field is not rendered in its own empty fieldset by
    # moving it to the form's first position before title
    form.order_before(date_of_completion='title')

    # deadline is not required
    deadline = schema.Date(
        title=task_mf(u"label_deadline", default=u"Deadline"),
        description=task_mf(u"help_deadline", default=u""),
        required=False,
    )

    form.widget('responsible', KeywordFieldWidget, async=True)
    responsible = schema.Choice(
        title=_(u"label_responsible", default=u"Responsible"),
        description=_(u"help_responsible", default=""),
        source=AllUsersInboxesAndTeamsSourceBinder(
            only_current_orgunit=True, include_teams=True),
        required=True,
    )
class ICollectionBlockSchema(model.Schema):
    """Collection block for simplelayout
    """

    title = schema.TextLine(
        title=_(u'collectionblock_title_label', default=u'Title'),
        required=True,
    )

    directives.order_before(title='*')

    show_title = schema.Bool(
        title=_(u'collectionblock_show_title_label', default=u'Show title'),
        default=False,
        required=False,
    )

    directives.order_after(show_title='title')

    block_amount = schema.Int(
        title=_(u'label_block_amount', default=u'Amount of entries on block'),
        default=5,
        required=False)

    show_rss_link = schema.Bool(
        title=_(u'label_show_rss_link',
                default=u'Link to RSS feed'),
        default=False,
    )

    show_more_link = schema.Bool(
        title=_(u'label_show_more_link', default=u'Show "more" link'),
        default=True,
    )

    more_link_label = schema.TextLine(
        title=_(u'label_more_link_label',
                default=u'Label for the "more" link'),
        required=False,
    )
class IRefEGovServiceSchema(model.Schema):
    """ Dexterity Python Schema for RefEGovService
    """

    # Copy title from IBasic behavior. We don't want description
    title = schema.TextLine(title=DXMF(u'label_title', default=u'Title'),
                            required=True)

    directives.order_before(title='*')

    directives.omitted('title')
    directives.no_omit(IEditForm, 'title')
    directives.no_omit(IAddForm, 'title')

    form.widget(referencedService=ReferenceWidgetFactory)
    referencedService = RelationChoice(
        title=_(u'referencedService', default=u'Referenced Service'),
        required=False,
        source=ReferenceObjSourceBinder(
            override=True,
            selectable=['izug.refegovservice.egovservice'],
        ),
    )
Exemplo n.º 27
0
class IPMPerson(IPerson):
    """ """

    form.order_before(firstname_abbreviated='gender')
    firstname_abbreviated = schema.TextLine(
        title=_("Firstname abbreviated"),
        required=False,
    )

    form.read_permission(userid='PloneMeeting.write_userid_field')
    form.write_permission(userid='PloneMeeting.write_userid_field')
    userid = schema.Choice(
        title=_(u'Plone user'),
        description=_(u'If you need to use this person data in the '
                      u'application like for example scanned signature or '
                      u'telephone number, select it here.'),
        required=False,
        vocabulary=u'Products.PloneMeeting.Users',
    )

    model.fieldset('app_parameters',
                   label=_(u"Application parameters"),
                   fields=['userid'])
Exemplo n.º 28
0
class IPollSaveData(ISaveData):
    """Data Saver Interface for Poll."""

    pollFields = schema.List(
        title=_(u"label_pollfields_text", default=u"Poll Fields"),
        description=_(
            u"help_pollfields_text",
            default=u"Pick the fields whose inputs you'd like to display as "
            u"a poll. If empty, no poll will be shown.",
        ),
        unique=True,
        required=False,
        value_type=schema.Choice(vocabulary="easyform.Fields"),
    )
    directives.order_before(pollFields='showFields')

    showToAuthUsers = schema.Bool(title=_(
        u'field_showto_auth_users',
        default=u"Show results to authenticated users"),
                                  required=False)
    showToAnonymousUsers = schema.Bool(title=_(
        u'field_showto_anonymous_users',
        default=u"Show results to anonymous users"),
                                       required=False)
Exemplo n.º 29
0
class IRisk(model.Schema, IRichDescription, IBasic):
    """A possible risk that can be present in an organisation."""

    title = schema.TextLine(
        title=_("label_statement", default="Affirmative statement"),
        description=_(
            "help_statement",
            default="This is a short affirmative statement about a "
            "possible risk (e.g. The building is well maintained.)",
        ),
        required=True,
    )
    directives.widget(title="euphorie.content.risk.TextLines4Rows")
    directives.order_before(title="*")

    problem_description = schema.TextLine(
        title=_("label_problem_description", default="Negative statement"),
        description=_(
            "help_problem_description",
            default="This is the inverse of the affirmative "
            "statement (e.g. The building is not well maintained.)",
        ),
        required=True,
    )
    directives.widget(
        problem_description="euphorie.content.risk.TextLines4Rows")
    directives.order_after(problem_description="title")

    description = HtmlText(
        title=_("label_description", default="Description"),
        description=_(
            "help_risk_description",
            default="Describe the risk. Include any relevant information "
            "that may be helpful for the end-user.",
        ),
        required=True,
    )
    directives.widget(
        description="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    directives.order_after(description="problem_description")

    existing_measures = TextLinesWithBreaks(
        title=_(
            "deprecated_label_existing_measures",
            default="Measures that are already in place (Only shown here for "
            "reference! Use the “Add Measure” button on the Risk for adding "
            "measures that are shown to the user during Identification.)",
        ),
        description=_(
            "help_existing_measures",
            default="Use this field to define (common) measures that the "
            "user might have already implemented. "
            "Separate measures with a line break (Enter). The user will be "
            "able to deselect those measures that are not applicable to their"
            "situation.",
        ),
        required=False,
    )
    directives.widget(existing_measures="euphorie.content.risk.TextLines8Rows")
    directives.order_after(existing_measures="description")

    legal_reference = HtmlText(
        title=_("label_legal_reference",
                default="Legal and policy references"),
        required=False,
    )
    directives.widget(
        legal_reference="plone.app.z3cform.wysiwyg.WysiwygFieldWidget")
    directives.order_after(legal_reference="description")

    model.fieldset(
        "identification",
        label=_("header_identification", default="Identification"),
        fields=["show_notapplicable"],
    )

    show_notapplicable = schema.Bool(
        title=_("label_show_notapplicable",
                default="Show `not applicable' option"),
        description=_(
            "help_show_notapplicable",
            default="Offer a `not applicable' option in addition "
            "to the standard yes/no options.",
        ),
        default=False,
    )

    type = schema.Choice(
        title=_("label_risk_type", default="Risk type"),
        description=_(
            "help_risk_type",
            default='"Priority risk" is one of the high risks in the '
            'sector. "Risk" is related to the workplace or to the work '
            'carried out. "Policy" refers to agreements, procedures, '
            "and management decisions.",
        ),
        vocabulary=SimpleVocabulary([
            SimpleTerm("top5",
                       title=_("risktype_top5", default="Priority risk")),
            SimpleTerm("risk", title=_("risktype_risk", default="Risk")),
            SimpleTerm("policy", title=_("risktype_policy", default="Policy")),
        ]),
        default="risk",
        required=True,
    )

    depends("risk_always_present", "type", "==", "risk")
    risk_always_present = schema.Bool(
        title=_("label_risk_always_present", default="Risk is always present"),
        description=_(
            "description_risk_always_present",
            default='If selected, the user will not be able to answer "Yes" or '
            '"No", since the risk is considered to be always present. The '
            "Evaluation and Action Plan will behave in the same way as for "
            "regular risks.",
        ),
        required=False,
        default=False,
    )

    depends("evaluation_method", "type", "==", "risk")
    evaluation_method = schema.Choice(
        title=_("label_evaluation_method", default="Evaluation method"),
        description=_(
            "help_evaluation_method",
            default="Select 'estimated' if calcuation is not necessary "
            "or not possible.",
        ),
        vocabulary=SimpleVocabulary([
            SimpleTerm("direct",
                       title=_("evalmethod_direct", default="Estimated")),
            SimpleTerm(
                "calculated",
                title=_("evalmethod_calculated", default="Calculated"),
            ),
            SimpleTerm("fixed",
                       title=_("evalmethod_fixed", default="Skip evaluation")),
        ]),
        default="calculated",
        required=False,
    )

    depends("fixed_priority", "type", "==", "risk")
    depends("fixed_priority", "evaluation_method", "==", "fixed")
    fixed_priority = schema.Choice(
        title=_("report_timeline_priority", default="Priority"),
        vocabulary=SimpleVocabulary([
            SimpleTerm("low", title=_("priority_low", default="Low")),
            SimpleTerm("medium", title=_("priority_medium", default="Medium")),
            SimpleTerm("high", title=_("priority_high", default="High")),
        ]),
        required=False,
        default="low",
    )

    depends("default_priority", "type", "==", "risk")
    depends("default_priority", "evaluation_method", "==", "direct")
    default_priority = schema.Choice(
        title=_("label_default_priority", default="Default priority"),
        description=_(
            "help_default_priority",
            default="You can help the end-user by selecting a default "
            "priority. He/she can still change the priority.",
        ),
        vocabulary=SimpleVocabulary([
            SimpleTerm("none", title=_("no_default", default="No default")),
            SimpleTerm("low", title=_("priority_low", default="Low")),
            SimpleTerm("medium", title=_("priority_medium", default="Medium")),
            SimpleTerm("high", title=_("priority_high", default="High")),
        ]),
        required=False,
        default="low",
    )

    model.fieldset(
        "main_image",
        label=_("header_main_image", default="Main image"),
        description=_(
            "intro_main_image",
            default="The main image will get a more prominent position "
            "in the client than the other images.",
        ),
        fields=["image", "caption"],
    )

    image = filefield.NamedBlobImage(
        title=_("label_image", default="Image file"),
        description=_(
            "help_image_upload",
            default="Upload an image. Make sure your image is of format "
            "png, jpg or gif and does not contain any special "
            "characters. The minimum size is 1000 (width) x 430 (height) pixels.",
        ),
        required=False,
    )
    caption = schema.TextLine(title=_("label_caption",
                                      default="Image caption"),
                              required=False)

    model.fieldset(
        "secondary_images",
        label=_("header_secondary_images", default="Secondary images"),
        fields=[
            "image2", "caption2", "image3", "caption3", "image4", "caption4"
        ],
    )

    image2 = filefield.NamedBlobImage(
        title=_("label_image", default="Image file"),
        description=_(
            "help_image_upload",
            default="Upload an image. Make sure your image is of format "
            "png, jpg or gif and does not contain any special "
            "characters. The minimum size is 1000 (width) x 430 (height) pixels.",
        ),
        required=False,
    )
    caption2 = schema.TextLine(title=_("label_caption",
                                       default="Image caption"),
                               required=False)

    image3 = filefield.NamedBlobImage(
        title=_("label_image", default="Image file"),
        description=_(
            "help_image_upload",
            default="Upload an image. Make sure your image is of format "
            "png, jpg or gif and does not contain any special "
            "characters. The minimum size is 1000 (width) x 430 (height) pixels.",
        ),
        required=False,
    )
    caption3 = schema.TextLine(title=_("label_caption",
                                       default="Image caption"),
                               required=False)

    image4 = filefield.NamedBlobImage(
        title=_("label_image", default="Image file"),
        description=_(
            "help_image_upload",
            default="Upload an image. Make sure your image is of format "
            "png, jpg or gif and does not contain any special "
            "characters. The minimum size is 1000 (width) x 430 (height) pixels.",
        ),
        required=False,
    )
    caption4 = schema.TextLine(title=_("label_caption",
                                       default="Image caption"),
                               required=False)

    model.fieldset(
        "additional_content",
        label=_("header_additional_content", default="Additional content"),
        description=_(
            "intro_additional_content",
            default="Attach any additional content you consider helpful "
            "for the user",
        ),
        fields=[
            "file1",
            "file1_caption",
            "file2",
            "file2_caption",
            "file3",
            "file3_caption",
            "file4",
            "file4_caption",
        ],
    )

    file1 = filefield.NamedBlobFile(
        title=_("label_file", default="Content file"),
        description=_(
            "help_content_upload",
            default="Upload a file that contains additional information, "
            "like a PDF, Word document or spreadsheet. Optionally provide "
            "a descriptive caption for your file.",
        ),
        required=False,
    )
    file1_caption = schema.TextLine(title=_("label_file_caption",
                                            default="Content caption"),
                                    required=False)

    file2 = filefield.NamedBlobFile(
        title=_("label_file", default="Content file"),
        description=_(
            "help_content_upload",
            default="Upload a file that contains additional information, "
            "like a PDF, Word document or spreadsheet. Optionally provide "
            "a descriptive caption for your file.",
        ),
        required=False,
    )
    file2_caption = schema.TextLine(title=_("label_file_caption",
                                            default="Content caption"),
                                    required=False)

    file3 = filefield.NamedBlobFile(
        title=_("label_file", default="Content file"),
        description=_(
            "help_content_upload",
            default="Upload a file that contains additional information, "
            "like a PDF, Word document or spreadsheet. Optionally provide "
            "a descriptive caption for your file.",
        ),
        required=False,
    )
    file3_caption = schema.TextLine(title=_("label_file_caption",
                                            default="Content caption"),
                                    required=False)

    file4 = filefield.NamedBlobFile(
        title=_("label_file", default="Content file"),
        description=_(
            "help_content_upload",
            default="Upload a file that contains additional information, "
            "like a PDF, Word document or spreadsheet. Optionally provide "
            "a descriptive caption for your file.",
        ),
        required=False,
    )
    file4_caption = schema.TextLine(title=_("label_file_caption",
                                            default="Content caption"),
                                    required=False)
class IConfigurablePODTemplate(IPODTemplate):
    """
    ConfigurablePODTemplate dexterity schema.
    """

    form.order_before(is_reusable='enabled')
    form.widget('is_reusable', RadioFieldWidget)
    is_reusable = schema.Bool(
        title=_(u'Reusable'),
        description=_(
            u'Check if this POD Template can be reused by other POD Template'),
        required=False,
        default=False)

    form.order_before(pod_template_to_use='enabled')
    pod_template_to_use = schema.Choice(
        title=_(u'Select Existing POD Template to reuse'),
        vocabulary='collective.documentgenerator.ExistingPODTemplate',
        required=False,
        default=None)

    form.widget('pod_formats',
                OrderedSelectFieldWidget,
                multiple='multiple',
                size=5)
    pod_formats = schema.List(
        title=_(u'Available formats'),
        description=_(
            u'Select format in which the template will be generable.'),
        value_type=schema.Choice(
            source='collective.documentgenerator.Formats'),
        required=True,
        default=[
            'odt',
        ],
    )

    csv_field_delimiter = schema.Choice(
        title=_(u'Field Delimiter for CSV format'),
        description=_(
            u"Select the character to be used to separate fields into CSV files"
        ),
        vocabulary='collective.documentgenerator.CSVFieldDelimiter',
        required=True,
        default=u",")
    csv_string_delimiter = schema.Choice(
        title=_(u'String Delimiter for CSV format'),
        description=
        _(u"Select the character to be used to wrap around string values in CSV files"
          ),
        vocabulary='collective.documentgenerator.CSVStringDelimiter',
        required=True,
        default=u'"')

    form.widget('pod_portal_types',
                CheckBoxFieldWidget,
                multiple='multiple',
                size=15)
    pod_portal_types = schema.List(
        title=_(u'Allowed portal types'),
        description=_(
            u'Select for which content types the template will be available.'),
        value_type=schema.Choice(
            source='collective.documentgenerator.PortalTypes'),
        required=False,
    )

    form.widget('merge_templates', DataGridFieldFactory)
    merge_templates = schema.List(
        title=_(u'Templates to merge.'),
        required=False,
        value_type=DictRow(schema=IMergeTemplatesRowSchema, required=False),
        default=[],
    )

    form.widget('context_variables', DataGridFieldFactory)
    context_variables = schema.List(
        title=_(u'Context variables.'),
        description=_(
            "These context variables are added to the odt_file context."),
        required=False,
        value_type=DictRow(schema=IContextVariablesRowSchema, required=False),
    )

    mailing_loop_template = schema.Choice(
        title=_(u'Mailing loop template'),
        description=_(
            u'Choose the mailing loop template to apply for this template.'),
        vocabulary='collective.documentgenerator.EnabledMailingLoopTemplates',
        required=False,
    )

    column_modifier = schema.Choice(
        title=_(u'Table column modifier'),
        description=_(COLUMN_MODIFIER_DESCR),
        vocabulary='collective.documentgenerator.PodColumnModifier',
        required=True,
        default=-1)

    @invariant
    def validate_context_variables(data):
        keys = []
        forbidden = ['context', 'view', 'uids', 'brains', 'self']
        to_check = copy.deepcopy(data.context_variables or [])
        to_check.extend(copy.deepcopy(data.merge_templates or []))

        for line in to_check:
            value = ('name' in line
                     and line['name']) or ('pod_context_name' in line
                                           and line['pod_context_name'])

            if value in forbidden:
                raise Invalid(
                    _("You can't use one of these words: ${list}",
                      mapping={'list': ', '.join(forbidden)}))

            if value in keys:
                raise Invalid(
                    _("You have twice used the same name '${name}'",
                      mapping={'name': value}))
            else:
                keys.append(value)

    @invariant
    def validate_pod_file(data):
        if not (data.odt_file or data.pod_template_to_use):
            raise Invalid(
                _("You must select an odt file or an existing pod template"),
                schema)

    @invariant
    def validate_pod_template_to_use(data):
        if data.pod_template_to_use and (data.is_reusable or data.odt_file):
            raise Invalid(
                _("You can't select a POD Template or set this template reusable "
                  "if you have chosen an existing POD Template."), schema)
Exemplo n.º 31
0

class IBasicBrandInfo(model.Schema):
    """Behavior interface to make a type support brand and model."""

    brand = schema.TextLine(
        title=_mf(u'label_brand', default=u'Brand'),
        required=True
    )

    model = schema.TextLine(
        title=_mf(u'label_model', default=u'Model'),
        required=True
    )

form.order_before(model='*')
form.order_before(brand='*')

alsoProvides(IBasicBrandInfo, IFormFieldProvider)


@implementer(IBasicBrandInfo)
class BasicBrandInfo(object):
    ""

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

    @property
    def title(self):
        ""