Beispiel #1
0
class ISiteSchema(controlpanel.ISiteSchema):
    short_site_title = schema.TextLine(title=u'Short site title',
                                       default=u"Castle",
                                       required=False)

    site_icon = schema.ASCII(
        title=u"Site Icon",
        description=u'CastleCMS will use this icon to generate all the various '
        u'icons for mobile devices necessary',
        required=False,
    )

    system_email_addresses = schema.List(
        title=u"System email addresses",
        description=u'List of admin email addresses',
        default=[],
        missing_value=[],
        value_type=schema.TextLine(),
        required=False)

    disable_contact_form = schema.Bool(title=u'Disable contact form',
                                       default=False)

    enable_notification_subscriptions = schema.Bool(
        title=u'Enable notification subscriptions',
        description=u'By going to @@subscribe',
        default=False)
class ISpeaker(model.Schema):

    directives.mode(oid='hidden')
    oid = schema.TextLine(title=u"UUID",
                          default=u'{}'.format(uuid.uuid4().hex))

    first_name = schema.TextLine(title=_(u"First Name"))
    last_name = schema.TextLine(title=_(u"Last Name"), )
    email = Email(title=_(u'label_email', default=u'Email'),
                  description=_(u'help_email', default=u''),
                  required=False)
    profession = schema.TextLine(
        title=_(u"Profession"),
        required=False,
    )
    description = schema.Text(
        title=_(u"Biography"),
        required=False,
    )
    website = schema.URI(title=_(u'label_website', default=u'Website'),
                         description=_(u'help_website', default=u''),
                         required=False)
    directives.widget('website', LinkWidget)
    phone = schema.TextLine(title=_(u'label_phone', default=u'Phone'),
                            description=_(u'help_phone', default=u''),
                            required=False)
    picture = schema.ASCII(
        title=_(u"Please upload an image"),
        required=False,
    )
    directives.widget('picture', NamedImageFieldWidget)
Beispiel #3
0
class IURL2Embed(interface.Interface):
    """To extend oembed experience we add a new kind of service: get the
    embed code directly from the URL. For example we can do that
    with picasaweb service.

    Pros:
      * no need to request external service
    Cons:
      * we can't get external information like title, description, ...
    """

    embed_html_template = schema.ASCII(title=_(u"embed_html_template"))

    url_schemes = schema.List(title=_(u"url schemes"))

    def break_url(url):
        """utility which return proto, host, path, query, fragments
        """

    def get_embed(url, maxwidth=None, maxheight=None):
        """Return the embed html code build from embed_html_template using
        get_params_from_url"""

    def request(url):
        """Return a dict contains all needed params in embed_html_template
Beispiel #4
0
class IImportSubscribersForm(model.Schema):
    directives.widget('csv_upload', FileWidget)
    csv_upload = schema.ASCII(
        title=u"Import subscribers",
        description=u"Upload CSV file to import",
        required=False
    )
Beispiel #5
0
class ISubPage(Interface):
    """A component that computes part of a page
    """
    def update():
        """Update content ot view information based on user input
        """

    def render():
        """Render the sub page, returning a unicode string
        """

    prefix = schema.ASCII(
        constraint=reConstraint(
            '[a-zA-Z][a-zA-Z0-9_]*([.][a-zA-Z][a-zA-Z0-9_]*)*',
            "Must be a sequence of not-separated identifiers"),
        description=u"""Page-element prefix

        All named or identified page elements in a subpage should have
        names and identifiers that begin with a subpage prefix
        followed by a dot.
        """,
        readonly=True,
    )

    def setPrefix(prefix):
        """Update the subpage prefix
class IMailSchema(Interface):

    smtp_host = schema.TextLine(title=_(u'label_smtp_server',
                                        default=u'SMTP server'),
                                description=_(
                                    u"help_smtp_server",
                                    default=u"The address of your local "
                                    u"SMTP (outgoing e-mail) server. Usually "
                                    u"'localhost', unless you use an "
                                    u"external server to send e-mail."),
                                default=u'localhost',
                                required=True)

    smtp_port = schema.Int(title=_(u'label_smtp_port', default=u'SMTP port'),
                           description=_(
                               u"help_smtp_port",
                               default=u"The port of your local SMTP "
                               u"(outgoing e-mail) server. Usually '25'."),
                           default=25,
                           required=True)

    smtp_userid = schema.TextLine(title=_(u'label_smtp_userid',
                                          default=u'ESMTP username'),
                                  description=_(
                                      u"help_smtp_userid",
                                      default=u"Username for authentication "
                                      u"to your e-mail server. Not required "
                                      u"unless you are using ESMTP."),
                                  default=None,
                                  required=False)

    smtp_pass = schema.Password(title=_(u'label_smtp_pass',
                                        default=u'ESMTP password'),
                                description=_(
                                    u"help_smtp_pass",
                                    default=u"The password for the ESMTP "
                                    u"user account."),
                                default=None,
                                required=False)

    email_from_name = schema.TextLine(title=_(u"Site 'From' name"),
                                      description=_(
                                          u"Plone generates e-mail using "
                                          u"this name as the e-mail "
                                          u"sender."),
                                      default=None,
                                      required=True)

    email_from_address = schema.ASCII(title=_(u"Site 'From' address"),
                                      description=_(
                                          u"Plone generates e-mail using "
                                          u"this address as the e-mail "
                                          u"return address. It is also "
                                          u"used as the destination "
                                          u"address for the site-wide "
                                          u"contact form and the 'Send test "
                                          u"e-mail' feature."),
                                      default=None,
                                      required=True)
Beispiel #7
0
class IScreenshotForm(model.Schema):
    """ Define form fields """

    names = schema.ASCII(
        title=u"URLs",
        description=
        u"One on each line. For sitemap: Only base URL ( http://medialog.no )",
        required=False)
Beispiel #8
0
class IReaditlaterSettings(interface.Interface):
    """Global configuration fo collective.readitlater add-on."""

    folder_query = schema.ASCII(
        title=_(u"Folder query"),
        description=_(u"help_readitlater_folder_query",
                      default=folder_query_desc),
    )

    @interface.invariant
    def _folder_query_is_json(obj):
        try:
            json.loads(obj.folder_query)
        except ValueError:
            raise interface.Invalid("Not a valid JSON.")
Beispiel #9
0
class IRuleElementData(Interface):
    """Metadata for rule element data (the configuration of actions
    or conditions).
    """

    element = schema.ASCII(
        title=u"Rule element",
        description=u"The name of the rule action or condition",
        required=True)

    summary = schema.Text(
        title=u"Summary",
        description=
        u"A human-readable description of this element as it is configured",
        required=True)
Beispiel #10
0
class IRichTextValue(Interface):
    """The value actually stored in a RichText field.

    This stores the following values on the parent object

      - A separate persistent object with the original value
      - A cache of the value transformed to the default output type

    The object is immutable.
    """

    raw = schema.Text(
        title=_(u"Raw value in the original MIME type"),
        readonly=True,
    )

    mimeType = schema.ASCIILine(
        title=_(u"MIME type"),
        readonly=True,
    )

    outputMimeType = schema.ASCIILine(
        title=_(u"Default output MIME type"),
        readonly=True,
    )

    encoding = schema.ASCIILine(
        title=_(u"Default encoding for the value"),
        description=_(u"Mainly used internally"),
        readonly=True,
    )

    raw_encoded = schema.ASCII(
        title=_(u"Get the raw value as an encoded string"),
        description=_(u"Mainly used internally"),
        readonly=True,
    )

    output = schema.Text(
        title=_(u"Transformed value in the target MIME type"),
        description=_(u"May be None if the transform cannot be completed"),
        readonly=True,
        required=False,
        missing_value=None,
    )
Beispiel #11
0
class IPigeonholeSchemaSettings(Interface):

    title = schema.TextLine(title=u'Title')
    name = schema.ASCIILine(title=u'Name')
    schema_xml = schema.ASCII(
        title=u'Schema XML',
        default=
        '<model xmlns="http://namespaces.plone.org/supermodel/schema"><schema></schema></model>'
    )
    types = schema.Set(value_type=schema.Choice(
        vocabulary='plone.app.vocabularies.ReallyUserFriendlyTypes', ))
    condition = schema.ASCIILine(
        title=u'Condition',
        description=
        u'A TALES expression. If specified, it must evaluate to true in order to show the schema.',
        required=False,
        constraint=isValidExpression,
    )
