Example #1
0
class IDCExtended(Interface):
    """Extended properties

    This is a mixed bag of properties we want but that we probably haven't
    quite figured out yet.
    """

    creators = Tuple(
        title=u'Creators',
        description=u"The unqualified Dublin Core 'Creator' element values",
        value_type=TextLine(),
    )

    subjects = Tuple(
        title=u'Subjects',
        description=u"The unqualified Dublin Core 'Subject' element values",
        value_type=TextLine(),
    )

    publisher = Text(
        title=u'Publisher',
        description=
        u"The first unqualified Dublin Core 'Publisher' element value.",
    )

    contributors = Tuple(
        title=u'Contributors',
        description=u"The unqualified Dublin Core 'Contributor' element values",
        value_type=TextLine(),
    )
class IMailMessage(Interface):

    # This needs to be converted to unicode on input
    from_addr = TextLine(
        title = _(u"From"),
        description = _(u"The address the mail was sent from"),
        required = True,)

    # This needs to be converted to unicode on input
    subject = TextLine(
        title = _(u"Subject"),
        description = _(u"The subject of the email"),
        default = u"No Subject",
        required = False,)

    date = Datetime(
        title = _(u"Date"),
        description = _(u"The date the mail was sent"),
        required = True,)

    body = Text(
        title = _(u"Body"),
        description = _(u"The mail message body"),
        default = u'',
        required = False,)

    message_id = ASCII(
        title = _(u"Message Id"),
        description = _(u"The message id of this message."),
        default = '',
        required = False,)

    in_reply_to = ASCII(
        title = _(u"Reply To"),
        description = _(u"The message id that this mail is in reply to."),
        default = '',
        required = False,)

    references = Tuple(
        title = _(u"References"),
        description = _(u"Any message ids that this mail refers to."),
        value_type = ASCII(title=_(u"Reference"),),
        default = (),
        required = False,)

    other_headers = Tuple(
        title = _(u"Headers"),
        description = _(u"List of selected other headers: (key, value) pairs"),
        value_type = Tuple(
                           title = _(u"Header"),
                           value_type = ASCII(),
                           min_length = 2,
                           max_length = 2,),
        default = (),
        required = False,
        )
Example #3
0
    def testCorrectValueType(self):
        # allow value_type of None (??? is this OK?)
        Tuple(value_type=None)

        # do not allow arbitrary value types
        self.assertRaises(ValueError, Tuple, value_type=object())
        self.assertRaises(ValueError, Tuple, value_type=Field)

        # however, allow anything that implements IField
        Tuple(value_type=Field())
        class FakeField(object):
            implements(IField)
        Tuple(value_type=FakeField())
Example #4
0
class INavigationSchema(Interface):
    """Fields for the navigation control panel."""
    generate_tabs = Bool(
        title=_(u"Automatically generate tabs"),
        description=
        _(u"By default, all items created at the root level will add to the global section navigation. You can turn this off if you prefer manually constructing this part of the navigation."
          ),
        default=True,
        required=False)

    nonfolderish_tabs = Bool(
        title=_(u"Generate tabs for items other than folders."),
        description=
        _(u"By default, any content item in the root of the portal will be shown as a global section. If you turn this option off, only folders will be shown. This only has an effect if 'Automatically generate tabs' is enabled."
          ),
        default=True,
        required=False)

    displayed_types = Tuple(
        title=_(u"Displayed content types"),
        description=
        _(u"The content types that should be shown in the navigation and site map."
          ),
        required=False,
        missing_value=tuple(),
        value_type=Choice(
            vocabulary="plone.app.vocabularies.ReallyUserFriendlyTypes"))

    filter_on_workflow = Bool(
        title=_(u"Filter on workflow state"),
        description=
        _(u"The workflow states that should be shown in the navigation tree and the site map."
          ),
        default=False,
        required=False)

    workflow_states_to_show = Tuple(
        required=False,
        missing_value=tuple(),
        value_type=Choice(vocabulary="plone.app.vocabularies.WorkflowStates"))

    show_excluded_items = Bool(
        title=
        _(u"Show items normally excluded from navigation if viewing their children."
          ),
        description=
        _(u"If an item has been excluded from navigation should it be shown in navigation when viewing content contained within it or within a subfolder."
          ),
        default=True,
        required=False)
