Пример #1
0
class IModelDescriptorField(interface.Interface):
    # name
    # label
    # description
    modes = schema.ASCIILine(
        title=u"View Usage Modes for Field",
        description=u"Pipe separated string of different modes.. "
        "view|edit|add|listing|search are all valid"
        # !+PIPE(mr, nov-2010) get rid of it, use whitespace instead?
    )
    # property
    listing_column = schema.Object(
        interface.Interface,
        title=u"A Custom Column Widget for Listing Views",
        required=False)
    view_widget = schema.Object(
        interface.Interface,
        title=u"A Custom Widget Factory for Read Views",
        required=False)
    edit_widget = schema.Object(
        interface.Interface,
        title=u"A Custom Widget Factory for Write Views",
        required=False,
    )
    add_widget = schema.Object(interface.Interface,
                               title=u"A Custom Widget Factory for Add Views",
                               required=False)
    search_widget = schema.ASCIILine(title=u"A Custom Search Widget Factory",
                                     required=False)
    ''' !+FIELD_PERMISSIONS(mr, nov-2010) these params are deprecated -- when 
Пример #2
0
class IFavoritingManager(interface.Interface):
    """The main component API"""

    context = schema.Object(title=u"Context", schema=IContentish)
    request = schema.Object(title=u"Request", schema=IRequest)

    def get(query=None):
        """Return the list of all content favorited by the current user.
        'query' is an optional dict that will be passed to the catalog search
        """

    def add():
        """add the current context to the favorites of the current user"""

    def rm():
        """Remove the current context from the favorites."""

    def isin():
        """Return True if the current context is in the favorites of the
        current user"""

    def how_many():
        """return the number of stars for this item"""

    def who_stars_it():
        """return the list of userid who stars this item"""
Пример #3
0
class IStressAnalysis(Interface):
    """Frontend to the LEAM Stress Analysis Model"""

    # -*- schema definition goes here -*-
    layer = schema.Object(
        title=_(u"GIS Layer"),
        required=True,
        description=_(
            u"A GIS layer with the environmentally sensitive areas."),
        schema=Interface,  # specify the interface(s) of the addable types here
    )
    #
    scenario = schema.Object(
        title=_(u"LUC Scenario"),
        required=True,
        description=_(
            u"An existing LUC Scenario with it's associated probability maps."
        ),
        schema=Interface,  # specify the interface(s) of the addable types here
    )
    #
    section = schema.Object(
        title=_(u"Section Map"),
        required=False,
        description=_(u"Section layer used to split the sensative layer."),
        schema=Interface,  # specify the interface(s) of the addable types here
    )
Пример #4
0
class IFormWrapper(Interface):
    """Form wrapper class.

    This class allows "two-step" rendering, with an outer view rendering
    part of the page and the form class rendering the form area.

    In Zope < 2.12, this is the only way to get z3c.form support, because
    the view class takes care of the acquisition requirement.

    In Zope 2.12 and later, this approach is optional: you may register the
    form class directly as a browser view.
    """
    def update():
        """We use the content provider update/render couple.
        """

    def render():
        """We use the content provider update/render couple.
        """

    form = Attribute("The form class. Should be set at class level")

    form_instance = schema.Object(
        title=u"Instance of the form being rendered",
        description=u"Set by the wrapper code during __init__()",
        readonly=True,
        schema=IForm)

    index = schema.Object(title=u"Page template instance",
                          description=(u"If not set, a template will be found "
                                       u"via an adapter lookup"),
                          required=False,
                          schema=IPageTemplate)
    def test_serialize(self):
        desB = IDeserializer(schema.Object(schema=ITestObjectB))
        serA = ISerializer(schema.Object(schema=ITestObjectA))
        serB = ISerializer(schema.Object(schema=ITestObjectB))

        obj = TestObjectA()
        obj.fish = u"haddock"
        self.assertEqual(serA(obj, None), dict(
            _class="transmogrify.dexterity.tests.testconverters_object.TestObjectA",
            fish=u"haddock",
        ))

        # Recurse into attributes
        filestore = {}
        obj = desB(dict(
            title=u'A hairy section',
            cowtent=dict(data=u'Some nice text', contenttype='scroll/dead-sea'),
            _class="transmogrify.dexterity.tests.testconverters_object.TestObjectB",
        ), filestore, None)
        self.assertEqual(serB(obj, filestore), dict(
            _class="transmogrify.dexterity.tests.testconverters_object.TestObjectB",
            title=u'A hairy section',
            cowtent=dict(
                file='_field_cowtent_cowtent',
                encoding='utf-8',
                contenttype='scroll/dead-sea',
            ),
        ))
Пример #6
0
class IBehavior(Interface):
    """A description of a behavior. These should be registered as named
    utilities. There should also be an adapter factory registered, probably
    using IBehaviorAdapterFactory.
    """

    title = schema.TextLine(title=u"Short title of the behavior",
                            required=True)

    description = schema.Text(title=u"Longer description of the behavior",
                              required=False)

    interface = schema.Object(title=u"Interface describing this behavior",
                              required=True,
                              schema=IInterface)

    marker = schema.Object(
        title=u"Marker interface for objects sporting this behavior",
        description=u"Due to the persistent nature of marker interfaces, "
        u"you should only use this if you really need it, e.g. "
        u"to support specific view or viewlet registrations. "
        u"Subtypes will typically be set when an object is "
        u"created",
        required=False,
        schema=IInterface)

    factory = schema.Object(title=u"An adapter factory for the behavior",
                            required=True,
                            schema=Interface)
    def test_deserialise(self):
        desA = IDeserializer(schema.Object(schema=ITestObjectA))
        desB = IDeserializer(schema.Object(schema=ITestObjectB))

        obj = self.deserialize(desA, dict(fish=u'moo'))
        self.assertEqual(obj.__class__, TestObjectA)
        self.assertEqual(obj.fish, u'moo')

        # We recurseivly deserialize
        obj = self.deserialize(desB, dict(
            title=u'A nice section',
            cowtent=dict(data=u'Some nice text', contenttype='scroll/dead-sea')
        ))
        self.assertEqual(obj.__class__, TestObjectB)
        self.assertEqual(obj.title, u'A nice section')
        self.assertEqual(obj.cowtent.__class__, RichTextValue)
        self.assertEqual(obj.cowtent.raw, u'Some nice text')
        self.assertEqual(obj.cowtent.mimeType, 'scroll/dead-sea')

        # Missing values are okay
        obj = self.deserialize(desB, dict(
            title=u'Another section',
        ))
        self.assertEqual(obj.__class__, TestObjectB)
        self.assertEqual(obj.title, u'Another section')
        self.assertEqual(obj.cowtent.__class__, RichTextValue)
        self.assertEqual(obj.cowtent.raw, u'')
        self.assertEqual(obj.cowtent.mimeType, 'text/html')
Пример #8
0
class ISearchAPI(IIterableMapping, IPublishTraverse):
    """
    Search API interface: common API for over-the-web (JSON) use and
    use in Python.  This interface is an entry point for specific
    search-related capabililties for querying uu.formlibrary form data
    and constructing search forms (dynamically, usually via JavaScript)
    for query construction.

    Has mapping interface listing names of capabilities, along with
    capability object values.
    """

    version = schema.Int(
        readonly=True,
        default=API_VERSION,
        )

    comparators = schema.Object(
        title=u'Comparators',
        description=u'Comparators metadata capability; this is, '
                    u'in theory, independent of the context.',
        schema=IComparators,
        )

    fields = schema.Object(
        title=u'Searchable fields',
        description=u'Field information metadata capability, '
                    u'dependent on context for schema information.',
        schema=ISearchableFields,
        )

    def __call__(*args, **kwargs):
        """
Пример #9
0
class IQuizInformation(Interface):
    """Information concerning a student
    """

    quiz_id = schema.Int(
        title=_(u"Quiz identifier"),
        description=_(u"A unique id for a question requested by a student."),
        required=True,
        readonly=True)

    studentinformation = schema.Object(title=_(u"Student"),
                                       schema=IStudentInformation,
                                       required=True,
                                       readonly=True)
    questioninformation = schema.Object(title=_(u"Question"),
                                        schema=IQuestionInformation,
                                        required=True,
                                        readonly=True)
    quiz_location = schema.TextLine(title=_(u"Lecture Url"), )

    quiz_time = schema.Date(title=_(u"Date/Time when question requested"), )
    student_answer = schema.Int(
        title=_(u"Id of student answer"),
        description=_(u"Id of the answer the student gave."),
    )
    answertime = schema.Date(title=_(u"Date/Time when question answered"), )
Пример #10
0
class IModelDescriptorField(interface.Interface):
    # name
    # label
    # description
    modes = schema.ASCIILine(
        title=u"View Usage Modes for Field",
        description=u"Whitespace separated string of different modes."
    )
    # property
    listing_column = schema.Object(interface.Interface,
        title=u"A Custom Column Widget for Listing Views",
        required=False
    )
    # !+LISTING_WIDGET(mr, nov-2010) why inconsistently named "listing_column"?
    view_widget = schema.Object(interface.Interface,
        title=u"A Custom Widget Factory for Read Views",
        required=False
    )
    edit_widget = schema.Object(interface.Interface,
        title=u"A Custom Widget Factory for Write Views",
        required=False,
    )
    add_widget = schema.Object(interface.Interface,
        title=u"A Custom Widget Factory for Add Views",
        required=False
    )
    search_widget = schema.ASCIILine(
        title=u"A Custom Search Widget Factory",
        required=False
    )
    ''' !+FIELD_PERMISSIONS(mr, nov-2010) these params are deprecated -- when 
