Exemplo n.º 1
0
class IContribOther(model.Schema):
    """  Other contributor
    """
    title = schema.TextLine(
        title=_(u"Name"),
        required=True,
    )

    organization_roles = schema.Choice(
        title=_(u"Organization roles"),
        description=_(u"The roles of other organizations in project"),
        source=utils.settings_organization_roles,
        required=False,
    )

    incash = schema.Decimal(
        title=_(u'In-cash'),
        required=False,
    )

    directives.mode(currency_incash='display')
    currency_incash = schema.TextLine(title=_(u""), )

    inkind = schema.Decimal(
        title=_(u'In-kind'),
        required=False,
    )

    directives.mode(currency_inkind='display')
    currency_inkind = schema.TextLine(title=_(u""), )
Exemplo n.º 2
0
class IContribPartner(model.Schema):
    """  Partner contributor
    """
    form.mode(IEditForm, title='display')
    title = schema.TextLine(
        title=_(u"Name"),
        required=True,
    )

    partner_roles = schema.Choice(
        title=_(u"Partner roles"),
        description=_(u"The role of partner in project"),
        source=utils.settings_partner_roles,
        required=False,
    )

    incash = schema.Decimal(
        title=_(u'In-cash'),
        required=False,
    )

    directives.mode(currency_incash='display')
    currency_incash = schema.TextLine(title=_(u""), )

    inkind = schema.Decimal(
        title=_(u'In-kind'),
        required=False,
    )

    directives.mode(currency_inkind='display')
    currency_inkind = schema.TextLine(title=_(u""), )
Exemplo n.º 3
0
class IIteration(model.Schema):

    start = schema.Date(title=_(u"Start"))
    end = schema.Date(title=_(u"End"))
    estimate = schema.Decimal(title=_(u"Estimate (man days)"),
                              required=False,
                              default=Decimal('0.00'))
Exemplo n.º 4
0
class IProjectPercentRowSchema(Interface):

    percent_allocated = schema.Decimal(
        title=_(u"Percent Allocated"),
        description=_(u""),
        required=False,
    )

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

    responsible_cost_center = schema.TextLine(
        title=_(u"Responsible Cost Center"),
        required=False,
    )

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

    project_title = schema.TextLine(
        title=_(u"Project Title"),
        required=False,
    )
Exemplo n.º 5
0
class IStory(model.Schema):

    text = schema.Text(title=_(u"Text"), required=False)

    form.widget('estimate',
                TimeFieldWidget,
                show_min=False,
                hour_free_input=True)
    estimate = schema.Decimal(title=_(u"Estimate (man hours)"),
                              default=Decimal('0.00'))

    assigned_to = Select2MultiField(
        title=_(u"Assignees"),
        description=_(u"The user IDs of the people "
                      u"that are responsible to act on this story"),
        # value_type=schema.TextLine(),
        value_type=schema.Choice(
            title=_(u"User ID"),
            source="collective.simplemanagement.resources"),
        required=False,
        search_view=lambda x: '{}/select2-users-search'.format(x))

    epic = RelationChoice(title=_(u"Epic"),
                          description=_(u"The epic the story belongs to"),
                          source=ObjPathSourceBinder(object_provides=[
                              IEpic.__identifier__,
                          ]),
                          required=False)

    milestone = schema.Choice(title=_(u"Milestone"),
                              required=False,
                              source="collective.simplemanagement.milestones")