Example #5
0
class IStaticDeployment(Interface):
    """
    Static deployment manage form.
    """
    section_choice = Tuple(
        title=_('Choose configuration section'),
        required=True,
        missing_value=set(),
        value_type=Choice(
            vocabulary="stxnext.staticdeployment.vocabularies.ConfigSections"))

    last_triggered = TextLine(
        title=_(u'Last static deployment date'),
        description=_(
            u'Last static deployment date - format YYYY/MM/DD HH:MM:SS'),
        default=u'',
        required=False,
    )

    delete_previous = Bool(
        title=_(u'Remove previously deployed files'),
        description=_(u''),
    )

    deployment = Choice(
        title=_('Deploy static version of website'),
        required=True,
        description=
        _(u'Choose if you want to deploy all content or update content modified since last static deployment'
          ),
        vocabulary='stxnext.staticdeployment.vocabularies.DeploymentMode',
    )
Example #6
0
    def test_data_converter_tuple(self):
        from plone.app.widgets.dx import AjaxSelectWidget
        from plone.app.widgets.dx import AjaxSelectWidgetConverter

        field = Tuple(__name__='tuplefield', value_type=TextLine())
        widget = AjaxSelectWidget(self.request)
        widget.field = field
        converter = AjaxSelectWidgetConverter(field, widget)

        self.assertEqual(
            converter.toFieldValue(''),
            field.missing_value,
        )

        self.assertEqual(
            converter.toFieldValue('123;456;789'),
            ('123', '456', '789'),
        )

        self.assertEqual(
            converter.toWidgetValue(tuple()),
            None,
        )

        self.assertEqual(
            converter.toWidgetValue(('123', '456', '789')),
            '123;456;789',
        )
class IMailModel(Interface):
    """A named utility providing a mail model.

    The mail content rule will allow the user ot pick a mail model based on
    a vocabulary of all named utilities providing this interface. When the
    content rule action is executed, the object being acted upon will be
    adapted to the interface specified under `replacer_interface`.
    Substitutions will then be made based on variables matching field names
    (e.g. "${foobar}" matches the `foobar` field). The substituted values
    are obtained from the adapter.
    """

    title = TextLine(title=_(u"A friendly name for model", ))

    replacer_interface = Object(
        title=_(u"Mail replacer schema"),
        description=_(u"Interface providing word substitution in "\
                        "mail fields: source, recipients, subject, text"),
        schema=Interface)

    fields = List(
        title=_(u"Fields help text"),
        description=_(u"Exposes the variables provided by the replacer"),
        value_type=Tuple(title=_(u"Pair of (key, help text,)"),
                         value_type=TextLine(title=_(u"Name or help text"))))
class IGSModeratorInfo(Interface):
    """Information about the users who are moderators in the group"""

    context = Field(title='Context',
                    description='Context for the moderator information')

    moderators = Tuple(
        title='Moderators',
        description='The members who are moderators in the group',
        readonly=True)

    def moderator(user):
        """Is the user a moderator?
        ARGUMENTS
          "user": A user.

        RETURNS
          "True" if the user is a moderator in the group; "False"
          otherwise.

        SIDE EFFECTS
          None
        """

    def status(user):
        """The moderator status for the user in the group.
Example #9
0
class IManageable(Interface):
    """Something that is manageable in the ZMI"""

    manage_tabs = Attribute("""Management tabs""")

    manage_options = Tuple(title=u"Manage options", )

    def manage(URL1):
        """Show management screen"""

    def manage_afterAdd(item, container):
        """Gets called after being added to a container"""

    def manage_beforeDelete(item, container):
        """Gets called before being deleted"""

    def manage_afterClone(item):
        """Gets called after being cloned"""

    def filtered_manage_options(REQUEST=None):
        """
        """

    def manage_workspace(REQUEST):
        """Dispatch to first interface in manage_options
        """

    def tabs_path_default(REQUEST):
        """
        """

    def tabs_path_info(script, path):
        """