Пример #11
0
class IBehavior(Interface):
    """A description of a behavior. These should be registered as named
    utilities. There should also be an adapter factory registered, probably
    using IBehaviorAdapterFactory.
    """

    title = schema.TextLine(title=u'Short title of the behavior',
                            required=True)

    description = schema.Text(title=u'Longer description of the behavior',
                              required=False)

    name = schema.TextLine(
        title=u'Readable short name to be used for behavior lookup',
        description=u'E.g. plone.somebehavior. If not given the full dotted '
        u'name of the interfaces is used for lookup instead.'
        u'Recommended, but due to BBB not required.',
        required=False)

    interface = schema.Object(title=u'Interface describing this behavior',
                              required=True,
                              schema=IInterface)

    marker = schema.Object(
        title=u'Marker interface for objects sporting this behavior',
        description=u'Markers are persisted in the ZODB. '
        u'Required when a factory is given, because the factory '
        u'is an adapter adapting the the marker and providing the '
        u'"interface" of this behavior.',
        required=False,
        schema=IInterface)

    factory = schema.Object(title=u'An adapter factory for the behavior',
                            required=True,
                            schema=Interface)
Пример #12
0
class IVersionEvent(IObjectEvent):
    """
    a versioning event
    """

    versioned = schema.Object(IVersioned)
    version = schema.Object(IVersion)
    message = schema.Text(description=u"Message accompanying versioning event")