Exemplo n.º 6
0
class IBooking(Interface):
    """ schema for booking object
    """

    cat_id = schema.Int(title=_(u"Catalog id"), required=True)

    uid = schema.ASCIILine(title=_(u"UID"), required=True)

    date = schema.Date(title=_(u"Date"), required=True)

    time = schema.Decimal(title=_(u"Hours"), required=True, min=Decimal('0.1'))

    text = schema.TextLine(title=_(u"Text"), required=True)

    owner = schema.ASCIILine(title=_(u"Owner ID"), required=True)

    references = schema.List(title=_(u"Related objects"),
                             required=False,
                             value_type=schema.Tuple(
                                 title=u"Reference",
                                 value_type=schema.ASCIILine(title=u'Stuff')))

    tags = schema.Set(title=_(u"Tags"),
                      required=False,
                      value_type=schema.TextLine(title=u"Tag"))

    def index_references():
        """ returns the value to be indexed for ``references`` field
class ISettings(Interface):
    """The settings of simplemanagement.
    """

    warning_delta_percent = schema.Decimal(
        title=_(u"Warning delta"),
        description=_(u"The percentage (between 0 and 1) "
                      u"after which a deviation needs to be highlighted"),
        min=Decimal("0.1"),
        max=Decimal("1.0")
    )
    man_day_hours = schema.Decimal(
        title=_(u"Man day hours"),
        description=_(u"The number of hours a person works in a day")
    )
    working_week_days = schema.Decimal(
        title=_(u"Working week days"),
        description=_(u"The number of days worked in a week")
    )
    statuses = schema.List(
        title=_(u"Project statuses"),
        value_type=schema.TextLine()
    )
    env_types = schema.List(
        title=_(u"Environment types"),
        value_type=schema.TextLine()
    )
    resource_roles = schema.List(
        title=_(u"Resource roles"),
        value_type=schema.TextLine()
    )
    employees_group = schema.TextLine(
        title=_(u"Employess group"),
        description=_(u"Identifier of the group containing all employees")
    )
    monthly_weeks_before = schema.Int(
        title=_(u"Number of weeks before month"),
        description=_(u"The number of weeks to show in monthly views "
                      u"that actually fall in the previous month")
    )
    monthly_weeks_after = schema.Int(
        title=_(u"Number of weeks after month"),
        description=_(u"The number of weeks to show in monthly views "
                      u"that actually fall in the next month")
    )
Exemplo n.º 8
0
class IProjectProgramTeamRowSchema(Interface):

    project_program_team = schema.TextLine(
        title=_(u"Project / Program Team"),
        required=False,
    )

    percent_allocated = schema.Decimal(
        title=_(u"Percent Allocated"),
        description=_(u""),
        required=False,
    )
Exemplo n.º 9
0
class IContribDonor(model.Schema):
    """  Donor contributor
    """
    form.mode(IEditForm, title='display')
    title = schema.TextLine(
        title=_(u"Name"),
        required=True,
    )

    incash = schema.Decimal(
        title=_(u'In-cash'),
        required=False,
    )

    directives.mode(currency_incash='display')
    currency_incash = schema.TextLine(title=_(u""), )

    inkind = schema.Decimal(
        title=_(u'In-kind'),
        required=False,
    )

    directives.mode(currency_inkind='display')
    currency_inkind = schema.TextLine(title=_(u""), )
Exemplo n.º 10
0
class IPayPalPaymentForm(Interface):
    """Most basic form fields for PayPal payments.
    """

    business = schema.TextLine(
        title=u"Merchant email or id",
        description=(
            u"Email address or account ID of the payment recipient (that is, "
            u"the merchant). Equivalent to the values of receiver_email "
            u"(if payment is sent to primary account) and business set in "
            u"the Website Payment HTML. Value of this variable is normalized "
            u"to lowercase characters"
        ),
        max_length=127,
        required=True,
        )

    amount = schema.Decimal(
        title=u"Amount",
        default=decimal.Decimal("0.00"),
        required=True,
        )

    notify_url = schema.URI(
        title=u"URL where PayPal should deliver notifications.",
        required=True,
        )

    return_url = schema.URI(
        title=u"Where users are sent after successfull payment.",
        required=True,
        )

    cancel_return = schema.URI(
        title=u"Where users are sent after payment cancellation.",
        required=True,
        )

    item_name = schema.TextLine(
        title=u"Item Name",
        required=False,
        )

    invoice = schema.TextLine(
        title=u"Unique Invoice ID",
        required=False,
        )
Exemplo n.º 11
0
class IDXItemSchema(Schema):

    bool_field = schema.Bool(title=u'Bool Field', default=False)
    choice_field = schema.Choice(title=u'Choice Field', vocabulary=COLORS)
    date_field = schema.Date(title=u'Date Field')
    datetime_field = schema.Datetime(title=u'Datetime Field')
    decimal_field = schema.Decimal(title=u'Float Field')
    dottedname_field = schema.URI(title=u'DottedName Field')
    file_field = NamedFile(title=u'File Field')
    float_field = schema.Float(title=u'Float Field')
    image_field = NamedImage(title=u'Image Field')
    list_field = schema.List(title=u'List Field')
    richtext_field = RichText(title=u'Rich Text Field')
    text_field = schema.Text(title=u'Text Field')
    time_field = schema.Time(title=u'Time Field')
    timedelta_field = schema.Timedelta(title=u'Timedelta Field')
    uri_field = schema.URI(title=u'URI Field')
Exemplo n.º 12
0
class DiscountBehaviorSchema(DiscountSchema):
    """Schema for behavior: DiscountBehavior"""

    registered_member_discount_enabled = schema.Bool(
        title=_(u"Registered Member Discount Enabled"),
        description=_(
            u'registered_member_discount_enabled_description',
            default=
            u'Check this option to enable discount for members who have registration numbers.'
        ),
        required=False)

    registered_member_discount_price = schema.Decimal(
        title=_(u"Registered Member Discount Price"),
        description=_(
            u'registered_member_discount_price_description',
            default=u'Discount price for members who have registration numbers.'
        ),
        required=False)
Exemplo n.º 13
0
    def test_decimal(self):
        field = schema.Decimal(
            title=u'My field',
            description=u'My great field',
            min=Decimal(0),
            max=Decimal(1),
            default=Decimal(0.5),
        )
        adapter = getMultiAdapter((field, self.portal, self.request),
                                  IJsonSchemaProvider)

        self.assertEqual(
            {
                'minimum': 0.0,
                'maximum': 1.0,
                'type': 'number',
                'title': u'My field',
                'description': u'My great field',
                'default': 0.5,
            }, adapter.get_schema())
Exemplo n.º 14
0
    def test_decimal(self):
        field = schema.Decimal(
            title=u"My field",
            description=u"My great field",
            min=Decimal(0),
            max=Decimal(1),
            default=Decimal(0.5),
        )
        adapter = getMultiAdapter((field, self.portal, self.request),
                                  IJsonSchemaProvider)

        self.assertEqual(
            {
                "minimum": 0.0,
                "maximum": 1.0,
                "type": "number",
                "title": u"My field",
                "description": u"My great field",
                "default": 0.5,
            },
            adapter.get_schema(),
        )
class IResource(Interface):

    role = schema.Choice(
        title=_(u"Role"),
        source="collective.simplemanagement.roles"
    )

    user_id = Select2Field(
        title=_(u"User ID"),
        source="collective.simplemanagement.resources",
        search_view=lambda x: '{}/select2-users-search'.format(x),
        required=True
    )

    active = schema.Bool(
        title=_(u"Active"),
        default=True
    )
    compass_effort = schema.Decimal(
        title=_(u"Effort (in man days)"),
        default=Decimal('0.00')
    )
Exemplo n.º 16
0
class IInfrastructureProject(model.Schema):
    """ Marker interface and Dexterity Python Schema for InfrastructureProject
    """
    # If you want, you can load a xml model created TTW here
    # and customize it in Python:

    # model.load('infrastructure_project.xml')

    dexteritytextindexer.searchable('title')
    title = schema.TextLine(
        title=_(u'Title'),
        description=_(u'''
                The title of the project.
                '''),
        required=True,
    )
    dexteritytextindexer.searchable('description')
    description = schema.Text(
        title=_(u'Description'),
        description=_(u'''
                A description of this project. This should usually be no
                longer than a single paragraph.
                '''),
        required=False,
    )

    id_reference = schema.TextLine(
        title=_(u'Identifier or Reference'),
        description=_(u'''
                A unique identifier or reference number for this
                infrastructure project.
                '''),
        required=False,
    )

    # status
    # https://standard.open-contracting.org/infrastructure/latest/en/reference/codelists/#projectstatus

    directives.widget(project_status=SelectFieldWidget)
    project_status = schema.Choice(
        title=_(u'Project Status'),
        description=_(u'''
        The current phase or status of this project
        '''),
        required=False,
        vocabulary='ocds.ProjectStatus',
    )

    # Project Period as fieldset

    # startDate
    project_startDate = schema.Date(
        title=_(u'Start Date'),
        description=_(u'''
        The start date for the period. When known, a precise start date
        must always be provided.
        '''),
        required=False,
    )

    # endDate
    project_endDate = schema.Date(
        title=_(u'End Date'),
        description=_(u'''
        The end date for the period. When known, a precise end date must
        always be provided.
        '''),
        required=False,
    )

    # period_maxExtentDate

    project_maxExtentDate = schema.Date(
        title=_(u'Maximum extent'),
        description=_(u'''
            The period cannot be extended beyond this date. This field
            is optional, and can be used to express the maximum
            available data for extension or renewal of this period.
            '''),
        required=False,
    )

    # period_durationInDays
    # Implemented as view

    # Project Sector
    # https://standard.open-contracting.org/infrastructure/latest/en/reference/codelists/#projectsector

    directives.widget(project_sector=SelectFieldWidget)
    project_sector = schema.Choice(
        title=_(u'Project Sector'),
        required=False,
        vocabulary='ocds.sector',
    )

    purpose = schema.Text(
        title=_(u'Project purpose'),
        description=_(u'The socioeconomic purpose of this project'),
        required=False,
    )

    # additionalClassifications

    # project_type

    directives.widget(project_sector=SelectFieldWidget)
    project_sector = schema.Choice(
        title=_(u'Project Sector'),
        required=False,
        vocabulary='ocds.sector',
    )
    directives.widget(project_type=SelectFieldWidget)
    project_type = schema.Choice(
        title=_(u'Project Type'),
        required=False,
        vocabulary='ocds.projecttypes',
    )

    # AssetLifeTime
    # assetLifeTime_start_date
    # assetLifeTime_end_date
    # assetLifeTime_maxExtentDate
    # assetLifeTime_durationInDays

    # Asset startDate
    assetLifetime_startDate = schema.Date(
        title=_(u'Asset Start Date'),
        description=_(u'''
        The start date for the asset. When known, a precise start date
        must always be provided.
        '''),
        required=False,
    )

    # Asset endDate
    assetLifetime_endDate = schema.Date(
        title=_(u'Asset End Date'),
        description=_(u'''
        The end date for the period. When known, a precise asset end
        date must always be provided.
        '''),
        required=False,
    )

    # Asset period_maxExtentDate

    assetLifetime_maxExtentDate = schema.Date(
        title=_(u'Asset Maximum extent'),
        description=_(u'''
            The period cannot be extended beyond this date. This field
            is optional, and can be used to express the maximum
            available data for extension or renewal of this period.
            '''),
        required=False,
    )

    fieldset('Asset Lifetime',
             fields=[
                 'assetLifetime_startDate',
                 'assetLifetime_endDate',
                 'assetLifetime_maxExtentDate',
             ])

    # locations

    # budget

    budget_amount = schema.Decimal(
        title=_(u'Budget Amount'),
        description=_(u'''
            The projected costs or allocated budget for
            the project'''),
        required=False,
    )

    # budget_currency
    directives.widget(budget_currency=SelectFieldWidget)
    budget_currency = schema.Choice(
        title=u'Budget Currency',
        description=u'Currency of the budget amount',
        required=False,
        vocabulary='collective.vocabularies.iso.currencies',
    )

    budget_approvalDate = schema.Date(
        title=_(u'Budget Approval Date'),
        description=_(u'''
            The date on which the project budget was approved. Where
            documentary evidence for this exists, it may be included
            amongst the project documents with the documentType set to
            ‘budgetApproval’.
            '''),
        required=False,
    )

    # budget_breakdown
    # implemented as content type

    # Parties
    # Implemented as a Behaviour

    # Contracting Processes
    # Implemented as content type

    # completion_endDate

    completion_endDate = schema.Date(
        title=_(u'Completion Date'),
        description=_(u'''
        The actual completion date for the project (compare with the
        endDate in project period.
            '''),
        required=False,
    )

    completion_endDate_details = RichText(
        title=_(u'Completion End Date Details'),
        description=_(u'''
        Details related to the endDate. This may be a justification for
        the contract’s completion date being different than in the
        original contract.
        '''),
        required=False,
    )

    # completion_endDateDetails
    completion_finalValue_amount = schema.Decimal(
        title=_(u'Final Value'),
        description=_(u'The total cost of this project at completion.'),
        required=False,
    )

    directives.widget(completion_finalValue_currency=SelectFieldWidget)
    completion_finalValue_currency = schema.Choice(
        title=u'Final  Currency',
        description=u'Currency of the budget amount',
        required=False,
        vocabulary='collective.vocabularies.iso.currencies',
    )

    completion_finalValue_details = RichText(
        title=_(u'Final value details'),
        description=_(u'''
        Details related to the final value. This may be a justification
        for the completed project’s value being different than in the
        original or latest revised budget.
        '''),
        required=False,
    )

    completion_finalScope = schema.Text(
        title=_(u'Final Scope'),
        description=_(u'''
        A short description of the final scope of the project at
        completion.
        '''),
        required=False,
    )

    completion_finalScopeDetails = RichText(
        title=_(u'Final scope details'),
        description=_(u'''
        A reason, explanation or justification for any variation between
        the anticipated scope (compare to the projectScope document) and
        the final scope at completion. If appropriate, additional
        details may be included in the documents section, with a title
        indicating that these documents will describe and differences
        between the planned and completed scope of work.
        '''),
        required=False,
    )

    fieldset('Completion',
             fields=[
                 'completion_endDate',
                 'completion_endDate_details',
                 'completion_finalValue_amount',
                 'completion_finalValue_currency',
                 'completion_finalValue_details',
                 'completion_finalScope',
                 'completion_finalScopeDetails',
             ])
Exemplo n.º 17
0
class IOAuth2Application(model.Schema):
    """Meta Info:
    http://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata"""

    client_name = zs.TextLine(
        title=_('Application Name'),
        description=_(
            'Name of the Client to be presented to the End-User. '
            'If desired, representation of this Claim in different '
            'languages and scripts is represented as described in Section 2.1.'
        ),
        required=True)
    redirect_uris = zs.List(
        title=_('Redirect URIs'),
        description=_(
            'Array of Redirection URI values used by the Client. '
            'One of these registered Redirection URI values MUST '
            'exactly match the redirect_uri parameter value used in each '
            'Authorization Request, with the matching performed as described in '
            'Section 6.2.1 of [RFC3986] (Simple String Comparison).'),
        value_type=zs.URI(),
        required=True)
    response_types = zs.List(
        title=_('Response Type'),
        description=
        _('JSON array containing a list of the OAuth 2.0 response_type values '
          'that the Client is declaring that it will restrict itself to using. '
          'If omitted, the default is that the Client will use only the code Response Type.'
          ),
        value_type=zs.Choice(vocabulary='oauth2_app_response_type_options'))

    grant_types = zs.List(
        title=_('Grant Types'),
        description=_(
            'JSON array containing a list of the OAuth 2.0 Grant Types that the '
            'Client is declaring that it will restrict itself to using. '),
        value_type=zs.Choice(vocabulary='oauth2_app_grant_type_options'),
        required=False)

    application_type = zs.Choice(
        title=_('Application Type'),
        description=
        _('Kind of the application. The default, if omitted, is web. '
          'The defined values are native or web. Web Clients using the OAuth Implicit '
          'Grant Type MUST only register URLs using the https scheme as redirect_uris; '
          'they MUST NOT use localhost as the hostname. Native Clients MUST only register '
          'redirect_uris using custom URI schemes or URLs using the http: scheme with '
          'localhost as the hostname. Authorization Servers MAY place additional constraints '
          'on Native Clients. Authorization Servers MAY reject Redirection URI values using '
          'the http scheme, other than the localhost case for Native Clients. '
          'The Authorization Server MUST verify that all the registered redirect_uris '
          'conform to these constraints. This prevents sharing a Client ID across different '
          'types of Clients'),
        vocabulary='oauth2_app_type_options',
        default='web')

    contacts = zs.List(
        title=_('Contact E-mails'),
        description=_(
            'Array of e-mail addresses of people responsible for this Client. '
            'This might be used by some providers to enable a Web user '
            'interface to modify the Client information.'),
        value_type=zs.TextLine(),
        required=False)

    logo_uri = zs.URI(
        title=_('Logo URI'),
        description=_(
            'URL that references a logo for the Client application. '
            'If present, the server SHOULD display this image to the '
            'End-User during approval. The value of this field MUST point '
            'to a valid image file. If desired, representation of this '
            'Claim in different languages and scripts is represented as '
            'described in Section 2.1.'),
        required=False)

    client_uri = zs.URI(
        title=_('Application URI'),
        description=
        _('URL of the home page of the Client. The value of this field MUST point to a '
          'valid Web page. If present, the server SHOULD display this URL to '
          'the End-User in a followable fashion. If desired, representation of this '
          'Claim in different languages and scripts is represented as described in Section 2.1.'
          ),
        required=False)

    policy_uri = zs.URI(
        title=_('Policy URI'),
        description=
        _('URL that the Relying Party Client provides to the End-User to '
          'read about the how the profile data will be used. '
          'The value of this field MUST point to a valid web page. '
          'The OpenID Provider SHOULD display this URL to the End-User if it is given. '
          'If desired, representation of this Claim in different languages and scripts '
          'is represented as described in Section 2.1.'),
        required=False)

    tos_uri = zs.URI(
        title=_('Terms of service URI'),
        description=
        _('URL that the Relying Party Client provides to the End-User to read about '
          'the Relying Party\'s terms of service. The value of this field MUST point '
          'to a valid web page. The OpenID Provider SHOULD display this URL to '
          'the End-User if it is given. If desired, representation of this Claim '
          'in different languages and scripts is represented as described in Section 2.1.'
          ),
        required=False)

    jwks_uri = zs.URI(
        title=_('JWKS URI'),
        description=
        _('URL for the Client\'s JSON Web Key Set [JWK] document. If the Client signs requests '
          'to the Server, it contains the signing key(s) the Server uses to validate signatures '
          'from the Client. The JWK Set MAY also contain the Client\'s encryption keys(s), '
          'which are used by the Server to encrypt responses to the Client. When both signing '
          'and encryption keys are made available, a use (Key Use) parameter value is '
          'REQUIRED for all keys in the referenced JWK Set to indicate each key\'s intended usage. '
          'Although some algorithms allow the same key to be used for both signatures and '
          'encryption, doing so is NOT RECOMMENDED, as it is less secure. '
          'The JWK x5c parameter MAY be used to provide X.509 representations of keys provided. '
          'When used, the bare key values MUST still be present and MUST match those in '
          'the certificate.'),
        required=False)
    # jwks: https://tools.ietf.org/html/draft-ietf-jose-json-web-key-41#section-3
    jwks = zs.Dict(
        title=_('JSON Web Key Set'),
        description=
        _('JSON Object. JSON Web Key Set [JWK] document, passed by value. '
          'The semantics of the jwks parameter are the same as the jwks_uri parameter, '
          'other than that the JWK Set is passed by value, rather than by reference. '
          'This parameter is intended only to be used by Clients that, for some reason, '
          'are unable to use the jwks_uri parameter, for instance, by native applications '
          'that might not have a location to host the contents of the JWK Set. '
          'If a Client can use jwks_uri, it MUST NOT use jwks. One significant downside of '
          'jwks is that it does not enable key rotation (which jwks_uri does, as described '
          'in Section 10 of OpenID Connect Core 1.0 [OpenID.Core]). '
          'The jwks_uri and jwks parameters MUST NOT be used together.'),
        required=False)

    sector_identifier_uri = zs.URI(
        title=_('Sector Identifier URI'),
        description=
        _('URL using the https scheme to be used in calculating Pseudonymous Identifiers '
          'by the OP. The URL references a file with a single JSON array of redirect_uri values. '
          'Please see Section 5. Providers that use pairwise sub (subject) values SHOULD '
          'utilize the sector_identifier_uri value provided in the Subject Identifier calculation '
          'for pairwise identifiers.'))

    subject_type = zs.Choice(
        title=_('Subject Type'),
        description=
        _('subject_type requested for responses to this Client. '
          'The subject_types_supported Discovery parameter contains a list of '
          'the supported subject_type values for this server. Valid types include '
          'pairwise and public.'),
        values=('pairwise', 'public'),
        required=False)

    id_token_signed_response_alg = zs.Choice(
        title=_('ID Token Response algorithms'),
        description=
        _('JWS alg algorithm [JWA] REQUIRED for signing the ID Token issued to this Client.'
          'The value none MUST NOT be used as the ID Token alg value unless the '
          'Client uses only Response Types that return no ID Token from the '
          'Authorization Endpoint (such as when only using the Authorization Code Flow). '
          'The default, if omitted, is RS256. The public key for validating the '
          'signature is provided by retrieving the JWK Set referenced by the '
          'jwks_uri element from OpenID Connect Discovery 1.0 [OpenID.Discovery].'
          ),
        vocabulary='oauth2_app_jwt_algs_options',
        required=False)

    id_token_encrypted_response_alg = zs.Choice(
        title=_('ID Token encrypted response algorithm'),
        description=
        _('JWE alg algorithm [JWA] REQUIRED for encrypting the ID Token issued to this Client. '
          'If this is requested, the response will be signed then encrypted, with the result '
          'being a Nested JWT, as defined in [JWT]. The default, if omitted, is that no '
          'encryption is performed.'),
        vocabulary='oauth2_app_jwt_algs_options',
        required=False)

    id_token_encrypted_response_enc = zs.Choice(
        title=_('ID Token encrypted response enc'),
        description=
        _('JWE enc algorithm [JWA] REQUIRED for encrypting the ID Token issued to this Client. '
          'If id_token_encrypted_response_alg is specified, the default for this value is '
          'A128CBC-HS256. When id_token_encrypted_response_enc is included, '
          'id_token_encrypted_response_alg MUST also be provided.'),
        vocabulary='oauth2_app_jwt_enc_options',
        required=False)

    userinfo_signed_response_alg = zs.Choice(
        title=_('userinfo_signed_response_alg'),
        description=
        _('JWS alg algorithm [JWA] REQUIRED for signing UserInfo Responses. '
          'If this is specified, the response will be JWT [JWT] serialized, and signed using JWS. '
          'The default, if omitted, is for the UserInfo Response to return the Claims as a '
          'UTF-8 encoded JSON object using the application/json content-type.'
          ),
        vocabulary='oauth2_app_jwt_algs_options',
        required=False)

    userinfo_encrypted_response_alg = zs.Choice(
        title=_('userinfo encrypted response algorithm'),
        description=
        _('JWE [JWE] alg algorithm [JWA] REQUIRED for encrypting UserInfo '
          'Responses. If both signing and encryption are requested, the response will '
          'be signed then encrypted, with the result being a Nested JWT, as defined in '
          '[JWT]. The default, if omitted, is that no encryption is performed.'
          ),
        vocabulary='oauth2_app_jwt_algs_options',
        required=False)

    request_object_signing_alg = zs.Choice(
        title=_('request_object_signing_alg'),
        description=
        _('JWS [JWS] alg algorithm [JWA] that MUST be used for signing Request Objects sent '
          'to the OP. All Request Objects from this Client MUST be rejected, '
          'if not signed with this algorithm. Request Objects are described in Section 6.1 of '
          'OpenID Connect Core 1.0 [OpenID.Core]. This algorithm MUST be used both when the '
          'Request Object is passed by value (using the request parameter) and when '
          'it is passed by reference (using the request_uri parameter). '
          'Servers SHOULD support RS256. The value none MAY be used. The default, if omitted, '
          'is that any algorithm supported by the OP and the RP MAY be used.'),
        vocabulary='oauth2_app_jwt_algs_options',
        required=False)

    request_object_encryption_alg = zs.Choice(
        title=_('request_object_encryption_alg'),
        description=
        _('JWE [JWE] alg algorithm [JWA] the RP is declaring that it may use for '
          'encrypting Request Objects sent to the OP. This parameter SHOULD be included when '
          'symmetric encryption will be used, since this signals to the OP that a client_secret '
          'value needs to be returned from which the symmetric key will be derived, '
          'that might not otherwise be returned. The RP MAY still use other supported encryption '
          'algorithms or send unencrypted Request Objects, even when this parameter is present. '
          'If both signing and encryption are requested, the Request Object will be signed then '
          'encrypted, with the result being a Nested JWT, as defined in [JWT]. '
          'The default, if omitted, is that the RP is not declaring whether it might encrypt any '
          'Request Objects.'),
        vocabulary='oauth2_app_req_obj_algs_options',
        required=False)
    request_object_encryption_enc = zs.Choice(
        title=_('request_object_encryption_enc'),
        description=
        _('WE enc algorithm [JWA] the RP is declaring that it may use for encrypting '
          'Request Objects sent to the OP. If request_object_encryption_alg is specified, '
          'the default for this value is A128CBC-HS256. When request_object_encryption_enc '
          'is included, request_object_encryption_alg MUST also be provided.'),
        vocabulary='oauth2_app_jwt_enc_options',
        required=False)

    token_endpoint_auth_method = zs.Choice(
        title=_('token_endpoint_auth_method'),
        description=
        _('Requested Client Authentication method for the Token Endpoint. '
          'The options are client_secret_post, client_secret_basic, client_secret_jwt, '
          'private_key_jwt, and none, as described in Section 9 of '
          'OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be '
          'defined by extensions. If omitted, the default is client_secret_basic -- '
          'the HTTP Basic Authentication Scheme specified in Section 2.3.1 of '
          'OAuth 2.0 [RFC6749].'),
        vocabulary='oauth2_app_token_endpoint_auth_method_options',
        required=False)
    token_endpoint_auth_signing_alg = zs.Choice(
        title=_('token_endpoint_auth_signing_alg'),
        description=
        _('JWS [JWS] alg algorithm [JWA] that MUST be used for signing the JWT [JWT] '
          'used to authenticate the Client at the Token Endpoint for the private_key_jwt '
          'and client_secret_jwt authentication methods. All Token Requests using these '
          'authentication methods from this Client MUST be rejected, if the JWT is not '
          'signed with this algorithm. Servers SHOULD support RS256. '
          'The value none MUST NOT be used. The default, if omitted, is that any '
          'algorithm supported by the OP and the RP MAY be used.'),
        vocabulary='oauth2_app_jwt_algs_options',
        required=False)

    default_max_age = zs.Decimal(
        title=_('Default Maximum Age'),
        description=
        _('Default Maximum Authentication Age. Specifies that the End-User MUST be '
          'actively authenticated if the End-User was authenticated longer ago than '
          'the specified number of seconds. The max_age request parameter overrides this '
          'default value. If omitted, no default Maximum Authentication Age is specified.'
          ),
        required=False)

    require_auth_time = zs.Bool(
        title=_('Is require auth time'),
        description=
        _('Boolean value specifying whether the auth_time Claim in the ID Token is REQUIRED. '
          'It is REQUIRED when the value is true. (If this is false, the auth_time Claim '
          'can still be dynamically requested as an individual Claim for the ID Token using '
          'the claims request parameter described in Section 5.5.1 of OpenID Connect Core 1.0 '
          '[OpenID.Core].) If omitted, the default value is false.'),
        required=False)
    default_acr_values = zs.TextLine(
        title=_('default_acr_values'),
        description=
        _('Default requested Authentication Context Class Reference values. '
          'Array of strings that specifies the default acr values that the OP '
          'is being requested to use for processing requests from this Client, '
          'with the values appearing in order of preference. The Authentication Context '
          'Class satisfied by the authentication performed is returned as the acr '
          'Claim Value in the issued ID Token. The acr Claim is requested as a Voluntary '
          'Claim by this parameter. The acr_values_supported discovery element contains a '
          'list of the supported acr values supported by this server. Values specified in '
          'the acr_values request parameter or an individual acr Claim request override '
          'these default values.'),
        required=False)

    initiate_login_uri = zs.URI(
        title=_('initiate_login_uri'),
        description=
        _('URI using the https scheme that a third party can use to initiate a login by the RP, '
          'as specified in Section 4 of OpenID Connect Core 1.0 [OpenID.Core]. '
          'The URI MUST accept requests via both GET and POST. The Client MUST understand '
          'the login_hint and iss parameters and SHOULD support the target_link_uri parameter.'
          ),
        required=False)
    request_uris = zs.List(
        title=_('request_uris'),
        description=
        _('Array of request_uri values that are pre-registered by the RP for use at the OP. '
          'Servers MAY cache the contents of the files referenced by these URIs and not '
          'retrieve them at the time they are used in a request. OPs can require that '
          'request_uri values used be pre-registered with the require_request_uri_registration '
          'discovery parameter. If the contents of the request file could ever change, these URI '
          'values SHOULD include the base64url encoded SHA-256 hash value of the file contents '
          'referenced by the URI as the value of the URI fragment. If the fragment value used for '
          'a URI changes, that signals the server that its cached value for that URI with the old '
          'fragment value is no longer valid.'),
        value_type=zs.URI(),
        required=False)
    # http://openid.net/specs/openid-connect-session-1_0.html#OPMetadata
    post_logout_redirect_uri = zs.List(
        title=_('post_logout_redirect_uri'),
        description=
        _('Array of URLs supplied by the RP to which it MAY request that the End-User\'s '
          'User Agent be redirected using the post_logout_redirect_uri parameter after a '
          'logout has been performed.'),
        value_type=zs.URI(),
        required=False)
    # https://www.rfc-editor.org/rfc/rfc7591.txt
    scope = zs.TextLine(
        title=_('Scope'),
        description=_(
            'String containing a space-separated list of scope values (as'
            'described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client'
            'can use when requesting access tokens.  The semantics of values in'
            'this list are service specific.  If omitted, an authorization'
            'server MAY register a client with a default set of scopes.'),
        required=False)
    software_id = zs.TextLine(
        title=_('Software ID'),
        description=_(
            'A unique identifier string (e.g., a Universally Unique Identifier'
            '(UUID)) assigned by the client developer or software publisher'
            'used by registration endpoints to identify the client software to'
            'be dynamically registered.'),
        required=False)
    client_id = zs.TextLine(
        title=_('Client ID'),
        description=_(
            'OAuth 2.0 client identifier string.  It SHOULD NOT be'
            'currently valid for any other registered client, though an'
            'authorization server MAY issue the same client identifier to'
            'multiple instances of a registered client at its discretion.'),
        required=True)
    client_secret = zs.TextLine(
        title=_('Client Secret'),
        description=_(
            'OAuth 2.0 client secret string.  If issued, this MUST'
            'be unique for each "client_id" and SHOULD be unique for multiple'
            'instances of a client using the same "client_id".  This value is'
            'used by confidential clients to authenticate to the token'
            'endpoint, as described in OAuth 2.0 [RFC6749], Section 2.3.1.'),
        required=False)

    client_type = zs.Choice(
        title=_('Client Type'),
        description=_('Type clients, i.e public or secret'),
        vocabulary='oauth2_app_client_type_options',
        required=False)

    client_id_issued_at = zs.Datetime(
        title=_('Client ID Issued at'),
        description=_(
            'Time at which the client identifier was issued.  The'
            'time is represented as the number of seconds from'
            '1970-01-01T00:00:00Z as measured in UTC until the date/time of'
            'issuance.'))

    client_secret_expires_at = zs.Datetime(
        title=_('Client Secret Expire at'),
        description=_(
            'REQUIRED if "client_secret" is issued.  Time at which the client'
            'secret will expire or 0 if it will not expire.  The time is'
            'represented as the number of seconds from 1970-01-01T00:00:00Z as'
            'measured in UTC until the date/time of expiration.'),
        required=False)

    domain = zs.TextLine(title=_('FQ Domain Name'),
                         description=_(''),
                         required=False)