class ISponsor(model.Schema):

    directives.mode(oid='hidden')
    oid = schema.TextLine(title=u"UUID",
                          default=u'{}'.format(uuid.uuid4().hex))

    name = schema.TextLine(title=_(u"Name"))
    email = Email(title=_(u'label_email', default=u'Email'),
                  description=_(u'help_email', default=u''),
                  required=False)
    website = schema.URI(title=_(u'label_website', default=u'Website'),
                         description=_(u'help_website', default=u''),
                         required=False)
    picture = schema.ASCII(
        title=_(u"Please upload an image"),
        required=False,
    )
    directives.widget('picture', NamedImageFieldWidget)
class ISiteSchema(ILockSettings):

    site_title = schema.TextLine(
        title=_(u'Site title'),
        description=_(
            u"This shows up in the title bar of "
            u"browsers and in syndication feeds."),
        default=u'Plone site')

    site_logo = schema.ASCII(
        title=_(u"Site Logo"),
        description=_(u"This shows a custom Logo on your Site."),
        required=False,
    )

    exposeDCMetaTags = schema.Bool(
        title=_(u"Expose Dublin Core metadata"),
        description=_(u"Exposes the Dublin Core properties as metatags."),
        default=False,
        required=False)

    enable_sitemap = schema.Bool(
        title=_(u"Expose sitemap.xml.gz"),
        description=_(
            u"Exposes your content as a file "
            u"according to the sitemaps.org standard. You "
            u"can submit this to compliant search engines "
            u"like Google, Yahoo and Microsoft. It allows "
            u"these search engines to more intelligently "
            u"crawl your site."),
        default=False,
        required=False)

    webstats_js = schema.SourceText(
        title=_(u'JavaScript for web statistics support'),
        description=_(
            u"For enabling web statistics support "
            u"from external providers (for e.g. Google "
            u"Analytics). Paste the code snippets provided. "
            u"It will be included in the rendered HTML as "
            u"entered near the end of the page."),
        default=u'',
        required=False)
Beispiel #14
0
class IAMPSettings(model.Schema):
    """Schema for the control panel form."""

    form.widget('publisher_logo', NamedImageFieldWidget)
    publisher_logo = schema.ASCII(
        title=_(u'Publisher Logo'),
        description=_(
            u'The logo of the publisher. Should have a wide aspect ratio, '
            u'and should be no wider than 600px, and no taller than 60px.'),
        required=False,
        constraint=is_valid_logo,
    )

    # XXX: placeholder attribute is not working
    form.widget('amp_sticky_ad',
                rows=15,
                placeholder=AMP_STICKY_AD_PLACEHOLDER)
    amp_sticky_ad = schema.Text(
        title=_(u'AMP Sticky Ad'),
        description=
        _(u'Adds support for ad units that always take a fixed place in the viewport. '
          u'Fill with the "amp-ad" element that will be used as a direct child of "amp-sticky-ad". '
          u'See <a href="https://ampbyexample.com/components/amp-sticky-ad/">amp-sticky-ad</a> for examples on how to implement this feature.'
          ),
        required=False,
        default=u'',
        constraint=is_xml,
    )

    form.widget('amp_analytics', rows=15)
    amp_analytics = schema.Text(
        title=_(u'AMP Analytics'),
        description=
        _(u'The "amp-analytics" elements that will be used to measure activity on AMP documents. '
          u'See <a href="https://developers.google.com/analytics/devguides/collection/amp-analytics/">'
          u'Adding Analytics to your AMP pages</a> for examples on how to implement this feature.'
          ),
        required=False,
        default=u'',
        constraint=is_xml,
    )
Beispiel #15
0
class IPloneQRControlPanel(model.Schema):
    enable_viewlet = schema.Bool(
        title=_(u'Enable Qr Code Viewlets'),
        description=_(u'''Provides QR code viewlet for dexterity'''
                      u'''content and shown below of title.'''),
        default=False)

    use_logo = schema.Bool(title=_(u'Use your logo?'), default=False)

    form.widget('your_logo', NamedImageFieldWidget)
    your_logo = schema.ASCII(
        title=_(u'Your logo'),
        required=False,
    )

    scale = schema.Choice(
        title=_(u'Scale'),
        required=True,
        default='2',
        vocabulary="collective.ploneqrcode.scale",
    )