Пример #13
0
class IPerson(model.Schema):
    JobTitle = schema.TextLine(title=_(u'Job Title'))
    Department = schema.TextLine(title=_(u'Department'))

    fieldset('address',
             label=_(u'Address'),
             fields=['PhysicalAddress', 'PostalAddress'])
    PhysicalAddress = schema.Object(title=_(u'Physical Address'),
                                    schema=IAddress)
    PostalAddress = schema.Object(title=_(u'Postal Address'), schema=IAddress)
Пример #14
0
class IAssignment(IAlchemistContent):

    content = schema.Object(IAlchemistContent)
    context = schema.Object(IAlchemistContent)
    title = schema.TextLine(title=_(u"Name of the Assignment"))
    start_date = schema.Date(title=_(u"Start Date of the Assignment"))
    end_date = schema.Date(title=_(u"End Date of the Assignment"))
    type = schema.TextLine(title=_(u"Assignment Type"), readonly=True)
    status = schema.TextLine(title=_(u"Status"), readonly=True)
    notes = schema.Text(title=_(u"Notes"), description=_(u"Notes"))
Пример #15
0
class IAssignment(IAlchemistContent):

    content = schema.Object(IAlchemistContent)
    context = schema.Object(IAlchemistContent)
    title = schema.TextLine(
        title=_(u"Title of document assignment to group or committee"))
    start_date = schema.Date(title=_(u"Start date of document assignment"))
    end_date = schema.Date(title=_(u"End date of document assignment"))
    type = schema.TextLine(title=_(u"Document assignment type"), readonly=True)
    status = schema.TextLine(title=_(u"Status"), readonly=True)
    notes = schema.Text(title=_(u"Notes"), description=_(u"Notes"))