Exemplo n.º 18
0
class DutchCompanySchema(Schema):
    title = schema.TextLine(title=u"Bedrijfsnaam",
                            max_length=128,
                            required=False)

    address_visit_address = schema.TextLine(title=u"Adres", required=False)
    address_visit_postal = schema.TextLine(title=u"Postcode",
                                           max_length=16,
                                           required=False)
    address_visit_city = schema.TextLine(title=u"Plaats",
                                         max_length=64,
                                         required=False)

    address_postal_address = schema.TextLine(title=u"Adres", required=False)
    address_postal_postal = schema.TextLine(title=u"Postcode",
                                            max_length=16,
                                            required=False)
    address_postal_city = schema.TextLine(title=u"Plaats",
                                          max_length=64,
                                          required=False)
    email = schema.ASCIILine(title=u"E-mailadres",
                             max_length=128,
                             required=False)
    # widget(email="tno.euphorie.company.TextSpan6")
    phone = schema.ASCIILine(title=u"Telefoonnummer",
                             max_length=32,
                             required=False)
    activity = schema.TextLine(title=u"Bedrijfsactiviteit",
                               max_length=64,
                               required=False)
    submitter_name = schema.TextLine(title=u"Naam invuller",
                                     max_length=64,
                                     required=False)
    submitter_function = schema.TextLine(title=u"Functie invuller",
                                         max_length=64,
                                         required=False)
    department = schema.TextLine(title=u"Afdeling",
                                 max_length=64,
                                 required=False)
    location = schema.TextLine(title=u"Lokatie", max_length=64, required=False)
    submit_date = schema.Date(
        title=u"Datum",
        description=u"Datum waarop de gegevens verzameld zijn",
        min=datetime.date(2000, 1, 1),
        required=False,
    )
    employees = schema.Choice(
        title=u"Aantal werknemers",
        vocabulary=SimpleVocabulary([
            SimpleTerm(u"40h",
                       title=u"Maximaal 40 uur betaalde arbeid per week"),
            SimpleTerm(u"max25", title=u"Maximaal 25 werknemers"),
            SimpleTerm(u"over25", title=u"Meer dan 25 werknemers"),
        ]),
        required=False,
    )
    absentee_percentage = schema.Decimal(
        title=u"Verzuimpercentage",
        min=decimal.Decimal(0),
        max=decimal.Decimal(100),
        required=False,
    )
    # widget(absentee_percentage="tno.euphorie.company.TextSpan1")
    accidents = schema.Int(title=u"Aantal ongevallen vorig jaar",
                           required=False)
    # widget(accidents="tno.euphorie.company.TextSpan1")
    incapacitated_workers = schema.Int(
        title=u"Aantal mensen in de WIA vorig jaar", required=False)
    # widget(incapacitated_workers="tno.euphorie.company.TextSpan1")
    arbo_expert = schema.TextLine(title=u"Gegevens arbodienst/-deskundige",
                                  max_length=128,
                                  required=False)
    works_council_approval = schema.Date(
        title=u"Datum van akkoord OR/medewerkersvertegenwoordiging",
        min=datetime.date(2000, 1, 1),
        required=False,
    )