class IFeedMixer(IPortletDataProvider):
    """A portlet which aggregates multiple feeds.
    """
    title = schema.TextLine(
            title=_(u"heading_title",
                default=u"Portlet Title"),
            description=_(u"description_title",
                default=u""),
            default=u"",
            required=True)

    cache_timeout = schema.Choice(
            title=_(u"heading_cache_timeout",
                default=u"Maximum time to cache feed data"),
            description=_(u"description_cache_timeout",
                default=u""),
            default="900",
            required=True,
            vocabulary="collective.portlet.feedmixer.timeouts")

    items_shown = schema.Int(
            title=_(u"heading_items_shown",
                default=u"Number of items to display"),
            description=_(u"description_items_shown",
                default=u""),
            default=5,
            required=True)

    feeds = schema.ASCII(
            title=_(u"heading_feeds",
                default=u"URL(s) for all feeds"),
            description=_(u"description_feeds",
                default=u"Enter the URLs for all feeds here, one URL per "
                        u"line. RSS 0.9x, RSS 1.0, RSS 2.0, CDF, Atom 0.3 "
                        u"and ATOM 1.0 feeds are supported."),
            required=True,
            constraint=isUrlList)

    def entries():
        """Return feed entries for all feeds.
Beispiel #17
0
class GoogleNewsSettings(model.Schema):

    """Main settings of this addon"""

    # XXX: default value is declared at profiles/default/registry.xml
    portal_types = schema.List(
        title=_(u'Portal types'),
        description=_(u'Select portal types that will be considered news articles.'),
        value_type=schema.Choice(
            vocabulary=u'plone.app.vocabularies.ReallyUserFriendlyTypes'),
    )

    logo = schema.ASCII(
        title=_(u'Logo image'),
        description=_(
            u"Google News requires Editors' Picks feed logos to follow some "
            u'<a href="{0}">general guidelines</a>. This image will replace '
            u'the logo in all Atom feeds on the site.'.format(EDITORS_PICKS_LINK)
        ),
        required=False,
        constraint=validate_logo,
    )
class IAMPSettings(model.Schema):
    """Schema for the control panel form."""

    form.widget('publisher_logo', NamedImageFieldWidget)
    publisher_logo = schema.ASCII(
        title=_(u'Publisher Logo'),
        description=_(
            u'The logo of the publisher. Should have a wide aspect ratio, '
            u'and should be no wider than 600px, and no taller than 60px.'),
        required=False,
        constraint=is_valid_logo,
    )

    form.widget('amp_analytics', rows=15)
    amp_analytics = schema.Text(
        title=_(u'AMP Analytics'),
        description=_(
            u'The value (in JSON-LD format) of the "amp-analytics" element '
            u'that will be used to measure activity on AMP documents.'),
        required=False,
        default=u'',
        constraint=is_json,
    )
Beispiel #19
0
class IAPISettings(Interface):
    princexml_server_url = schema.TextLine(
        title=u'PrinceXML server url',
        description=u'required in order to convert documents',
        default=u'http://localhost:6543/convert',
        required=False)

    google_maps_api_key = schema.TextLine(title=u'Google Maps API Key',
                                          default=None,
                                          required=False)

    google_api_email = schema.TextLine(title=u'Google API Email',
                                       default=None,
                                       required=False)

    google_api_service_key_file = schema.ASCII(
        title=u"Google API Service Key File",
        description=u'Private key file',
        required=False,
    )

    google_analytics_id = schema.TextLine(
        title=u'Google Analytics ID',
        description=u'for use with gathering content statistics',
        required=False)

    recaptcha_public_key = schema.TextLine(title=u'Recaptcha 3 Public Key',
                                           required=False)

    recaptcha_private_key = schema.TextLine(title=u'Recaptcha 3 Private Key',
                                            required=False)

    aws_s3_key = schema.TextLine(title=u'AWS S3 Key',
                                 required=False,
                                 default=None)

    aws_s3_secret = schema.TextLine(title=u'AWS S3 Secret',
                                    required=False,
                                    default=None)

    aws_s3_bucket_name = schema.TextLine(title=u'AWS S3 Bucket',
                                         required=False,
                                         default=None)

    aws_s3_host_endpoint = schema.TextLine(
        title=u'AWS Host endpoint',
        description=u'Leave empty unless you know what you are doing here.',
        required=False,
        default=None)

    aws_s3_base_url = schema.TextLine(
        title=u'AWS File Base Url',
        description=
        u'If you are providing your own domain name to serve files from',
        required=False,
        default=None)

    plivo_auth_id = schema.TextLine(title=u'Plivo Auth ID',
                                    description=u'Text messaging API',
                                    required=False)

    plivo_auth_token = schema.TextLine(title=u'Plivo Auth Token',
                                       required=False)

    plivo_phone_number = schema.TextLine(
        title=u'Plivo Source Number',
        description=u'For making text messages from',
        required=False)

    etherpad_url = schema.TextLine(title=u'Etherpad Url', required=False)

    etherpad_api_key = schema.TextLine(title=u'Etherpad API Key',
                                       required=False)

    cf_api_key = schema.TextLine(
        title=u'Cloudflare API Key',
        description=u'Setting an API Key here and enabling cache purging '
        u'activates purging against Cloudflare.',
        required=False)

    cf_email = schema.TextLine(
        title=u'Cloudflare Email',
        description=u'One associated with cloudflare api key',
        required=False)

    cf_zone_id = schema.TextLine(title=u'Cloudflare Zone ID', required=False)

    rocket_chat_front_page = schema.TextLine(
        title=u'Rocket.Chat User URL',
        description=u'URL of the Rocket.Chat server to connect to',
        required=False)

    rocket_chat_secret = schema.TextLine(
        title=u'Rocket.Chat secret',
        description=
        u'Text string used to salt Rocket.Chat authentication tokens',
        required=False,
        default=unicode(django_random.get_random_string(64)))
Beispiel #20
0
class IDXTestDocumentSchema(model.Schema):

    # zope.schema fields
    test_ascii_field = schema.ASCII(required=False)
    test_asciiline_field = schema.ASCIILine(required=False)
    test_bool_field = schema.Bool(required=False)
    test_bytes_field = schema.Bytes(required=False)
    test_bytesline_field = schema.BytesLine(required=False)
    test_choice_field = schema.Choice(values=[u"foo", u"bar"], required=False)
    test_choice_field_with_vocabulary = schema.Choice(
        vocabulary=SimpleVocabulary([
            SimpleTerm(u"value1", "token1", u"title1"),
            SimpleTerm(u"value2", "token2", u"title2"),
        ]),
        required=False,
    )
    test_date_field = schema.Date(required=False)
    test_datetime_field = schema.Datetime(required=False)
    test_datetime_tz_field = schema.Datetime(
        required=False,
        defaultFactory=lambda: timezone("Europe/Zurich").localize(
            datetime(2017, 10, 31, 10, 0)),
    )
    test_decimal_field = schema.Decimal(required=False)
    test_dict_field = schema.Dict(required=False)
    test_float_field = schema.Float(required=False)
    test_frozenset_field = schema.FrozenSet(required=False)
    test_int_field = schema.Int(required=False)
    test_list_field = schema.List(required=False)
    test_list_field_with_choice_with_vocabulary = schema.List(
        value_type=schema.Choice(vocabulary=SimpleVocabulary([
            SimpleTerm(u"value1", "token1", u"title1"),
            SimpleTerm(u"value2", "token2", u"title2"),
            SimpleTerm(u"value3", "token3", u"title3"),
        ])),
        required=False,
    )
    test_set_field = schema.Set(required=False)
    test_text_field = schema.Text(required=False)
    test_textline_field = schema.TextLine(required=False)
    test_time_field = schema.Time(required=False)
    test_timedelta_field = schema.Timedelta(required=False)
    test_tuple_field = schema.Tuple(required=False)
    test_nested_list_field = schema.List(required=False,
                                         value_type=schema.Tuple())
    test_nested_dict_field = schema.Dict(required=False,
                                         key_type=schema.ASCIILine(),
                                         value_type=schema.Tuple())
    test_list_choice_with_context_vocabulary_field = schema.List(
        title=u"Field",
        value_type=schema.Choice(
            vocabulary="plone.restapi.testing.context_vocabulary"),
        required=False,
    )

    # plone.app.textfield
    test_richtext_field = RichText(
        required=False, allowed_mime_types=["text/html", "text/plain"])

    # plone.namedfile fields
    test_namedfile_field = namedfile.NamedFile(required=False)
    test_namedimage_field = namedfile.NamedImage(required=False)
    test_namedblobfile_field = namedfile.NamedBlobFile(required=False)
    test_namedblobimage_field = namedfile.NamedBlobImage(required=False)

    # z3c.relationfield
    test_relationchoice_field = RelationChoice(
        required=False, source=CatalogSource(id=["doc1", "doc2"]))
    test_relationlist_field = RelationList(
        required=False,
        value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
    )

    # Test fields for validation
    test_required_field = schema.TextLine(required=True)
    test_readonly_field = schema.TextLine(required=False, readonly=True)
    test_maxlength_field = schema.TextLine(required=False, max_length=10)
    test_constraint_field = schema.TextLine(required=False,
                                            constraint=lambda x: u"00" in x)
    test_datetime_min_field = schema.Datetime(required=False,
                                              min=datetime(2000, 1, 1))
    test_time_min_field = schema.Time(required=False, min=time(1))
    test_timedelta_min_field = schema.Timedelta(required=False,
                                                min=timedelta(100))
    test_list_value_type_field = schema.List(required=False,
                                             value_type=schema.Int())
    test_dict_key_type_field = schema.Dict(required=False,
                                           key_type=schema.Int())

    read_permission(test_read_permission_field="cmf.ManagePortal")
    test_read_permission_field = schema.TextLine(required=False)
    write_permission(test_write_permission_field="cmf.ManagePortal")
    test_write_permission_field = schema.TextLine(required=False)

    read_permission(test_read_permission_field="cmf.ManagePortal")
    test_read_permission_field = schema.TextLine(required=False)

    test_invariant_field1 = schema.TextLine(required=False)
    test_invariant_field2 = schema.TextLine(required=False)

    test_missing_value_field = schema.TextLine(required=False,
                                               missing_value=u"missing",
                                               default=u"default")

    test_missing_value_required_field = schema.TextLine(
        required=True, missing_value=u"missing", default=u"some value")

    @invariant
    def validate_same_value(data):
        if data.test_invariant_field1 != data.test_invariant_field2:
            raise Invalid(u"Must have same values")

    # Test fields with default values
    test_default_value_field = schema.TextLine(required=True,
                                               default=u"Default")

    @provider(IContextAwareDefaultFactory)
    def default_factory(context):
        return u"DefaultFactory"

    test_default_factory_field = schema.TextLine(
        required=True, defaultFactory=default_factory)
Beispiel #21
0
class IGrokForm(IGrokView):
    """Grok form API, inspired by zope.formlib's IFormBaseCustomization.

    We explicitly don't inherit from IFormBaseCustomization because
    that would imply ISubPage with another definition of update() and
    render() than IGrokView has.
    """

    prefix = schema.ASCII(
        constraint=reConstraint(
            '[a-zA-Z][a-zA-Z0-9_]*([.][a-zA-Z][a-zA-Z0-9_]*)*',
            "Must be a sequence of not-separated identifiers"),
        description=u"""Page-element prefix

        All named or identified page elements in a subpage should have
        names and identifiers that begin with a subpage prefix
        followed by a dot.
        """,
        readonly=True,
    )

    def setPrefix(prefix):
        """Update the subpage prefix
        """

    label = interface.Attribute("A label to display at the top of a form")

    status = interface.Attribute("""An update status message

        This is normally generated by success or failure handlers.
        """)

    errors = interface.Attribute(
        """Sequence of errors encountered during validation
        """)

    form_result = interface.Attribute("""Return from action result method
        """)

    form_reset = interface.Attribute(
        """Boolean indicating whether the form needs to be reset
        """)

    form_fields = interface.Attribute("""The form's form field definitions

        This attribute is used by many of the default methods.
        """)

    widgets = interface.Attribute("""The form's widgets

        - set by setUpWidgets

        - used by validate
        """)

    def setUpWidgets(ignore_request=False):
        """Set up the form's widgets.

        The default implementation uses the form definitions in the
        form_fields attribute and setUpInputWidgets.

        The function should set the widgets attribute.
        """

    def validate(action, data):
        """The default form validator

        If an action is submitted and the action doesn't have it's own
        validator then this function will be called.
        """

    template = interface.Attribute("""Template used to display the form
        """)

    def resetForm():
        """Reset any cached data because underlying content may have changed
        """

    def error_views():
        """Return views of any errors.

        The errors are returned as an iterable.
        """

    def applyData(obj, **data):
        """Save form data to an object.