Пример #16
0
class IOrganization(model.Schema):
    TaxNumber = schema.TextLine(title=_(u'VAT Number'), required=False)

    fieldset('address',
             label=_(u'Address'),
             fields=['EmailAddress', 'PhysicalAddress', 'PostalAddress'])
    EmailAddress = Email(title=_(u'Email Address'), required=False)
    PhysicalAddress = schema.Object(title=_(u'Physical Address'),
                                    required=False,
                                    schema=IAddress)
    PostalAddress = schema.Object(title=_(u'Postal Address'),
                                  required=False,
                                  schema=IAddress)
class IAutopublishSettingsSchema(Interface):

    publish_actions = schema.Tuple(
        value_type=schema.Object(
            title=_(u'Action'),
            schema=IAutopublishSpecification),
        title=_(u'Publish actions'),
        description=_(u"Workflow actions initiated by the autopublishing "
                      u"module when the publishing date is met."),
        required=False,
        default=(),
        missing_value=())
    retract_actions = schema.Tuple(
        value_type=schema.Object(
            title=_(u'Action'),
            schema=IAutopublishSpecification),
        title=_(u'Retract actions'),
        description=_(u"Workflow actions initiated by the autopublishing "
                      u"module when the expiration date is met."),
        required=False,
        default=(),
        missing_value=())
    overwrite_expiration_on_retract = schema.Bool(
        title=_(u'Set expiration date on retraction'),
        description=_(u"If this is set, the expiration date "
                      u"will be overwritten with the current time "
                      u"when manually retracting an item, to avoid "
                      u" republication if there is a publication date "
                      u"in the past."),
        default=False)
    clear_expiration_on_publish = schema.Bool(
        title=_(u'Clear expiration date on publication'),
        description=_(u"If this is set, an expiration date "
                      u"in the past will be cleared "
                      u"when manually publishing an item, to avoid "
                      u"immediate retraction."),
        default=False)
    email_log = schema.List(
        value_type=schema.TextLine(
            title=u'Email'),
        title=_(u'Email addresses for audit log'),
        description=_(u"If one or more email addresses is supplied, "
                      u"an audit log of the actions taken is sent."),
        required=False)
    dry_run = schema.Bool(
        title=_(u'Simulate'),
        description=_(u"Simulates the process of changing workflow state. "
                      u"Nothing actually changes state, but it is possible to "
                      u"review what actions will be taken. To activate "
                      u"the module, remove the checkmark."),
        default=True)