Exemplo n.º 19
0
class IModification(model.Schema):
    """ Marker interface and Dexterity Python Schema for Modification
    """
    # If you want, you can load a xml model created TTW here
    # and customize it in Python:

    # model.load('modification.xml')

    # ContractingProcess
    directives.widget('ContractingProcess',
                      RelatedItemsFieldWidget,
                      pattern_options={
                          'basePath': '/',
                          'mode': 'auto',
                          'favourites': [],
                      })

    ContractingProcess = RelationChoice(
        title=u'Constracting Process',
        description=_(u'''
            Contracting Process this modification is for
            '''),
        source=CatalogSource(portal_type='Contracting Process'),
        required=False,
    )

    dexteritytextindexer.searchable('title')
    title = schema.TextLine(
        title=_(u'Title'),
        description=_(u'''
                Modification title
                '''),
        required=True,
    )
    dexteritytextindexer.searchable('description')
    description = schema.Text(
        title=_(u'Description'),
        description=_(u'''
                Details of the modification.
                '''),
        required=False,
    )

    rationale = RichText(title=_(u'Rationale'),
                         description=_(u'''
         A summary of the reasons which have led to this modification to
         the originally planned scope, period or value.
         '''),
                         required=False)

    directives.widget(modificationType=SelectFieldWidget)
    modificationType = schema.List(title=_(u'Type'),
                                   description=_(u'''
         Indicates whether the modification relates to the duration,
         value, scope or other aspect of the contract.
        '''),
                                   required=False,
                                   default=[],
                                   value_type=schema.Choice(
                                       vocabulary='ocds.ModificationType', ))

    # OCDS Release ID (not used yet)

    oldContractValue = schema.Decimal(
        title=_(u'Old Contract Value'),
        description=_(u'''
            Contract value before the modification, taking into account
            any prior modifications.
            '''),
        required=False,
    )

    directives.widget(oldContractValue_currency=SelectFieldWidget)
    oldContractValue_currency = schema.Choice(
        title=u'Old Contract Value Currency',
        description=u'Currency of the old contract value',
        required=False,
        vocabulary='collective.vocabularies.iso.currencies',
    )

    newContractValue = schema.Decimal(
        title=_(u'New Contract Value'),
        description=_(u'''
            Contract value after the modification, taking into account
            any prior modifications.
            '''),
        required=False,
    )

    directives.widget(newContractValue_currency=SelectFieldWidget)
    newContractValue_currency = schema.Choice(
        title=u'New Contract Value Currency',
        description=u'Currency of the new contract value',
        required=False,
        vocabulary='collective.vocabularies.iso.currencies',
    )

    # startDate
    oldContractPeriod_startDate = schema.Date(
        title=_(u'Old Start Date'),
        description=_(u'''
        The start date for the period. When known, a precise start date
        must always be provided.
        '''),
        required=False,
    )

    # endDate
    oldContractPeriod_endDate = schema.Date(
        title=_(u'Old End Date'),
        description=_(u'''
        The end date for the period. When known, a precise end date must
        always be provided.
        '''),
        required=False,
    )

    # period_maxExtentDate
    oldContractPeriod_maxExtentDate = schema.Date(
        title=_(u'Old Maximum extent'),
        description=_(u'''
            The period cannot be extended beyond this date. This field
            is optional, and can be used to express the maximum
            available data for extension or renewal of this period.
            '''),
        required=False,
    )

    # startDate
    newContractPeriod_startDate = schema.Date(
        title=_(u'New Start Date'),
        description=_(u'''
        The start date for the period. When known, a precise start date
        must always be provided.
        '''),
        required=False,
    )

    # endDate
    newContractPeriod_endDate = schema.Date(
        title=_(u'New End Date'),
        description=_(u'''
        The end date for the period. When known, a precise end date must
        always be provided.
        '''),
        required=False,
    )

    # period_maxExtentDate
    newContractPeriod_maxExtentDate = schema.Date(
        title=_(u'New Maximum extent'),
        description=_(u'''
            The period cannot be extended beyond this date. This field
            is optional, and can be used to express the maximum
            available data for extension or renewal of this period.
            '''),
        required=False,
    )