Beispiel #22
0
class ITestInterface( interface.Interface ):
    
    ASCII = schema.ASCII(title=u'ASCII')
    ASCIILine = schema.ASCIILine(title=u'ASCIILine')
    Bool = schema.Bool(title=u'Bool')
class ISiteSchema(ILockSettings):

    site_title = schema.TextLine(
        title=_(u'Site title'),
        description=_(
            u"This shows up in the title bar of "
            u"browsers and in syndication feeds."),
        default=u'Plone site')

    site_logo = schema.ASCII(
        title=_(u"Site Logo"),
        description=_(u"This shows a custom Logo on your Site."),
        required=False,
    )

    exposeDCMetaTags = schema.Bool(
        title=_(u"Expose Dublin Core metadata"),
        description=_(u"Exposes the Dublin Core properties as metatags."),
        default=False,
        required=False)

    enable_sitemap = schema.Bool(
        title=_(u"Expose sitemap.xml.gz"),
        description=_(
            u"Exposes your content as a file "
            u"according to the sitemaps.org standard. You "
            u"can submit this to compliant search engines "
            u"like Google, Yahoo and Microsoft. It allows "
            u"these search engines to more intelligently "
            u"crawl your site."),
        default=False,
        required=False)

    webstats_js = schema.SourceText(
        title=_(u'JavaScript for web statistics support'),
        description=_(
            u"For enabling web statistics support "
            u"from external providers (for e.g. Google "
            u"Analytics). Paste the code snippets provided. "
            u"It will be included in the rendered HTML as "
            u"entered near the end of the page."),
        default=u'',
        required=False)

    toolbar_position = schema.Choice(
        title=_(u'Position where the toolbar is displayed'),
        description=_(
            u"It can be in the side vertical mode "
            u"or in the top horizontal mode"),
        default=u'side',
        vocabulary=SimpleVocabulary([
            SimpleTerm('side', 'side', _(u"Side")),
            SimpleTerm('top', 'top', _(u"Top"))]),
        required=True)

    toolbar_logo = schema.TextLine(
        title=_(u"Site based relative url for toolbar logo"),
        description=_(
            u"This must be a relative url to portal root site. "
            u"By default its /++plone++static/plone-toolbarlogo.svg"),
        default=u'/++plone++static/plone-toolbarlogo.svg',
        required=False,
    )
Beispiel #24
0
    def fields(self):
        fields = field.Fields()
        settings = IFeedSettings(self.context)

        # Javascript-widget
        if settings.enable_select_all:
            fields += field.Fields(
                SelectAllGroupsJavascript(schema.Field(__name__="js",
                                                       required=False),
                                          mode="hidden"))

        # Include form fields, but change the order around.
        fields += field.Fields(ISubscription).select('interests')
        fields['interests'].widgetFactory = InterestsWidget.factory

        if settings.show_name:
            fields += field.Fields(
                schema.TextLine(
                    __name__="name",
                    title=_(u"Name"),
                    required=False,
                ))

        fields += field.Fields(ISubscription).select('email')

        # Add mailinglist as hidden field
        fields += field.Fields(schema.ASCII(__name__="list_id", required=True),
                               mode="hidden")

        context = self.getContent()
        api = getUtility(IApiUtility, context=self.context)
        result = api.list_merge_vars(context.mailinglist)

        for entry in result:
            name = entry['tag'].lower()

            if name in fields:
                continue

            if not entry['show']:
                continue

            # Skip all-uppercase:
            if entry['name'] == entry['name'].upper():
                continue

            field_type = entry['field_type']
            required = entry['req']

            if field_type == 'text':
                factory = schema.TextLine
                options = {}

            elif field_type == 'dropdown':
                factory = schema.Choice
                choices = list(entry['choices'])

                if not required:
                    choices.append(u"")
                    required = True

                options = {
                    'vocabulary':
                    SimpleVocabulary([
                        SimpleTerm(value=value,
                                   token=value.encode('ascii',
                                                      'xmlcharrefreplace'),
                                   title=value or _(u"None"))
                        for value in choices
                    ])
                }

            else:
                continue

            fields += field.Fields(
                factory(__name__=name.encode('utf-8'),
                        default=entry['default'],
                        required=required,
                        title=_(entry['name']),
                        **options))

        return fields
Beispiel #25
0
class IFormField(Interface):
    """Definition of a field to be included in a form

    This should not be confused with a schema field.
    """

    __name__ = schema.ASCII(constraint=reConstraint('[a-zA-Z][a-zA-Z0-9_]*',
                                                    "Must be an identifier"),
                            title=u"Field name",
                            description=u"""\
        This is the name, without any proefix, used for the field.
        It is usually the same as the name of the for field's schem field.
        """)

    field = Attribute("""Schema field that defines the data of the form field
        """)

    prefix = schema.ASCII(
        constraint=reConstraint('[a-zA-Z][a-zA-Z0-9_]*',
                                "Must be an identifier"),
        title=u"Prefix",
        description=u"""\
        Form-field prefix.  The form-field prefix is used to
        disambiguate fields with the same name (e.g. from different
        schema) within a collection of form fields.
        """,
        default="",
    )

    for_display = schema.Bool(title=u"Is the form field for display only?",
                              description=u"""\
        If this attribute has a true value, then a display widget will be
        used for the field even if it is writable.
        """)

    for_input = schema.Bool(title=u"Is the form field for input?",
                            description=u"""\
        If this attribute has a true value, then an input widget will be
        used for the field even if it is readonly.
        """)

    custom_widget = Attribute("""Factory to use for widget construction.

        If not set, normal view lookup will be used.
        """)

    render_context = schema.Choice(
        title=u"Should the rendered value come from the form context?",
        description=u"""\

        If this attribute has a true value, and there is no other
        source of rendered data, then use data from the form context
        to set the rendered value for the widget.  This attribute is
        ignored if:

        - There is user input and user input is not being ignored, or

        - Data for the value is passed to setUpWidgets.

        If the value is true, then it is evaluated as a collection of bit
        flags with the flags:

        DISPLAY_UNWRITEABLE
            If the field isn't writable, then use a display widget

            TODO untested


        SKIP_UNAUTHORIZED
            If the user is not priviledges to perform the requested
            operation, then omit a widget.

            TODO unimplemented

        """,
        vocabulary=schema.vocabulary.SimpleVocabulary.fromValues((
            False,
            True,
            DISPLAY_UNWRITEABLE,
            SKIP_UNAUTHORIZED,
            DISPLAY_UNWRITEABLE | SKIP_UNAUTHORIZED,
        )),
        default=False,
        missing_value=False,
    )

    get_rendered = Attribute("""Object to call to get a rendered value

        This attribute may be set to a callable object or to
        a form method name to call to get a value to be rendered in a
        widget.

        This attribute is ignored if:

        - There is user input and user input is not being ignored, or

        - Data for the value is passed to setUpWidgets.

        """)