Example #10
0
class ILocaleDisplayNames(Interface):
    """Localized Names of common text strings.

    This object contains localized strings for many terms, including
    language, script and territory names. But also keys and types used
    throughout the locale object are localized here.
    """

    languages = Dict(title=u"Language type to translated name",
                     key_type=TextLine(title=u"Language Type"),
                     value_type=TextLine(title=u"Language Name"))

    scripts = Dict(title=u"Script type to script name",
                   key_type=TextLine(title=u"Script Type"),
                   value_type=TextLine(title=u"Script Name"))

    territories = Dict(title=u"Territory type to translated territory name",
                       key_type=TextLine(title=u"Territory Type"),
                       value_type=TextLine(title=u"Territory Name"))

    variants = Dict(title=u"Variant type to name",
                    key_type=TextLine(title=u"Variant Type"),
                    value_type=TextLine(title=u"Variant Name"))

    keys = Dict(title=u"Key type to name",
                key_type=TextLine(title=u"Key Type"),
                value_type=TextLine(title=u"Key Name"))

    types = Dict(title=u"Type type and key to localized name",
                 key_type=Tuple(title=u"Type Type and Key"),
                 value_type=TextLine(title=u"Type Name"))
Example #11
0
class ITransformSchema(Interface):
    enabled_transforms = Tuple(
        title=_(u"label_transforms", default=u"Transforms"),
        description=_(
            u"help_transforms",
            default=u"Select the text transformations that should be "
            u"used for comments posted in Ploneboard "
            u"conversations. Text transformations alter the "
            u"text entered by the user, either to remove "
            u"potentially malicious HTML tags, or to add "
            u"additional functionality, such as making links "
            u"clickable."),
        required=True,
        missing_value=set(),
        value_type=Choice(
            vocabulary="Products.Ploneboard.AvailableTransforms"))

    enable_anon_name = Bool(
        title=_(u"label_anon_nick", default=u"Anonymous name"),
        description=_(
            u"help_anon_nick",
            default=
            u"If selected, anonymous users can insert a name in their comments."
        ),
        required=False)
Example #12
0
class IListingTile(IPersistentCoverTile):

    title = TextLine(
        title=u'Title',
        required=False,
    )

    # uuid = RelationChoice(
    #     title=u"Linked Source",
    #     source=UUIDSourceBinder(portal_type="Sparql"),
    #     required=False,
    # )
    uuid = Tuple(title=u"Linked Sources",
                 value_type=Choice(
                     title=u"Linked Source",
                     vocabulary="bise.datasource_vocabulary",
                     required=False,
                 ))

    text = RichText(title=u'Text', required=False)

    view_more_url = TextLine(
        title=u'View More URL',
        required=False,
    )

    count = Int(
        title=u'Number of items to display, per source',
        required=False,
        default=6,
    )
Example #13
0
    def test_data_converter_tuple(self):
        from plone.app.widgets.dx import SelectWidget
        from plone.app.widgets.dx import SelectWidgetConverter

        field = Tuple(__name__='tuplefield',
                      value_type=Choice(__name__='selectfield',
                                        values=['one', 'two', 'three']))
        widget = SelectWidget(self.request)
        widget.field = field
        widget.multiple = True
        converter = SelectWidgetConverter(field, widget)

        self.assertEqual(
            converter.toFieldValue(''),
            field.missing_value,
        )

        self.assertEqual(
            converter.toFieldValue('one;two;three'),
            ('one', 'two', 'three'),
        )

        self.assertEqual(
            converter.toWidgetValue(tuple()),
            [],
        )

        self.assertEqual(
            converter.toWidgetValue(('one', 'two', 'three')),
            ['one', 'two', 'three'],
        )
Example #14
0
 def test_widget_tuple_orderable(self):
     from plone.app.z3cform.widget import SelectWidget
     widget = SelectWidget(self.request)
     widget.id = 'test-widget'
     widget.field = Tuple(
         __name__='selectfield',
         value_type=Choice(values=['one', 'two', 'three'])
     )
     widget.terms = widget.field.value_type.vocabulary
     self.assertEqual(
         {
             'multiple': True,
             'name': None,
             'pattern_options': {
                 'orderable': True, 'multiple': True, 'separator': ';'},
             'pattern': 'select2',
             'value': (),
             'items': [
                 ('one', 'one'),
                 ('two', 'two'),
                 ('three', 'three')
             ]
         },
         widget._base_args(),
     )