Пример #18
0
class IChannel(interface.Interface):
    """A Channel is what we can subscribe to.

    A Channel is a hub of configuration.  It doesn't do anything by
    itself.  Rather, it provides a number of components to configure
    and work with.  It is also the container of subscriptions to it.
    """

    name = schema.ASCIILine(
        title=_(u"Unique identifier for this channel across the site."), )

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

    description = schema.Text(title=_(u"Description"))

    subscribeable = schema.Bool(title=_(u"Subscribeable"), default=False)

    scheduler = schema.Object(
        title=_(u"Scheduler (when)"),
        required=False,
        schema=IScheduler,
    )

    collector = schema.Object(
        title=_(u"Collector (what)"),
        required=False,
        schema=ICollector,
    )

    composers = schema.Dict(
        title=_(u"The channel's composers, keyed by format."),
        key_type=schema.TextLine(title=_(u"Format")),
        value_type=schema.Object(title=_(u"Composer"), schema=IComposer),
    )

    subscriptions = schema.Object(
        title=_(u"The channel's subscriptions"),
        schema=ISubscriptions,
    )

    queue = schema.Object(
        title=_(u"This channel's message queues, keyed by message status"),
        schema=IMessageQueues,
    )

    keep_sent_messages = schema.Bool(
        title=_(u"Keep a record of sent messages."),
        description=_(u"This is not currently recommended for large volumes "
                      u"of messages due to storage requirements."),
        default=False,
    )
Пример #19
0
class ILUCScenario(Interface):
    """LEAM Land Use Change (LUC) Scenario"""
    #
    end_time = schema.Date(
        title=_(u"End Time"),
        required=False,
        description=_(u"When the model completed."),
    )
    #
    start_time = schema.Date(
        title=_(u"Start Time"),
        required=False,
        description=_(u"When the model began execution."),
    )
    #
    runstatus = schema.TextLine(
        title=_(u"Run Status"),
        required=True,
        description=_(u"Provide the current run state of the scenario."),
    )
    #
    growth = schema.Object(
        title=_(u"Growth Projections"),
        required=False,
        description=_(
            u"Add one or more growth Projections for this scenario."),
        schema=Interface,  # specify the interface(s) of the addable types here
    )
    #
    growthmap = schema.Object(
        title=_(u"Growth Drivers"),
        required=False,
        description=_(u"Add one or more driver sets."),
        schema=Interface,  # specify the interface(s) of the addable types here
    )
    #
    decline = schema.Object(
        title=_(u"Decline Projections"),
        required=False,
        description=
        _(u"Identify the study area and population and employment projections."
          ),
        schema=Interface,  # specify the interface(s) of the addable types here
    )
    #
    declinemap = schema.Object(
        title=_(u"Decline Drivers"),
        required=False,
        description=_(u"Add one or more driver sets."),
        schema=Interface,  # specify the interface(s) of the addable types here
    )
Пример #20
0
class IOrganization(model.Schema):
    TaxNumber = schema.TextLine(title=_(u'VAT Number'), required=False)

    directives.fieldset('address',
                        label=_(u'Address'),
                        fields=[
                            'EmailAddress', 'PhysicalAddress', 'PostalAddress',
                            'BillingAddress'
                        ])
    EmailAddress = Email(title=_(u'Email Address'), required=False)
    PhysicalAddress = schema.Object(title=_(u'Physical Address'),
                                    required=False,
                                    schema=IAddress)
    PostalAddress = schema.Object(title=_(u'Postal Address'),
                                  required=False,
                                  schema=IAddress)
    BillingAddress = schema.Object(title=_(u'Billing Address'),
                                   required=False,
                                   schema=IAddress)

    directives.fieldset(
        'bank',
        label=_(u'Bank Details'),
        fields=('AccountType', 'AccountName', 'AccountNumber', 'BankName',
                'BankBranch'),
    )

    AccountType = schema.TextLine(
        title=_(u"Account Type"),
        required=False,
    )

    AccountName = schema.TextLine(
        title=_(u"Account Name"),
        required=False,
    )

    AccountNumber = schema.TextLine(
        title=_(u"Account Number"),
        required=False,
    )

    BankName = schema.TextLine(
        title=_(u"Bank Name"),
        required=False,
    )

    BankBranch = schema.TextLine(
        title=_(u"Bank Branch"),
        required=False,
    )
Пример #21
0
class ISCALDS(Interface):
    """Interface to the SCALDS Model."""

    # -*- schema definition goes here -*-
    end_time = schema.Date(
        title=_(u"Model End Time"),
        required=False,
        description=_(u"Logs when model ends execution."),
    )