Beispiel #26
0
class IExample(model.Schema):
    """Dexterity-Schema with all field-types."""

    # The most used fields
    # textline, text, bool, richtext, email

    fieldset(
        "numberfields",
        label=u"Number fields",
        fields=("int_field", "float_field"),
    )

    fieldset(
        "datetimefields",
        label=u"Date and time fields",
        fields=(
            "datetime_field",
            "date_field",
            "time_field",
            "timedelta_field",
        ),
    )

    fieldset(
        "choicefields",
        label=u"Choice and Multiple Choice fields",
        fields=(
            "choice_field",
            "choice_field_radio",
            "choice_field_select",
            "choice_field_voc",
            "list_field",
            "list_field_checkbox",
            "list_field_select",
            "list_field_voc_unconstrained",
            "tuple_field",
            "set_field",
            "set_field_checkbox",
        ),
    )

    fieldset(
        "relationfields",
        label=u"Relation fields",
        fields=(
            "relationchoice_field",
            "relationlist_field",
            "relationchoice_field_constrained",
            "relationlist_field_constrained",
            "relationlist_field_search_mode",
            "relationchoice_field_select",
            "relationchoice_field_radio",
            "relationlist_field_select",
            "relationlist_field_checkbox",
            "relationchoice_field_ajax_select",
            "relationlist_field_ajax_select",
        ),
    )

    fieldset(
        "uuidrelationfields",
        label=u"Relation widgets with uuids",
        fields=(
            "uuid_choice_field",
            "uuid_list_field",
            "uuid_choice_field_constrained",
            "uuid_list_field_constrained",
            "uuid_list_field_search_mode",
            "uuid_choice_field_select",
            "uuid_choice_field_radio",
            "uuid_list_field_select",
            "uuid_list_field_checkbox",
            "uuid_choice_field_ajax_select",
            "uuid_list_field_ajax_select",
        ),
    )

    fieldset(
        "filefields",
        label=u"File fields",
        fields=("file_field", "image_field"),
    )

    fieldset(
        "otherfields",
        label=u"Other fields",
        fields=(
            "uri_field",
            "sourcetext_field",
            "ascii_field",
            "bytesline_field",
            "asciiline_field",
            "pythonidentifier_field",
            "dottedname_field",
            # 'dict_field',
            # "vocabularyterms_field",
            # "vocabularytermstranslation_field",
            # 'dict_field_with_choice',
        ),
    )

    fieldset(
        "datagrid",
        label=u"Datagrid field",
        fields=("datagrid_field", ),
    )

    primary("title")
    title = schema.TextLine(
        title=u"Primary Field (Textline)",
        description=u"zope.schema.TextLine",
        required=True,
    )

    description = schema.TextLine(
        title=u"Description (Textline)",
        description=u"zope.schema.TextLine",
        required=False,
    )

    text_field = schema.Text(
        title=u"Text Field",
        description=u"zope.schema.Text",
        required=False,
        missing_value=u"",
    )

    textline_field = schema.TextLine(
        title=u"Textline field",
        description=u"A simple input field (schema.TextLine)",
        required=False,
    )

    bool_field = schema.Bool(
        title=u"Boolean field",
        description=u"zope.schema.Bool",
        required=False,
    )

    choice_field = schema.Choice(
        title=u"Choice field",
        description=u"zope.schema.Choice",
        values=[u"One", u"Two", u"Three"],
        required=True,
    )

    directives.widget(choice_field_radio=RadioFieldWidget)
    choice_field_radio = schema.Choice(
        title=u"Choice field with radio boxes",
        description=u"zope.schema.Choice",
        values=[u"One", u"Two", u"Three"],
        required=False,
    )

    choice_field_voc = schema.Choice(
        title=u"Choicefield with values from named vocabulary",
        description=u"zope.schema.Choice",
        vocabulary="plone.app.vocabularies.PortalTypes",
        required=False,
    )

    directives.widget(choice_field_select=SelectFieldWidget)
    choice_field_select = schema.Choice(
        title=u"Choicefield with select2 widget",
        description=u"zope.schema.Choice",
        vocabulary="plone.app.vocabularies.PortalTypes",
        required=False,
    )

    list_field = schema.List(
        title=u"List field",
        description=u"zope.schema.List",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=[],
    )

    directives.widget(list_field_checkbox=CheckBoxFieldWidget)
    list_field_checkbox = schema.List(
        title=u"List field with checkboxes",
        description=u"zope.schema.List",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=[],
    )

    directives.widget(list_field_select=SelectFieldWidget)
    list_field_select = schema.List(
        title=u"List field with select widget",
        description=u"zope.schema.List",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=[],
    )

    list_field_voc_unconstrained = schema.List(
        title=
        u"List field with values from vocabulary but not constrained to them.",
        description=u"zope.schema.List",
        value_type=schema.TextLine(),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "list_field_voc_unconstrained",
        AjaxSelectFieldWidget,
        vocabulary="plone.app.vocabularies.PortalTypes",
        pattern_options={
            "closeOnSelect":
            False,  # Select2 option to leave dropdown open for multiple selection
        },
    )

    tuple_field = schema.Tuple(
        title=u"Tuple field",
        description=u"zope.schema.Tuple",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=(),
    )

    set_field = schema.Set(
        title=u"Set field",
        description=u"zope.schema.Set",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value={},
    )

    directives.widget(set_field_checkbox=CheckBoxFieldWidget)
    set_field_checkbox = schema.Set(
        title=u"Set field with checkboxes",
        description=u"zope.schema.Set",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value={},
    )

    # File fields
    image_field = NamedBlobImage(
        title=u"Image field",
        description=
        u"A upload field for images (plone.namedfile.field.NamedBlobImage)",
        required=False,
    )

    file_field = NamedBlobFile(
        title=u"File field",
        description=
        u"A upload field for files (plone.namedfile.field.NamedBlobFile)",
        required=False,
    )

    # Date and Time fields
    datetime_field = schema.Datetime(
        title=u"Datetime field",
        description=u"Uses a date and time picker (zope.schema.Datetime)",
        required=False,
    )

    date_field = schema.Date(
        title=u"Date field",
        description=u"Uses a date picker (zope.schema.Date)",
        required=False,
    )

    time_field = schema.Time(
        title=u"Time field",
        description=u"zope.schema.Time",
        required=False,
    )

    timedelta_field = schema.Timedelta(
        title=u"Timedelta field",
        description=u"zope.schema.Timedelta",
        required=False,
    )

    # Relation Fields
    relationchoice_field = RelationChoice(
        title=u"Relationchoice field",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )

    relationlist_field = RelationList(
        title=u"Relationlist Field",
        description=u"z3c.relationfield.schema.RelationList",
        default=[],
        value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )

    relationchoice_field_constrained = RelationChoice(
        title=u"Relationchoice field (only allows Documents)",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )
    directives.widget(
        "relationchoice_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document"]},
    )

    relationlist_field_constrained = RelationList(
        title=u"Relationlist Field (only allows Documents and Events)",
        description=u"z3c.relationfield.schema.RelationList",
        default=[],
        value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "relationlist_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document", "Event"]},
    )

    relationlist_field_search_mode = RelationList(
        title=
        u"Relationlist Field in Search Mode (constrained to published Documents and Events)",
        description=u"z3c.relationfield.schema.RelationList",
        default=[],
        value_type=RelationChoice(source=CatalogSource(
            portal_type=["Document", "Event"], review_state="published")),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "relationlist_field_search_mode",
        RelatedItemsFieldWidget,
        pattern_options={
            "baseCriteria":
            [  # This is a optimization that limits the catalog-query
                {
                    "i": "portal_type",
                    "o": "plone.app.querystring.operation.selection.any",
                    "v": ["Document", "Event"],
                },
                {
                    "i": "review_state",
                    "o": "plone.app.querystring.operation.selection.any",
                    "v": "published",
                },
            ],
            "mode":
            "search",
        },
    )

    # From here on we use other widgets than the default RelatedItemsFieldWidget

    # This one also works in Volto!
    # All other options use the default ObjectWidget in Volto so far.
    relationchoice_field_select = RelationChoice(
        title=u"RelationChoice with Select Widget",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state": "published",
        }),
        required=False,
    )
    directives.widget(
        "relationchoice_field_select",
        SelectFieldWidget,
    )

    relationchoice_field_radio = RelationChoice(
        title=
        u"RelationChoice with Radio Widget (and customized title-template)",
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event"],
                "review_state": "published",
            },
            title_template="{brain.Title}",
        ),  # Set a custom vocabulary item title
        required=False,
    )
    directives.widget(
        "relationchoice_field_radio",
        RadioFieldWidget,
    )

    relationlist_field_select = RelationList(
        title=
        u"RelationList with select widget with items from a named vocabulary",
        value_type=RelationChoice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "relationlist_field_select",
        SelectFieldWidget,
        pattern_options={
            "closeOnSelect":
            False,  # Select2 option to leave dropdown open for multiple selection
        },
    )

    relationlist_field_checkbox = RelationList(
        title=u"RelationList with Checkboxes",
        value_type=RelationChoice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "relationlist_field_checkbox",
        CheckBoxFieldWidget,
    )

    relationchoice_field_ajax_select = RelationChoice(
        title=u"Relationchoice Field with AJAXSelect",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        required=False,
    )
    directives.widget(
        "relationchoice_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
        },
    )

    relationlist_field_ajax_select = RelationList(
        title=u"Relationlist Field with AJAXSelect",
        description=u"z3c.relationfield.schema.RelationList",
        value_type=RelationChoice(vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state":
            "published",
        })),
        required=False,
    )
    directives.widget(
        "relationlist_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event", "Folder"],
            },
            title_template="{brain.Type}: {brain.Title} at {path}",
        ),  # Custom item rendering
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
        },
    )

    # These look like relationsfields (see above) but only store the uuid(s) of the selected target
    # as a string in a the field instead of a RelationValue.
    # A good way to use these is in combination with a index that allows you to query these connenctions.
    uuid_choice_field = schema.Choice(
        title=u"Choice field with RelatedItems widget storing uuids",
        description=u"schema.Choice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )
    directives.widget("uuid_choice_field", RelatedItemsFieldWidget)

    uuid_list_field = schema.List(
        title=u"List Field with RelatedItems widget storing uuids",
        description=u"schema.List",
        default=[],
        value_type=schema.Choice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )
    directives.widget("uuid_list_field", RelatedItemsFieldWidget)

    uuid_choice_field_constrained = schema.Choice(
        title=
        u"Choice field with RelatedItems widget storing uuids (only allows Documents)",
        description=u"schema.Choice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )
    directives.widget(
        "uuid_choice_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document"]},
    )

    uuid_list_field_constrained = schema.List(
        title=
        u"List Field with RelatedItems widget storing uuids (only allows Documents and Events)",
        description=u"schema.List",
        default=[],
        value_type=schema.Choice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "uuid_list_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document", "Folder"]},
    )

    uuid_list_field_search_mode = schema.List(
        title=
        u"List Field with RelatedItems widget in Search Mode storing uuids",
        description=u"schema.List",
        default=[],
        value_type=schema.Choice(source=CatalogSource(
            portal_type=["Document", "Event"], review_state="published")),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "uuid_list_field_search_mode",
        RelatedItemsFieldWidget,
        pattern_options={
            "selectableTypes": ["Document", "Folder"],
            "basePath": "",  # Start the search at the portal root
            "mode": "search",
        },
    )

    # From here on we use other widgets than the default RelatedItemsFieldWidget

    uuid_choice_field_select = schema.Choice(
        title=u"UUID Choice with select widget storing uuids",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state": "published",
        }),
        required=False,
    )
    directives.widget(
        "uuid_choice_field_select",
        SelectFieldWidget,
    )

    uuid_choice_field_radio = schema.Choice(
        title=u"RelationChoice with Radio widget storing uuids",
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event"],
                "review_state": "published",
            },
            title_template="{brain.Title}",
        ),  # Set a custom vocabulary item title
        required=False,
    )
    directives.widget(
        "uuid_choice_field_radio",
        RadioFieldWidget,
    )

    uuid_list_field_select = schema.List(
        title=
        u"RelationList with select widget with items from a named vocabulary storing uuids",
        value_type=schema.Choice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "uuid_list_field_select",
        SelectFieldWidget,
        pattern_options={
            "closeOnSelect":
            False,  # Select2 option to leave dropdown open for multiple selection
        },
    )

    uuid_list_field_checkbox = schema.List(
        title=u"RelationList with Checkboxes storing uuids",
        value_type=schema.Choice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "uuid_list_field_checkbox",
        CheckBoxFieldWidget,
    )

    uuid_choice_field_ajax_select = schema.Choice(
        title=u"Relationchoice Field with AJAXSelect storing uuids",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        required=False,
    )
    directives.widget(
        "uuid_choice_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
        },
    )

    uuid_list_field_ajax_select = schema.List(
        title=u"Relationlist Field with AJAXSelect storing uuids",
        description=u"z3c.relationfield.schema.RelationList",
        value_type=schema.Choice(vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state":
            "published",
        })),
        required=False,
    )
    directives.widget(
        "uuid_list_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event"],
            },
            title_template="{brain.Type}: {brain.Title} at {path}",
        ),  # Custom item rendering
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
            "closeOnSelect":
            False,  # - Leave dropdown open for multiple selection
        },
    )

    # Number fields
    int_field = schema.Int(
        title=u"Integer Field (e.g. 12)",
        description=u"zope.schema.Int",
        required=False,
    )

    float_field = schema.Float(
        title=u"Float field, e.g. 12.7",
        description=u"zope.schema.Float",
        required=False,
    )

    # Text fields
    email_field = Email(
        title=u"Email field",
        description=
        u"A simple input field for a email (plone.schema.email.Email)",
        required=False,
    )

    uri_field = schema.URI(
        title=u"URI field",
        description=u"A simple input field for a URLs (zope.schema.URI)",
        required=False,
    )

    richtext_field = RichText(
        title=u"RichText field",
        description=
        u"This uses a richtext editor. (plone.app.textfield.RichText)",
        max_length=2000,
        required=False,
    )

    sourcetext_field = schema.SourceText(
        title=u"SourceText field",
        description=u"zope.schema.SourceText",
        required=False,
    )

    ascii_field = schema.ASCII(
        title=u"ASCII field",
        description=u"zope.schema.ASCII",
        required=False,
    )

    bytesline_field = schema.BytesLine(
        title=u"BytesLine field",
        description=u"zope.schema.BytesLine",
        required=False,
    )

    asciiline_field = schema.ASCIILine(
        title=u"ASCIILine field",
        description=u"zope.schema.ASCIILine",
        required=False,
    )

    pythonidentifier_field = schema.PythonIdentifier(
        title=u"PythonIdentifier field",
        description=u"zope.schema.PythonIdentifier",
        required=False,
    )

    dottedname_field = schema.DottedName(
        title=u"DottedName field",
        description=u"zope.schema.DottedName",
        required=False,
    )

    # dict_field = schema.Dict(
    #     title=u'Dict field',
    #     description=u"zope.schema.Dict",
    #     required=False,
    #     key_type=schema.TextLine(
    #         title=u'Key',
    #         required=False,
    #     ),
    #     value_type=schema.TextLine(
    #         title=u'Value',
    #         required=False,
    #     ),
    # )

    # vocabularyterms_field = Dict(  # we use the plone.schema field Dict not zope.schema field to use the attribute 'widget'
    #     title=u"Vocabulary terms field",
    #     description=u"plone.schema.Dict field with value_type schema.TextLine and frontend widget 'VocabularyTermsWidget'",
    #     required=False,
    #     key_type=schema.TextLine(
    #         title=u"Key",
    #         required=False,
    #     ),
    #     value_type=schema.TextLine(
    #         title=u"Value",
    #         required=False,
    #     ),
    #     widget="vocabularyterms",  # we use the widget attribute to apply the frontend widget VocabularyWidget
    # )

    # vocabularytermstranslation_field = Dict(  # we use the plone.schema field Dict not zope.schema field to use the attribute 'widget'
    #     title=u"Vocabulary terms field with translations",
    #     description=u"plone.schema.Dict field with value_type Dict and frontend widget 'VocabularyTermsWidget'",
    #     required=False,
    #     key_type=schema.TextLine(
    #         title=u"Key",
    #         required=False,
    #     ),
    #     value_type=Dict(  # we use the plone.schema field Dict not zope.schema field to use the attribute 'widget'
    #         title=u"Term translation",
    #         description=u"plone.schema.Dict field for translations of vocabulary term",
    #         required=True,
    #         key_type=schema.TextLine(
    #             title=u"Key",
    #             required=False,
    #         ),
    #         value_type=schema.TextLine(
    #             title=u"Value",
    #             required=False,
    #         ),
    #     ),
    #     widget="vocabularyterms",  # we use the widget attribute to apply the frontend widget VocabularyWidget
    # )

    # dict_field_with_choice = schema.Dict(
    #     title=u'Dict field with key and value as choice',
    #     description=u"zope.schema.Dict",
    #     required=False,
    #     key_type=schema.Choice(
    #         title=u'Key',
    #         values=[u'One', u'Two', u'Three'],
    #         required=False,
    #         ),
    #     value_type=schema.Set(
    #         title=u'Value',
    #         value_type=schema.Choice(
    #             values=[u'Beginner', u'Advanced', u'Professional'],
    #             ),
    #         required=False,
    #         missing_value={},
    #         ),
    #     )

    datagrid_field = schema.List(
        title=u"Datagrid field",
        description=u"schema.List",
        value_type=DictRow(title=u"Table", schema=IMyRowSchema),
        default=[],
        required=False,
    )
    directives.widget("datagrid_field", DataGridFieldFactory)