Example #15
0
class ILocaleTimeZone(Interface):
    """Represents and defines various timezone information. It mainly manages
    all the various names for a timezone and the cities contained in it.

    Important: ILocaleTimeZone objects are not intended to provide
    implementations for the standard datetime module timezone support. They
    are merily used for Locale support.
    """

    type = TextLine(
        title=u"Time Zone Type",
        description=u"Standard name of the timezone for unique referencing.",
        required=True,
        readonly=True)

    cities = List(title=u"Cities",
                  description=u"Cities in Timezone",
                  value_type=TextLine(title=u"City Name"),
                  required=True,
                  readonly=True)

    names = Dict(title=u"Time Zone Names",
                 description=u"Various names of the timezone.",
                 key_type=Choice(title=u"Time Zone Name Type",
                                 values=(u'generic', u'standard',
                                         u'daylight')),
                 value_type=Tuple(title=u"Time Zone Name and Abbreviation",
                                  min_length=2,
                                  max_length=2),
                 required=True,
                 readonly=True)
Example #16
0
class IGroupManager(IForm):
    """Groups manager interface"""

    groups = Tuple(
        title='Groups',
        description=('Initially a collection of group classes, which are '
                     'converted to group instances when the form is '
                     'updated.'))
Example #17
0
class IPrivacyScreenSettings(Interface):
    """ NOTE: Not used at the moment
    """

    settings = Tuple(title=u"Settings",
                     required=False,
                     value_type=DictRow(title=u"Website Settings",
                                        schema=IProtectedDestination))
Example #18
0
    def testValidateRequired(self):
        field = Tuple(title=u'Tuple field', description=u'',
                      readonly=False, required=True)
        field.validate(())
        field.validate((1, 2))
        field.validate((3,))

        self.assertRaises(RequiredMissing, field.validate, None)
Example #19
0
    def testValidateMinValues(self):
        field = Tuple(title=u'Tuple field', description=u'',
                      readonly=False, required=False, min_length=2)
        field.validate(None)
        field.validate((1, 2))
        field.validate((1, 2, 3))

        self.assertRaises(TooShort, field.validate, ())
        self.assertRaises(TooShort, field.validate, (1,))
class IAliasesSchema(Interface):

    managed_types = Tuple(title=_(u"Managed types"),
                          description=_(u"Select the types for which the "
                                        "aliases can be managed"),
                          required=True,
                          missing_value=tuple(),
                          value_type=Choice(
                              vocabulary="plone.app.vocabularies.ReallyUserFriendlyTypes"))
Example #21
0
    def testValidateMaxValues(self):
        field = Tuple(title=u'Tuple field', description=u'',
                      readonly=False, required=False, max_length=2)
        field.validate(None)
        field.validate(())
        field.validate((1, 2))

        self.assertRaises(TooLong, field.validate, (1, 2, 3, 4))
        self.assertRaises(TooLong, field.validate, (1, 2, 3))
Example #22
0
    def testValidateValueTypes(self):
        field = Tuple(title=u'Tuple field', description=u'',
                      readonly=False, required=False,
                      value_type=Int())
        field.validate(None)
        field.validate((5,))
        field.validate((2, 3))

        self.assertRaises(WrongContainedType, field.validate, ('',) )
        self.assertRaises(WrongContainedType, field.validate, (3.14159,) )
class ICalendarSchema(Interface):

    firstweekday = Int(title=_(u'First day of week in the calendar'),
                       default=0,
                       required=True)

    calendar_states = Tuple(title=_(u'Workflow states to show in the calendar'),
                            required=True,
                            missing_value=set(),
                            value_type=Choice(
                                vocabulary="plone.app.vocabularies.WorkflowStates"))
 def test_anonymousfield(self):
     self.field = Tuple(__name__=u'foo', value_type=TextLine())
     request = TestRequest()
     widget = TupleSequenceWidget(self.field, self.field.value_type,
                                  request)
     widget.setRenderedValue((u'existing', ))
     s = widget()
     check_list = ('input', '"field.foo.0."', 'existing', 'submit',
                   'submit', 'field.foo.add')
     s = widget()
     self.verifyResult(s, check_list, inorder=True)