#
    start_time = schema.Date(
        title=_(u"Model Start Time"),
        required=False,
        description=_(u"Logs when the model begins execution."),
    )
#
    runstatus = schema.TextLine(
        title=_(u"Model Run Status"),
        required=True,
        description=_(u"Maintain the state of the job."),
    )
#
    water = schema.Object(
        title=_(u"Water and Sewer Costs"),
        required=False,
        description=_(u"A vector map providing costs associated with households/employees by area."),
        schema=Interface, # specify the interface(s) of the addable types here
    )
#
    vmt = schema.Object(
        title=_(u"VMT Map"),
        required=True,
        description=_(u"A vector map with the daily average VMT per household/employee per area."),
        schema=Interface, # specify the interface(s) of the addable types here
    )
#
    scenario = schema.Object(
        title=_(u"LUC Scenario"),
        required=True,
        description=_(u"The LUC scenario that will provide spatialized inputs to the SCALDS model."),
        schema=Interface, # specify the interface(s) of the addable types here
    )
#
    template = schema.Object(
        title=_(u"SCALDS Spreadsheet"),
        required=True,
        description=_(u"The SCALDS spreadsheet used as a template."),
        schema=Interface, # specify the interface(s) of the addable types here
    )
Пример #22
0
class ISocialNetworksSchema(Interface):

    accounts_info = schema.List(
        title=_(u'Social Network'),
        default=[],
        value_type=schema.Object(ISocialNetworksPair, title=u'Rede'),
        required=False)
Пример #23
0
    def test_object(self):
        field = schema.Object(
            title=u'My field',
            description=u'My great field',
            schema=IDummySchema,
        )
        adapter = getMultiAdapter(
            (field, self.portal, self.request),
            IJsonSchemaProvider
        )

        self.assertEqual(
            {
                'type': 'object',
                'title': u'My field',
                'description': u'My great field',
                'properties': {
                    'field1': {
                        'title': u'Foo',
                        'description': u'',
                        'type': 'boolean'
                    },
                    'field2': {
                        'title': u'Bar',
                        'description': u'',
                        'type': 'string'
                    },
                }
            },
            adapter.get_schema()
        )
Пример #24
0
class IServiceNavigationSchema(model.Schema):
    directives.widget('links', DataGridFieldFactory, allow_reorder=True)
    links = schema.List(
        title=_(u'label_service_links', default=u'Service links'),
        value_type=schema.Object(
            title=u'link',
            schema=IServiceNavigationSchemaGrid
        ),
        required=False,
        missing_value=[],
    )

    disable = schema.Bool(
        title=_(u'label_disable_service_links',
                default=u'Disable service links'),
        required=False,
        missing_value=False,
    )

    directives.mode(modified='hidden')
    modified = schema.Bool(
        title=u'modified_marker',
        required=False,
        default=True,
        missing_value=True,
    )

    @invariant
    def link_validator(data):
        for link in data.links:
            if link.get('internal_link', None) and link.get('external_url', None):
                raise Invalid(_('error_link_validator',
                                u'Choose between an external or an internal link.'))
Пример #25
0
class INamedDataSequence(form.Schema, IDataSeries, ISeriesDisplay):
    """Named category seqeuence with embedded data stored as content"""

    form.fieldset(
        'display',
        label=u"Display settings",
        fields=[
            'color',
            'show_trend',
            'trend_width',
            'trend_color',
            'display_precision',
            'point_labels',
        ],
    )

    input = schema.Text(
        title=_(u'Data input'),
        description=_(u'Comma-separated records, one per line '
                      u'(name, numeric value, [note], [URL]). '
                      u'Note and URL are optional.'),
        default=u'',
        required=False,
    )

    # data field to store CSV source:
    form.omitted('data')
    data = schema.List(
        title=_(u'Data'),
        description=_(u'Data points for series: name, value; values are '
                      u'either whole/integer or decimal numbers.'),
        value_type=schema.Object(schema=INamedDataPoint, ),
        readonly=True,
    )