Beispiel #27
0
class ISocialLikeSettings(model.Schema):
    """Schema for the control panel form."""

    enabled_portal_types = schema.Tuple(
        title=_(u'Content types'),
        description=_(
            u'help_portal_types',
            default=u'Please select content types in which the '
            u'viewlet will be applied.',
        ),
        required=True,
        default=DEFAULT_ENABLED_CONTENT_TYPES,
        value_type=schema.Choice(
            vocabulary='plone.app.vocabularies.ReallyUserFriendlyTypes'),
    )

    plugins_enabled = schema.Tuple(
        title=_(u'Plugins'),
        description=_(
            u'help_enabled_plugins',
            default=u'Please select which plugins will be used',
        ),
        required=False,
        default=DEFAULT_PLUGINS_ENABLED,
        value_type=schema.Choice(vocabulary='sc.social.likes.plugins'),
    )

    folderish_templates = schema.List(
        title=_(u'Folderish Templates'),
        description=_(
            u'help_folderish_templates',
            default=u'If a folderish has one of these templates as default '
            u'view, the viewlet is showed even if the folderish type '
            u'is not selected in Content types.',
        ),
        required=False,
        value_type=schema.TextLine(),
    )

    validation_enabled = schema.Bool(
        title=_(u'Enable content validation?'),
        description=
        _(u'help_validation_enabled',
          default=
          u'Enables validation to check if content follows social networks sharing best practices. '
          u'The validation includes title, description and lead image fields. '
          u'This feature is only available for Dexterity-based content types.'
          ),
        default=True,
    )

    typebutton = schema.Choice(
        title=_(u'Button style'),
        description=_(
            u'help_selected_buttons',
            default=u'Choose your button style.',
        ),
        required=True,
        default=u'horizontal',
        vocabulary=TypeButtonVocabulary,
    )

    do_not_track = schema.Bool(
        title=_(u'Do not track users'),
        description=_(
            u'help_do_not_track',
            default=u'If enabled, the site will not provide advanced sharing '
            u'widgets; simple links will be used instead.\n'
            u'This will limit user experience and features '
            u"(like the share count) but will enhance users' privacy: "
            u'no 3rd party cookies will be sent to users.'),
        default=False,
    )

    model.fieldset(
        'open_graph',
        label=u'Open Graph',
        fields=[
            'canonical_domain',
            'fallback_image',
        ],
    )

    canonical_domain = schema.URI(
        title=_(u'Canonical domain'),
        description=
        _(u'help_canonical_domain',
          default=
          u'The canonical domain will be used to construct the canonical URL (<code>og:url</code> property) of portal objects. '
          u'Use the domain name of your site (e.g. <strong>http://www.example.org</strong> or <strong>https://www.example.org</strong>). '
          u'Facebook will use the canonical URL to ensure that all actions such as likes and shares aggregate at the same URL rather than spreading across multiple versions of a page. '
          u'Check <a href="https://pypi.python.org/pypi/sc.social.like">package documentation</a> for more information on how to use this feature.'
          ),
        required=True,
        constraint=validate_canonical_domain,
    )

    form.widget('fallback_image', NamedImageFieldWidget)
    fallback_image = schema.ASCII(
        title=_(u'Fallback image'),
        description=
        _(u'help_fallback_image',
          default=
          u'Content without a lead image will use this image as fallback (<code>og:image</code> property). '
          u'There could be a delay of up to 2 minutes when replacing this image.'
          ),
        required=False,
        constraint=validate_og_fallback_image,
    )

    model.fieldset(
        'facebook',
        label=u'Facebook',
        fields=[
            'fbaction',
            'facebook_username',
            'facebook_app_id',
            'fbbuttons',
            'fbshowlikes',
            'facebook_prefetch_enabled',
        ],
    )

    fbaction = schema.Choice(
        title=_(u'Verb to display'),
        description=_(u'help_verb_display',
                      default=u'The verb to display in the Facebook button. '
                      u'Currently only "like" and "recommend" are '
                      u'supported.'),
        required=True,
        default=u'like',
        vocabulary=FacebookVerbsVocabulary,
    )

    facebook_username = schema.ASCIILine(
        title=_(u'Admins'),
        description=_(u'help_admins',
                      default=u'A comma-separated list of either the '
                      u'Facebook IDs of page administrators.'),
        required=False,
        default='',
    )

    facebook_app_id = schema.ASCIILine(
        title=_(u'Application ID'),
        description=
        _(u'help_appid',
          default=u'A Facebook Platform application ID.\n'
          u'This is required when the \"Do not track users\" option is enabled and for the '
          u'Facebook share icon to be displayed. See https://developers.facebook.com/docs/apps#register'
          ),
        required=False,
        default='',
    )

    fbbuttons = schema.Tuple(
        title=_(u'Facebook buttons'),
        description=_(
            u'help_fbbuttons',
            default=u'Select buttons to be shown',
        ),
        value_type=schema.Choice(vocabulary=FacebookButtonsVocabulary),
        required=True,
        default=(u'Like', ),
    )

    fbshowlikes = schema.Bool(
        title=_(u'Show number of likes'),
        description=_(
            u'help_show_likes',
            default=u'If enabled, the Facebook button will show the number of '
            u'Facebook users who have already liked this page.'),
        default=True,
    )

    facebook_prefetch_enabled = schema.Bool(
        title=_(u'Enable Facebook prefetch?'),
        description=_(
            u'help_facebook_prefetch_enabled',
            default=u'If enabled, an event is triggered to make Facebook '
            u'crawler scrape and cache metadata every time a new '
            u'piece content is published and every time published '
            u'content is edited. '
            u'This will keep the metadata updated on Facebook always.'),
        default=False,
    )

    model.fieldset('twitter', label=u'Twitter', fields=['twitter_username'])

    twitter_username = schema.ASCIILine(
        title=_(u'Twitter nick'),
        description=_(
            u'help_your_twitter_nick',
            default=u'Enter your twitter nick. eg. simplesconsultoria'),
        required=False,
        default='',
    )