Exemplo n.º 20
0
class IShopConfiguration(Interface):
    """This interface defines the ftw.shop configlet.
    """

    shop_name = schema.TextLine(
            title=_(u"label_shop_name", default=u"Enter the shop name"),
            required=True,
            default=u"Webshop")

    shop_email = schema.TextLine(
            title=_(u"label_shop_email", default=u"Sender e-Mail Address"),
            required=True,
            default=u"*****@*****.**")

    mail_bcc = schema.TextLine(
            title=_(u"label_mail_bcc", default=u"BCC Address"),
            required=False,
            default=u"")

    mail_subject = schema.TextLine(
            title=_(u"label_mail_subject",
                    default=u"Subject"),
            description=_(u"help_mail_subject",
                    default=u"The subject for order mails."),
            required=False,
            default=u"")

    phone_number = schema.TextLine(
        title=_(u'label_phone_number',
                default=u'Phone number'),
        description=_(u'help_phone_number',
                      default=u'Will be displayed in the customer confirmation mail'
                      ' as contact information when configured.'),
        required=False,
        default=u'')

    always_notify_shop_owner = schema.Bool(
            title=_(u"label_always_notify_shop_owner",
                    default=u"Always notify shop owner about orders"),
            description=_(u"help_always_notify_shop_owner",
                    default=u"Also send eMail to owner if supplier(s) have "
                             "been notified"),
            required=False)

    payment_processor_step_group = schema.Choice(
            title=_(u"label_payment_processor_step_group",
                    default="Payment Processor Step Group"),
            vocabulary="ftw.shop.payment_processor_step_groups",
            default=u"ftw.shop.DefaultPaymentProcessorStepGroup",
            required=True)

    enabled_payment_processors = schema.List(
            title=_(u"label_enabled_payment_processors",
                    default="Enabled Payment Processors"),
            required=False,
            default=[u'ftw.shop.InvoicePaymentProcessor'],
            value_type=schema.Choice(
                            vocabulary="ftw.shop.payment_processors"),
                            )

    order_storage = schema.Choice(
            title=_(u"label_order_storage",
                    default="Order Storage method"),
            required=True,
            default=u'ftw.shop.BTreeOrderStorage',
            vocabulary="ftw.shop.order_storage_vocabulary")

    contact_info_step_group = schema.Choice(
            title=_(u"label_contact_info_step_group",
                    default="Contact Information Step Group"),
            vocabulary="ftw.shop.contact_info_step_groups",
            default=u"ftw.shop.DefaultContactInformationStepGroup",
            required=True)

    shipping_address_step_group = schema.Choice(
            title=_(u"label_shipping_address_step_group",
                    default="Shipping Address Step Group"),
            vocabulary="ftw.shop.shipping_address_step_groups",
            default=u"ftw.shop.DefaultShippingAddressStepGroup",
            required=True)

    order_review_step_group = schema.Choice(
            title=_(u"label_order_review_step_group",
                    default="Order Review Step Group"),
            vocabulary="ftw.shop.order_review_step_groups",
            default=u"ftw.shop.DefaultOrderReviewStepGroup",
            required=True)

    status_set = schema.Choice(
            title=_(u"label_status_set",
                    default="Status Set"),
            vocabulary="ftw.shop.status_sets_vocabulary",
            default=u'ftw.shop.DefaultStatusSet',
            required=True)

    show_status_column = schema.Bool(
            title=_(u"label_show_status_column",
                    default=u"Show status column in order manager"),
            description=_(u"help_show_status_column",
                    default=u""),
            default=True,
            required=False)

    vat_enabled = schema.Bool(
            title=_(u"label_vat_enabled",
                    default=u"Enable VAT support"),
            description=_(u"help_vat_enabled",
                    default=u""),
            default=True,
            required=False)

    vat_number = schema.TextLine(
            title=_(u"label_vat_number",
                    default=u"VAT number"),
            description=_(u"help_vat_number",
                    default=u""),
            default=u'',
            required=False)

    vat_rates = schema.List(
            title=_(u"label_vat_rates",
                    default=u"VAT rates"),
            description=_(u"help_vat_rates",
                    default=u""),
            value_type=schema.Decimal(),
            default=DEFAULT_VAT_RATES,
            required=False)