class IContentSource(IQuerySource):
    """A source that can specify content. The generated terms should have
       tokens that are URLs to the content, since these are used to create
       links.
    """

    navigation_tree_query = Attribute(
        "A dict to pass to portal_catalog when "
        "searching for items to display. This dictates "
        "how the tree is structured, and also provides an "
        "upper bound for items allowed by the source.")

    selectable_filter = schema.Object(
        title=u"Filter",
        description=
        u"The filter will be applied to any returned search results",
        schema=IContentFilter)

    def isBrainSelectable(self, brain):
        """Return True iff the brain represents a page that can be selected
        in the navigation tree. Base implementation should be sufficient
        """

    def getTermByBrain(self, brain, real_value=True):
        """Given a brain, generate a Term that represents this brain
Пример #27
0
    def test_object(self):
        field = schema.Object(title=u"My field",
                              description=u"My great field",
                              schema=IDummySchema)
        adapter = getMultiAdapter((field, self.portal, self.request),
                                  IJsonSchemaProvider)

        self.assertEqual(
            {
                "type": "object",
                "title": u"My field",
                "description": u"My great field",
                "properties": {
                    "field1": {
                        "title": u"Foo",
                        "description": u"",
                        "type": "boolean"
                    },
                    "field2": {
                        "title": u"Bar",
                        "description": u"",
                        "type": "string"
                    },
                },
            },
            adapter.get_schema(),
        )
Пример #28
0
class IProduct(interface.Interface):

    id = schema.Int(
        title=_(u"ID"),
        readonly=True,
    )

    name = schema.TextLine(title=_(u"Name"), )

    product_id = schema.TextLine(title=_(u"ProductNumber"))

    producer = schema.Choice(
        title=_(u"Producer"),
        source=sources('producers_query'),
        required=False,
    )

    categories = schema.Set(
        title=_(u"Category"),
        value_type=schema.Choice(title=_(u""), source=sources('categories')),
    )

    hazards = ListField(
        title=_(u"Hazards"),
        value_type=schema.Object(title=_(u""), schema=IHazard),
    )
Пример #29
0
class ITimeDataSequence(form.Schema, IDataSeries, ILineDisplay):
    """Content item interface for a data series stored as content"""

    input = schema.Text(
        title=_(u'Data input'),
        description=_(u'Comma-separated records, one per line '
                      u'(date, numeric value, [note], [URL]). '
                      u'Note and URL are optional. Date '
                      u'should be in MM/DD/YYYY format.'),
        default=u'',
        required=False,
        )

    label_default = schema.Choice(
        title=_(u'Label default'),
        description=_(u'Default format for X-Axis labels.'),
        default='locale',
        vocabulary=DATE_AXIS_LABEL_CHOICES,
        )

    form.omitted('data')
    data = schema.List(
        title=_(u'Data'),
        description=_(u'Data points for time series: date, value; values are '
                      u'either whole/integer or decimal numbers.'),
        value_type=schema.Object(
            schema=ITimeSeriesDataPoint,
            ),
        readonly=True,
        )
Пример #30
0
class IPriced(form.Schema):
    """ Add a price list to a content object
    """

    form.fieldset(
            'pricing',
            label=u'Pricing',
            fields=('enabled', 'price', 'pricelist'),
        )
    enabled = schema.Bool(
        title=u'Enabled',
        description=u'Enable pricing for this item',
        default=False,
        required=False,
    )
    form.widget(pricelist=DataGridFieldFactory)
    pricelist = PriceListField(
        title=u"Price list",
        value_type=schema.Object(title=u"Price", schema=INamedPriceSchema),
        missing_value=NO_PRICELIST,
    )

    @zif.invariant
    def priceMustBeSetIfEnabled(data):
        if data.enabled and not data.pricelist:
            raise zif.Invalid(
                _(u"At least one price must be set in order for pricing to be enabled."))