Beispiel #28
0
class IAPISettings(Interface):
    princexml_server_url = schema.TextLine(
        title=u'PrinceXML server url',
        description=u'required in order to convert documents',
        default=u'http://localhost:6543/convert',
        required=False)

    google_maps_api_key = schema.TextLine(title=u'Google Maps API Key',
                                          default=None,
                                          required=False)

    google_api_email = schema.TextLine(title=u'Google API Email',
                                       default=None,
                                       required=False)

    google_api_service_key_file = schema.ASCII(
        title=u"Google API Service Key File",
        description=u'Private key file',
        required=False,
    )

    google_analytics_id = schema.TextLine(
        title=u'Google Analytics ID',
        description=u'for use with gathering content statistics',
        required=False)

    gtm_id = schema.TextLine(title=u'Google Tag Manager Container ID',
                             description=u'Provided by Google',
                             required=False)

    gtm_enabled = schema.Bool(
        title=u'Enable Google Tag Manager Throughout Site', default=False)

    recaptcha_public_key = schema.TextLine(title=u'Recaptcha 3 Public Key',
                                           required=False)

    recaptcha_private_key = schema.TextLine(title=u'Recaptcha 3 Private Key',
                                            required=False)

    aws_s3_key = schema.TextLine(title=u'AWS S3 Key',
                                 required=False,
                                 default=None)

    aws_s3_secret = schema.TextLine(title=u'AWS S3 Secret',
                                    required=False,
                                    default=None)

    aws_s3_bucket_name = schema.TextLine(title=u'AWS S3 Bucket',
                                         required=False,
                                         default=None)

    aws_s3_host_endpoint = schema.TextLine(
        title=u'AWS Host endpoint',
        description=u'Leave empty unless you know what you are doing here.',
        required=False,
        default=None)

    aws_s3_base_url = schema.TextLine(
        title=u'AWS File Base Url',
        description=
        u'If you are providing your own domain name to serve files from',
        required=False,
        default=None)

    plivo_auth_id = schema.TextLine(title=u'Plivo Auth ID',
                                    description=u'Text messaging API',
                                    required=False)

    plivo_auth_token = schema.TextLine(title=u'Plivo Auth Token',
                                       required=False)

    plivo_phone_number = schema.TextLine(
        title=u'Plivo Source Number',
        description=u'For making text messages from',
        required=False)

    etherpad_url = schema.TextLine(
        title=u'Etherpad URL',
        description=
        u'The full address of your Etherpad server, e.g. http://127.0.0.1:9001',
        required=False)

    etherpad_api_key = schema.TextLine(
        title=u'Etherpad API Key',
        description=
        u'The hexadecimal string taken from your Etherpad installation'
        's APIKEY.txt',
        required=False)

    cf_api_key = schema.TextLine(
        title=u'Cloudflare API Key',
        description=u'Setting an API Key here and enabling cache purging '
        u'activates purging against Cloudflare.',
        required=False)

    cf_email = schema.TextLine(
        title=u'Cloudflare Email',
        description=u'One associated with cloudflare api key',
        required=False)

    cf_zone_id = schema.TextLine(title=u'Cloudflare Zone ID', required=False)

    rocket_chat_front_page = schema.TextLine(
        title=u'Rocket.Chat User URL',
        description=u'URL of the Rocket.Chat server to connect to',
        required=False)

    rocket_chat_secret = schema.TextLine(
        title=u'Rocket.Chat secret',
        description=
        u'Text string used to salt Rocket.Chat authentication tokens',
        required=False,
        default=unicode(django_random.get_random_string(64)))

    matomo_base_url = schema.URI(
        title=u'Matomo instance base URL',
        description=u'used to query social media share outlinks via Matomo API, '
        'e.g. https://castlecms.innocraft.cloud',
        default=None,
        required=False)

    matomo_token_auth = schema.TextLine(
        title=u'Matomo authentication token',
        description=
        u'from your Matomo account settings, under Platform > API, User Authentication.',
        default=u'',
        required=False)

    matomo_site_id = schema.TextLine(
        title=u'Matomo Site ID',
        description=
        u'from your Matomo account settings, under Websites > Manage.',
        default=u'1',
        required=False)