Example #25
0
    def test_data_converter(self):
        from plone.app.widgets.dx import Select2Widget
        from plone.app.widgets.dx import Select2WidgetConverter

        field1 = List(__name__='listfield', value_type=TextLine())
        widget1 = Select2Widget(self.request)
        widget1.field = field1
        converter1 = Select2WidgetConverter(field1, widget1)

        self.assertEqual(
            converter1.toFieldValue(''),
            field1.missing_value,
        )

        self.assertEqual(
            converter1.toFieldValue('123;456;789'),
            ['123', '456', '789'],
        )

        self.assertEqual(
            converter1.toWidgetValue([]),
            '',
        )

        self.assertEqual(
            converter1.toWidgetValue(['123', '456', '789']),
            '123;456;789',
        )

        field2 = Tuple(__name__='tuplefield', value_type=TextLine())
        widget2 = Select2Widget(self.request)
        widget2.field = field2
        converter2 = Select2WidgetConverter(field2, widget2)

        self.assertEqual(
            converter2.toFieldValue(''),
            field2.missing_value,
        )

        self.assertEqual(
            converter2.toFieldValue('123;456;789'),
            ('123', '456', '789'),
        )

        self.assertEqual(
            converter2.toWidgetValue(tuple()),
            '',
        )

        self.assertEqual(
            converter2.toWidgetValue(('123', '456', '789')),
            '123;456;789',
        )
Example #26
0
    def testValidate(self):
        field = Tuple(title=u'Tuple field', description=u'',
                      readonly=False, required=False)
        field.validate(None)
        field.validate(())
        field.validate((1, 2))
        field.validate((3,))

        self.assertRaises(WrongType, field.validate, [1, 2, 3])
        self.assertRaises(WrongType, field.validate, 'abc')
        self.assertRaises(WrongType, field.validate, 1)
        self.assertRaises(WrongType, field.validate, {})
Example #27
0
class IWikiMarkupSchema(Interface):

    wiki_enabled_types = Tuple(title=_(u"Choose which types will have wiki "
                                        "behavior."),
                               description=_(u"Each type chosen will have a "
                                             "wiki enabled primary text area. "
                                             "At least one type must be chosen "
                                             "to turn wiki behavior on."),
                               required=False,
                               missing_value=tuple(),
                               value_type=Choice(vocabulary="plone.app.\
controlpanel.WickedPortalTypes"))
Example #28
0
class ICategoryContainer(Interface):

    local_categories = List(title=_(u"Local Categories"),
                            value_type=Object(IPloneRatingCategory,
                                              title=_(u"Category")),
                            required=False)

    acquired_categories = Tuple(title=_(u"Acquired Categories"),
                                value_type=Object(IPloneRatingCategory,
                                                  title=_(u"Category")),
                                readonly=True,
                                required=False)
Example #29
0
class IMail(model.Schema):

    mail_from = TextLine(
        title=_('from', u'From'),
        description=u'',
        default=u'',
    )

    mail_to = Tuple(
        title=_('to', u'To'),
        description=u'',
        value_type=TextLine(),
        default=(),
        required=False,
    )

    mail_cc = Tuple(
        title=_('cc', u'CC'),
        description=u'',
        value_type=TextLine(),
        default=(),
        required=False,
    )

    mail_bcc = Tuple(
        title=_('bcc', u'BCC'),
        description=u'',
        value_type=TextLine(),
        missing_value=(),
        required=False,
    )

    mail_body = RichTextField(
        title=_('body', u'Body'),
        description=u"",
        required=False,
        default=RichTextValue(u''),
    )
    form.widget('mail_body', RichTextFieldWidget)
    model.primary('mail_body')
Example #30
0
 def test_widget_tuple_orderable(self):
     from plone.app.widgets.dx import AjaxSelectWidget
     widget = AjaxSelectWidget(self.request)
     widget.field = Tuple(__name__='selectfield')
     self.assertEqual(
         {
             'name': None,
             'value': u'',
             'pattern': 'select2',
             'pattern_options': {'orderable': True, 'separator': ';'},
         },
         widget._base_args(),
     )