Exemplo n.º 21
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)
Exemplo n.º 22
0
class IBuyableBehavior(model.Schema, IBuyable):
    """Buyable behavior.
    """

    model.fieldset(
        "shop",
        label=u"Shop",
        fields=[
            "item_net",
            "item_vat",
            "item_cart_count_limit",
            "item_display_gross",
            "item_comment_enabled",
            "item_comment_required",
            "item_quantity_unit_float",
            "item_quantity_unit",
        ],
    )

    item_net = schema.Decimal(
        title=_(u"label_item_net", default=u"Item net price"),
        required=False,
        defaultFactory=default_item_net,
        min=Decimal(0),
    )

    item_vat = schema.Choice(
        title=_(u"label_item_vat", default=u"Item VAT (in %)"),
        vocabulary="bda.plone.shop.vocabularies.VatVocabulary",
        required=False,
        defaultFactory=default_item_vat,
    )

    item_cart_count_limit = schema.Decimal(
        title=_(u"label_item_cart_count_limit",
                default=u"Max count of this item in cart"),
        required=False,
        defaultFactory=default_item_cart_count_limit,
        min=Decimal(0),
    )

    item_display_gross = schema.Bool(
        title=_(u"label_item_display_gross", default=u"Display Gross Price"),
        description=_(u"help_item_display_gross",
                      default=u"Show price with taxes included"),
        required=False,
        defaultFactory=default_item_display_gross,
    )

    item_comment_enabled = schema.Bool(
        title=_(u"label_item_comment_enabled", default="Comment enabled"),
        required=False,
        defaultFactory=item_comment_enabled,
    )

    item_comment_required = schema.Bool(
        title=_(u"label_item_comment_required", default="Comment required"),
        required=False,
        defaultFactory=default_item_comment_required,
    )

    item_quantity_unit_float = schema.Bool(
        title=_(u"label_item_quantity_unit_float",
                default="Quantity as float"),
        required=False,
        defaultFactory=default_item_quantity_unit_float,
    )

    item_quantity_unit = schema.Choice(
        title=_(u"label_item_quantity_unit", default="Quantity unit"),
        vocabulary="bda.plone.shop.vocabularies.QuantityUnitVocabulary",
        required=False,
        defaultFactory=default_item_quantity_unit,
    )
Exemplo n.º 23
0
class INamedPriceSchema(zif.Interface):
    name = schema.TextLine(title=u"Name", required=False)
    price = schema.Decimal(title=u"Price")