Beispiel #29
0
class IDXTestDocumentSchema(model.Schema):

    # zope.schema fields
    test_ascii_field = schema.ASCII(required=False)
    test_asciiline_field = schema.ASCIILine(required=False)
    test_bool_field = schema.Bool(required=False)
    test_bytes_field = schema.Bytes(required=False)
    test_bytesline_field = schema.BytesLine(required=False)
    test_choice_field = schema.Choice(values=[u'foo', u'bar'], required=False)
    test_date_field = schema.Date(required=False)
    test_datetime_field = schema.Datetime(required=False)
    test_datetime_tz_field = schema.Datetime(
        required=False,
        defaultFactory=lambda: timezone("Europe/Zurich").localize(
            datetime(2017, 10, 31, 10, 0)))
    test_decimal_field = schema.Decimal(required=False)
    test_dict_field = schema.Dict(required=False)
    test_float_field = schema.Float(required=False)
    test_frozenset_field = schema.FrozenSet(required=False)
    test_int_field = schema.Int(required=False)
    test_list_field = schema.List(required=False)
    test_set_field = schema.Set(required=False)
    test_text_field = schema.Text(required=False)
    test_textline_field = schema.TextLine(required=False)
    test_time_field = schema.Time(required=False)
    test_timedelta_field = schema.Timedelta(required=False)
    test_tuple_field = schema.Tuple(required=False)
    test_nested_list_field = schema.List(
        required=False, value_type=schema.Tuple())
    test_nested_dict_field = schema.Dict(
        required=False, key_type=schema.ASCIILine(), value_type=schema.Tuple())
    test_list_choice_with_context_vocabulary_field = schema.List(
        title=u'Field',
        value_type=schema.Choice(
            vocabulary='plone.restapi.testing.context_vocabulary'),
        required=False)

    # plone.app.textfield
    test_richtext_field = RichText(
        required=False, allowed_mime_types=['text/html', 'text/plain'])

    # plone.namedfile fields
    test_namedfile_field = namedfile.NamedFile(required=False)
    test_namedimage_field = namedfile.NamedImage(required=False)
    test_namedblobfile_field = namedfile.NamedBlobFile(required=False)
    test_namedblobimage_field = namedfile.NamedBlobImage(required=False)

    # z3c.relationfield
    test_relationchoice_field = RelationChoice(
        required=False, source=CatalogSource(id=['doc1', 'doc2']))
    test_relationlist_field = RelationList(
        required=False, value_type=RelationChoice(
            vocabulary="plone.app.vocabularies.Catalog"))

    # Test fields for validation
    test_required_field = schema.TextLine(required=True)
    test_readonly_field = schema.TextLine(required=False, readonly=True)
    test_maxlength_field = schema.TextLine(required=False, max_length=10)
    test_constraint_field = schema.TextLine(required=False,
                                            constraint=lambda x: u'00' in x)
    test_datetime_min_field = schema.Datetime(required=False,
                                              min=datetime(2000, 1, 1))
    test_time_min_field = schema.Time(required=False, min=time(1))
    test_timedelta_min_field = schema.Timedelta(required=False,
                                                min=timedelta(100))
    test_list_value_type_field = schema.List(required=False,
                                             value_type=schema.Int())
    test_dict_key_type_field = schema.Dict(required=False,
                                           key_type=schema.Int())

    read_permission(test_read_permission_field='cmf.ManagePortal')
    test_read_permission_field = schema.TextLine(required=False)
    write_permission(test_write_permission_field='cmf.ManagePortal')
    test_write_permission_field = schema.TextLine(required=False)

    read_permission(test_read_permission_field='cmf.ManagePortal')
    test_read_permission_field = schema.TextLine(required=False)

    test_invariant_field1 = schema.TextLine(required=False)
    test_invariant_field2 = schema.TextLine(required=False)

    @invariant
    def validate_same_value(data):
        if data.test_invariant_field1 != data.test_invariant_field2:
            raise Invalid(u'Must have same values')

    # Test fields with default values
    test_default_value_field = schema.TextLine(
        required=True, default=u'Default')

    @provider(IContextAwareDefaultFactory)
    def default_factory(context):
        return u'DefaultFactory'

    test_default_factory_field = schema.TextLine(
        required=True, defaultFactory=default_factory)
class IGoogleDocsViewerSettings(interface.Interface):
    """Settings"""

    cssstyle = schema.ASCII(title=u"CSS Style", default='border: none;')
    width = schema.ASCIILine(title=u"Width", default='620')
    height = schema.ASCIILine(title=u"Height", default='620')