Exemplo n.º 24
0
class IPayPalStandardBase(Interface):

    #
    # Transaction and notification-related vars.
    #
    status = schema.Choice(
        title=u"Status",
        vocabulary="megrok.paypal.payment_states",
        required=True,
        )

    # transaction and notification related
    business = schema.TextLine(
        title=u"Merchant email or id",
        description=(
            u"Email address or account ID of the payment recipient (that is, "
            u"the merchant). Equivalent to the values of receiver_email "
            u"(if payment is sent to primary account) and business set in "
            u"the Website Payment HTML. Value of this variable is normalized "
            u"to lowercase characters"
        ),
        max_length=127,
        )

    charset = schema.Choice(
        title=u"Charset",
        description=(
            u"Sets the character set and character encoding "
            u"for the billing information/log-in page on the PayPal "
            u"website. In addition, this variable sets the same values "
            u"for information that you send to PayPal in your HTML "
            u"button code. The default is based on the language "
            u"encoding settings in your Account Profile."),
        vocabulary="megrok.paypal.charsets",
    )

    custom = schema.TextLine(
        title=u"Custom",
        description=(
            "Custom value as passed by you, the merchant. These are "
            u"pass-through variables that are never presented to your "
            u"customer"
        ),
        max_length=255,
    )

    notify_version = schema.Decimal(
        title=u"notify_version",
        description=u"Message's version number",
        default=decimal.Decimal("0.00"),
    )

    parent_txn_id = schema.TextLine(
        title=u"Parent transaction ID",
        description=(
            u"In the case of a refund, reversal, or canceled reversal, "
            u"this variable contains the txn_id of the original "
            u"transaction, while txn_id contains a new ID for the new "
            u"transaction."
        ),
        max_length=19,
    )

    receiver_email = schema.TextLine(
        title=u"Receiver Email",
        description=(
            u"Primary email address of the payment recipient (that is, "
            u"the merchant). If the payment is sent to a non-primary "
            u"email address on your PayPal account, the receiver_email is "
            u"still your primary email. Value of this variable is normalized "
            u"to lowercase characters."
        ),
        max_length=127,
    )

    receiver_id = schema.TextLine(
        title=u"Receiver ID",
        description=(
            u"Unique account ID of the payment recipient (i.e., the "
            u"merchant). This is the same as the recipient's referral ID."
        ),
        max_length=13,
    )

    residence_country = schema.Choice(
        title=u"(Merchant's) residence country",
        description=(
            u"ISO 3166 country code associated with the country of residence."
        ),
        vocabulary="megrok.paypal.countrycodes",
    )

    test_ipn = schema.Bool(
        title=u"Is message IPN test?",
        description=(
            u"Whether the message is a test message. It is one of the "
            u"following values: 1 - the message is directed to the Sandbox"
        ),
        default=False,
    )

    txn_id = schema.TextLine(
        title=u"Transaction ID",
        description=(
            u"The merchant's original transaction identification "
            u"number for the payment from the buyer, against which the "
            u"case was registered."
        ),
        max_length=19,
    )

    txn_type = schema.TextLine(
        title=u"Transacion Type",
        description=(
            u"The kind of transaction for which the IPN message was sent."
        ),
        max_length=128,
    )

    verify_sign = schema.TextLine(
        title=u"Verify sign",
        description=(
            u"Encrypted string used to validate the authenticity of the "
            u"transaction"
        ),
    )

    #
    # Buyer related infos
    #
    address_country = schema.TextLine(
        title=u"Country",
        description=u"Country of customer's address",
        max_length=64,
    )

    address_city = schema.TextLine(
        title=u"City",
        description=u"City of customer's address",
        max_length=40,
    )

    address_country_code = schema.Choice(
        title=u"Country Code",
        description=(
            u"ISO 3166.1 country code (2-letter) associated with "
            u"customer's address."
            ),
        vocabulary="megrok.paypal.contrycodes",
    )

    address_name = schema.TextLine(
        title=u"Name",
        description=(
            u"Name used with address (included when the customer "
            u"provides a Gift Address)"
            ),
        max_length=128,
    )

    address_state = schema.TextLine(
        title=u"State",
        description=u"State of customer's address",
        max_length=40,
    )

    address_status = schema.TextLine(
        title=u"Status",
        description=(
            u"Whether the customer provided a confirmed address. It "
            u"is one of the following values: "
            u"confirmed - Customer provided a confirmed address. "
            u"unconfirmed - Customer provided an unconfirmed address."),
        max_length=11,
    )

    address_street = schema.TextLine(
        title=u"Street",
        description=u"Customer's street address.",
        max_length=200,
    )

    address_zip = schema.TextLine(
        title=u"Zip code",
        description=u"Zip code of customer's address.",
        max_length=20,
    )

    contact_phone = schema.TextLine(
        title=u"Phone",
        description=u"Customer's telephone number.",
        max_length=20,
    )

    first_name = schema.TextLine(
        title=u"First Name",
        description=u"Customer's first name",
        max_length=64,
    )

    last_name = schema.TextLine(
        title=u"Last Name",
        description=u"Customer's last name",
        max_length=64,
    )

    payer_business_name = schema.TextLine(
        title=u"Payer Business Name",
        description=u"Customer's company name, if customer is a business",
        max_length=127,
    )

    payer_email = schema.TextLine(
        title=u"Payer Email",
        description=(
            u"Customer's primary email address. Use this email "
            u"to provide any credits."),
        max_length=127,
    )

    payer_id = schema.TextLine(
        title=u"Payer ID",
        description=u"Unique customer ID.",
        max_length=13,
    )

    #
    # Payment info vars
    # (https://developer.paypal.com/docs/classic/ipn/integration-guide/
    #  IPNandPDTVariables/)
    #
    auth_amount = schema.Decimal(
        title=u"Amount",
        description=u"Authorization amount",
        default=decimal.Decimal("0.00"),
        )

    auth_exp = schema.TextLine(
        title=u"Authorization Expiration Datetime",
        description=(
            u"Authorization expiration date and time, in the following "
            u"format: HH:MM:SS DD Mmm YY, YYYY PST"
            ),
        max_length=28,
        )

    auth_id = schema.TextLine(
        title=u"Auth ID",
        description=u"Authorization Identification Number",
        max_length=19,
        )

    auth_status = schema.TextLine(
        title=u"Auth Status",
        description=u"Status of Authorization",
        max_length=9,
        )

    exchange_rate = schema.Decimal(
        title=u"Exchange Rate",
        description=(
            u"Exchange rate used if a currency conversion occurred."
            ),
        default=decimal.Decimal("1.00"),
        )

    invoice = schema.TextLine(
        title=u"Invoice",
        description=(
            u"Pass-through variable you can use to identify your "
            u"Invoice Number for this purchase. If omitted, no variable "
            u"is passed back."
            ),
        max_length=127,
        )

    item_nameX = schema.TextLine(
        title=u"Item Name",
        description=(
            u"Item name as passed by you, the merchant. Or, if not "
            u"passed by you, as entered by your customer. If this is a "
            u"shopping cart transaction, PayPal will append the number of "
            u"the item (e.g., item_name1, item_name2, and so forth)."
            ),
        max_length=127,
        )

    item_numberX = schema.TextLine(
        title=u"Item Number",
        description=(
            u"Pass-through variable for you to track purchases. It will "
            u"get passed back to you at the completion of the payment. "
            u"If omitted, no variable will be passed back to you. If this "
            u"is a shopping cart transaction, PayPal will append the "
            u"number of the item (e.g., item_number1, item_number2, and "
            u"so forth)"
            ),
        max_length=127,
        )

    mc_currency = schema.TextLine(
        title=u"Payment Currency",
        description=(
            u"For payment IPN notifications, this is the currency of the "
            u"payment. For non-payment subscription IPN notifications "
            u"(i.e., txn_type= signup, cancel, failed, eot, or modify), "
            u"this is the currency of the subscription. For payment "
            u"subscription IPN notifications, it is the currency of the "
            u"payment (i.e., txn_type = subscr_payment)"
            ),
        default=u"USD",
        max_length=32,
        )

    mc_fee = schema.Decimal(
        title=u"Transaction Fee",
        description=(
            u"Transaction fee associated with the payment. mc_gross minus "
            u"mc_fee equals the amount deposited into the receiver_email "
            u"account. Equivalent to payment_fee for USD payments. If this "
            u"amount is negative, it signifies a refund or reversal, and "
            u"either of those payment statuses can be for the full or partial "
            u"amount of the original transaction fee."
            ),
        default=decimal.Decimal("0.00"),
        )

    mc_gross = schema.Decimal(
        title=u"Payment Gross",
        description=(
            u"Full amount of the customer's payment, before transaction "
            u"fee is subtracted. Equivalent to payment_gross for USD "
            u"payments. If this amount is negative, it signifies a refund "
            u"or reversal, and either of those payment statuses can be for "
            u"the full or partial amount of the original transaction."
            ),
        default=decimal.Decimal("0.00"),
        )

    mc_handling = schema.Decimal(
        title=u"Handling fees",
        description=u"Total handling amount associated with the transaction.",
        default=decimal.Decimal("0.00"),
        )

    mc_shipping = schema.Decimal(
        title=u"Shipping costs",
        description=u"Total shipping amount associated with the transaction.",
        default=decimal.Decimal("0.00"),
        )

    memo = schema.TextLine(
        title=u"Memo",
        description=(
            u"Memo as entered by your customer in PayPal Website Payments "
            u"note field."
            ),
        max_length=255,
        )

    num_cart_items = schema.Int(
        title=u"Number of cart items",
        description=(
            u"If this is a PayPal Shopping Cart transaction, number of "
            u"items in cart."
            ),
        default=0,
        )

    option_name1 = schema.TextLine(
        title=u"Option name 1",
        description=(
            u"Option 1 name as requested by you. PayPal appends the "
            u"number of the item where x represents the number of the "
            u"shopping cart detail item (e.g., option_name1, option_name2)."
            ),
        max_length=64,
        )

    option_name2 = schema.TextLine(
        title=u"Option name 2",
        description=(
            u"Option 2 name as requested by you. PayPal appends the "
            u"number of the item where x represents the number of the "
            u"shopping cart detail item (e.g., option_name2, option_name2)."
            ),
        max_length=64,
        )

    payer_status = schema.TextLine(
        title=u"Payer Status",
        description=(
            u"Whether the customer has a verified PayPal account. "
            u"verified - Customer has a verified PayPal account. "
            u"unverified - Customer has an unverified PayPal account."
            ),
        max_length=10,
        )

    payment_date = schema.TextLine(
        title=u"Payment Date",
        description=(
            u"Time/date stamp generated by PayPal."
            u"Format: HH:MM:SS DD Mmm YY, YYYY PST"
            ),
        max_length=28,
        )

    payment_gross = schema.Decimal(
        title=u"Payment Gross",
        description=(
            u"Full USD amount of the customer's payment, "
            u"before transaction fee is subtracted. Will be empty for "
            u"non-USD payments. This is a legacy field replaced by "
            u"mc_gross. If this amount is negative, it signifies a refund "
            u"or reversal, and either of those payment statuses can be for "
            u"the full or partial amount of the original transaction."
            ),
        default=decimal.Decimal("0.00"),
        )

    payment_status = schema.TextLine(
        title=u"Payment Status",
        description=(
            u"The status of the payment: "

            u"Canceled_Reversal: A reversal has been canceled. For "
            u"example, you won a dispute with the customer, and the "
            u"funds for the transaction that was reversed have been "
            u"returned to you. "
            u" "
            u"Completed: The payment has been completed, and the funds "
            u"have been added successfully to your account balance. "
            u" "
            u"Created: A German ELV payment is made using Express Checkout. "
            u" "
            u"Denied: The payment was denied. This happens only if the "
            u"payment was previously pending because of one of the reasons "
            u"listed for the pending_reason variable or the "
            u"Fraud_Management_Filters_x variable. "
            u" "
            u"Expired: This authorization has expired and cannot be captured."
            u" "
            u"Failed: The payment has failed. This happens only if "
            u"the payment was made from your customer's bank account."
            u" "
            u"Pending: The payment is pending. See pending_reason for "
            u"more information."
            u" "
            u"Refunded: You refunded the payment."
            u" "
            u"Reversed: A payment was reversed due to a chargeback or "
            u"other type of reversal. The funds have been removed from "
            u"your account balance and returned to the buyer. The "
            u"reason for the reversal is specified in the ReasonCode element."
            u" "
            u"Processed: A payment has been accepted."
            u" "
            u"Voided: This authorization has been voided."
            ),
        max_length=17,
        )

    payment_type = schema.TextLine(
        title=u"Payment Type",
        description=(
            u"echeck: This payment was funded with an eCheck. "
            u"instant: This payment was funded with PayPal balance, "
            u"credit card, or Instant Transfer."
            ),
        max_length=7,
        )

    pending_reason = schema.TextLine(
        title=u"Pending Reason",
        description=(
            u"This variable is set only if payment_status is Pending. "
            u" "
            u"address: The payment is pending because your customer did "
            u"not include a confirmed shipping address and your "
            u"Payment Receiving Preferences is set yo allow you to "
            u"manually accept or deny each of these payments. To change "
            u"your preference, go to the Preferences section of your Profile."
            u" "
            u"authorization: You set the payment action to Authorization "
            u"and have not yet captured funds."
            u" "
            u"echeck: The payment is pending because it was made by an "
            u"eCheck that has not yet cleared."
            u" "
            u"intl: The payment is pending because you hold a non-U.S. "
            u"account and do not have a withdrawal mechanism. You must "
            u"manually accept or deny this payment from your Account "
            u"Overview."
            u" "
            u"multi_currency: You do not have a balance in the currency "
            u"sent, and you do not have your profiles's Payment Receiving "
            u"Preferences option set to automatically convert and accept "
            u"this payment. As a result, you must manually accept or "
            u"deny this payment."
            u" "
            u"order: You set the payment action to Order and have not "
            u"yet captured funds."
            u" "
            u"paymentreview: The payment is pending while it is reviewed "
            u"by PayPal for risk."
            u" "
            u"regulatory_review: The payment is pending because "
            u"PayPal is reviewing it for compliance with government "
            u"regulations. PayPal will complete this review within "
            u"72 hours. When the review is complete, you will receive "
            u"a second IPN message whose payment_status/reason code "
            u"variables indicate the result."
            u" "
            u"unilateral: The payment is pending because it was made "
            u"to an email address that is not yet registered or confirmed."
            u" "
            u"upgrade: The payment is pending because it was made via "
            u"credit card and you must upgrade your account to Business "
            u"or Premier status before you can receive the funds. "
            u"upgrade can also mean that you have reached the monthly "
            u"limit for transactions on your account."
            u" "
            u"verify: The payment is pending because you are not yet "
            u"verified. You must verify your account before you can "
            u"accept this payment."
            u" "
            u"other: The payment is pending for a reason other than "
            u"those listed above. For more information, contact PayPal "
            u"Customer Service."
            ),
        max_length=14,
        )

    protection_eligibility = schema.TextLine(
        title=u"Protection Eligibility",
        description=(
            u"ExpandedSellerProtection: Seller is protected by Expanded "
            u"seller protection "
            u"SellerProtection: Seller is protected by PayPal's "
            u"Seller Protection Policy "
            u"None: Seller is not protected under Expanded seller "
            u"protection nor the Seller Protection Policy"
            ),
        max_length=32,
        )

    quantity = schema.Int(
        title=u"Quantity",
        description=(
            u"Quantity as entered by your customer or as passed by "
            u"you, the merchant. If this is a shopping cart "
            u"transaction, PayPal appends the number of the item "
            u"(e.g. quantity1, quantity2)."
            ),
        default=1,
        )

    reason_code = schema.TextLine(
        title=u"Reason Code",
        description=(
            u"This variable is set if payment_status is Reversed, "
            u"Refunded, Canceled_Reversal, or Denied. "
            u" "
            u"adjustment_reversal: Reversal of an adjustment. "
            u" "
            u"admin_fraud_reversal: The transaction has been reversed "
            u"due to fraud detected by PayPal administrators."
            u" "
            u"admin_reversal: The transaction has been reversed by "
            u"PayPal administrators."
            u" "
            u"buyer-complaint: The transaction has been reversed due "
            u"to a complaint from your customer."
            u" "
            u"chargeback: The transaction has been reversed due to "
            u"a chargeback by your customer."
            u" "
            u"chargeback_reimbursement: Reimbursement for a chargeback."
            u" "
            u"chargeback_settlement: Settlement of a chargeback."
            u" "
            u"guarantee: The transaction has been reversed because your "
            u"customer exercised a money-back guarantee."
            u" "
            u"other: Unspecified reason."
            u" "
            u"refund: The transaction has been reversed because you "
            u"gave the customer a refund."
            u" "
            u"regulatory_block: PayPal blocked the transaction due to a "
            u"violation of a government regulation. In this case, "
            u"payment_status is Denied."
            u" "
            u"regulatory_reject: PayPal rejected the transaction due "
            u"to a violation of a government regulation and returned "
            u"the funds to the buyer. In this case, payment_status is Denied."
            u" "
            u"regulatory_review_exceeding_sla: PayPal did not complete "
            u"the review for compliance with government regulations "
            u"within 72 hours, as required. Consequently, PayPal "
            u"auto-reversed the transaction and returned the funds to "
            u"the buyer. In this case, payment_status is Denied. Note "
            u"that 'sla' stand for 'service level agreement'."
            u" "
            u"unauthorized_claim: The transaction has been reversed "
            u"because it was not authorized by the buyer."
            u" "
            u"unauthorized_spoof: The transaction has been reversed due to "
            u"a customer dispute in which an unauthorized spoof is suspected."
            ),
        max_length=15,
        )

    remaining_settle = schema.Decimal(
        title=u"Remaining Settle",
        description=(
            u"Remaining amount that can be captured with Authorization "
            u"and Capture"
            ),
        default=decimal.Decimal("0.00"),
        )

    settle_amount = schema.Decimal(
        title=u"Settle Amount",
        description=(
            u"Amount that is deposited into the account's primary balance "
            u"after a currency conversion from automatic conversion "
            u"(through your Payment Receiving Preferences) or manual "
            u"conversion (through manually accepting a payment)."
            ),
        default=decimal.Decimal("0.00"),
        )

    settle_currency = schema.TextLine(
        title=u"Settle Currency",
        description=u"Currency of settle_amount",
        max_length=32,
        )

    shipping = schema.Decimal(
        title=u"Shipping",
        description=(
            u"Shipping charges associated with this transaction. "
            u"Format: unsigned, no currency symbol, two decimal places."
            ),
        default=decimal.Decimal("0.00"),
        )

    shipping_method = schema.TextLine(
        title=u"Shipping Method",
        description=(
            u"The name of a shipping method from the Shipping "
            u"Calculations section of the merchant's account profile. "
            u"The buyer selected the named shipping method for this "
            u"transaction."
            ),
        max_length=255,
        )

    tax = schema.Decimal(
        title=u"Tax",
        description=(
            u"Amount of tax charged on payment. PayPal appends the "
            u"number of the item (e.g., item_name1, item_name2). The "
            u"taxx variable is included only if there was a specific tax "
            u"amount applied to a particular shopping cart item. Because "
            u"total tax may apply to other items in the cart, the sum "
            u"of taxx might not total to tax."
            ),
        default=decimal.Decimal("0.00"),
        )

    transaction_entity = schema.TextLine(
        title=u"Transaction Entity",
        description=u"Authorization and Capture transaction entity",
        max_length=7,
        )
Exemplo n.º 25
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)
Exemplo n.º 26
0
class IEpic(model.Schema):

    text = RichText(title=_(u"Text"))
    estimate = schema.Decimal(title=_(u"Estimate (man days)"),
                              default=Decimal('0.00'))
class IProject(model.Schema):

    customer = schema.TextLine(
        title=_(u"Customer")
    )

    form.widget(customer_contact=DataGridFieldFactory)
    customer_contact = schema.List(
        title=_(u"Customer contacts"),
        value_type=DictRow(
            title=u"Contact",
            schema=ICustomerContact
        )
    )

    budget = schema.Decimal(
        title=_(u"Budget (man days)"),
        description=_(u"The man days that this project is paid for")
    )
    initial_estimate = schema.Decimal(
        title=_(u"Estimate (man days)"),
        description=_(
            u"The man days required for completion, "
            u"as initially estimated by the project manager"
        ),
        required=False,
        default=Decimal('0.00')
    )
    prj_start_date = schema.Date(
        title=_(u"Start date"),
    )
    prj_expected_end_date = schema.Date(
        title=_(u"Expected end date"),
        required=False
    )
    prj_end_date = schema.Date(
        title=_(u"End date"),
        required=False
    )
    classifiers = Select2MultiField(
        title=_(u"Project classifiers"),
        description=_(
            u"Some keywords that describe the project "
            u"and used technologies"
        ),
        value_type=schema.TextLine(),
        search_view=lambda x: '{}/select2-classifier-search'.format(x),
        required=False
    )

    repositories = schema.List(
        title=_(u"Repositories"),
        description=_(u"The HTTP URLs of the repositories "
                      u"(e.g. https://github.com/company/my.repository/)"),
        value_type=schema.URI(),
        required=False
    )
    environments = schema.List(
        title=_(u"URLs"),
        description=_(u"The URLs of the various online environments "
                      u"(staging, production)"),
        value_type=schema.Object(title=_(u"Environment"),
                                 schema=IEnvironment),
        required=False
    )
    milestones = schema.List(
        title=_(u"Milestones"),
        description=_(u"Milestones are the different phases of the project. "
                      u"Each milestone should formally define "
                      u"a self-sufficient deliverable, "
                      u"that can then be put into production."),
        value_type=schema.Object(title=_(u"Milestone"),
                                 schema=IMilestone),
        required=False
    )

    notes = RichText(
        title=_(u"Notes"),
        required=False
    )

    form.omitted(
        'priority',
        'active',
        'compass_effort',
        'compass_notes',
        'operatives'
    )
    priority = schema.Int(
        title=_(u"Priority"),
        default=100,
        min=0
    )
    active = schema.Bool(
        title=_(u"Active"),
        default=True
    )
    compass_effort = schema.Decimal(
        title=_(u"Effort (in man days)"),
        default=Decimal('0.00')
    )
    compass_notes = schema.Text(
        title=_(u"Notes"),
        required=False
    )

    operatives = schema.List(
        title=_(u"Operatives"),
        description=_(
            u"The user IDs of those that have operative roles in this project "
            u"(coders, designers, project managers, accounts etc.). "
            u"Customers should not be included in this list."
            u"Adding someone here will add them automatically "
            u"as managers to the default tracker."
        ),
        value_type=schema.Object(title=_(u"Resource"),
                                 schema=IResource),
        required=False
    )