예제 #1
0
    (3, CLASSIFICATION_CLASSIFIED),
    )


grok.global_utility(
    utils.create_restricted_vocabulary(
        IClassification['classification'],
        CLASSIFICATION_OPTIONS,
        message_factory=_),
    provides=schema.interfaces.IVocabularyFactory,
    name=u'classification_classification_vocabulary')


form.default_value(field=IClassification['classification'])(
    utils.set_default_with_acquisition(
        field=IClassification['classification'],
        default=CLASSIFICATION_UNPROTECTED
        )
    )


# PUBLIC: Vocabulary and default value
PUBLIC_TRIAL_UNCHECKED = u'unchecked'
PUBLIC_TRIAL_PUBLIC = u'public'
PUBLIC_TRIAL_PRIVATE = u'private'
PUBLIC_TRIAL_OPTIONS = (
    (1, PUBLIC_TRIAL_UNCHECKED),
    (2, PUBLIC_TRIAL_PUBLIC),
    (3, PUBLIC_TRIAL_PRIVATE),
    )

예제 #2
0
    return retention_period_settings.is_restricted


grok.global_utility(
    utils.create_restricted_vocabulary(
        ILifeCycle['retention_period'],
        _get_retention_period_options,
        message_factory=_,
        restricted=_is_retention_period_restricted),
    provides=schema.interfaces.IVocabularyFactory,
    name=u'lifecycle_retention_period_vocabulary')


# Default value
form.default_value(field=ILifeCycle['retention_period'])(
    utils.set_default_with_acquisition(
        field=ILifeCycle['retention_period'],
        default=5))


# Validator
class CustodyPeriodValidator(IntGreaterEqualThanParentValidator):
    pass


validator.WidgetValidatorDiscriminators(
    CustodyPeriodValidator,
    field=ILifeCycle['custody_period'])


grok.global_adapter(CustodyPeriodValidator)
예제 #3
0
    grok.name('seantis.dir.facility.item.detailviewletmanager')


# Provide the facility fields in a behavior which will then be activated for
# for seantis.reservation.resource. This allows resources to contain the
# fields of the facility. These fields will be filled with the values of the
# facility on creation. After that the values are independent.


class IFacilityFields(IFacilityDirectoryItem):
    """Provides the fields of Facility Directory Item to any Dexterity type"""
    form.omitted(*IDirectoryItemBase.names())


def default_value(data):
    """ Gets the default value of the context (facility) if the attribute
    is found.

    """
    if hasattr(data.context, data.field.__name__):
        return getattr(data.context, data.field.__name__)

# Setup the decorators
defaults = [None] * len(IFacilityDirectoryItem.names())
for ix, field in enumerate(IFacilityDirectoryItem.names()):
    defaults[ix] = form.default_value(
        field=IFacilityFields[field]
    )(default_value)

alsoProvides(IFacilityFields, IFormFieldProvider)
예제 #4
0
    # Option-   # Option Name
    # level     #
    (1, CLASSIFICATION_UNPROTECTED),
    (2, CLASSIFICATION_CONFIDENTIAL),
    (3, CLASSIFICATION_CLASSIFIED),
)

grok.global_utility(utils.create_restricted_vocabulary(
    IClassification['classification'],
    CLASSIFICATION_OPTIONS,
    message_factory=_),
                    provides=schema.interfaces.IVocabularyFactory,
                    name=u'classification_classification_vocabulary')

form.default_value(field=IClassification['classification'])(
    utils.set_default_with_acquisition(field=IClassification['classification'],
                                       default=CLASSIFICATION_UNPROTECTED))

# PUBLIC: Vocabulary and default value
PUBLIC_TRIAL_UNCHECKED = u'unchecked'
PUBLIC_TRIAL_PUBLIC = u'public'
PUBLIC_TRIAL_PRIVATE = u'private'
PUBLIC_TRIAL_OPTIONS = (
    (1, PUBLIC_TRIAL_UNCHECKED),
    (2, PUBLIC_TRIAL_PUBLIC),
    (3, PUBLIC_TRIAL_PRIVATE),
)

grok.global_utility(utils.create_restricted_vocabulary(
    IClassification['public_trial'], PUBLIC_TRIAL_OPTIONS, message_factory=_),
                    provides=schema.interfaces.IVocabularyFactory,
예제 #5
0
    registry = getUtility(IRegistry)
    retention_period_settings = registry.forInterface(IRetentionPeriodRegister)
    return retention_period_settings.is_restricted


grok.global_utility(utils.create_restricted_vocabulary(
    ILifeCycle['retention_period'],
    _get_retention_period_options,
    message_factory=_,
    restricted=_is_retention_period_restricted),
                    provides=schema.interfaces.IVocabularyFactory,
                    name=u'lifecycle_retention_period_vocabulary')

# Default value
form.default_value(field=ILifeCycle['retention_period'])(
    utils.set_default_with_acquisition(field=ILifeCycle['retention_period'],
                                       default=5))


# Validator
class CustodyPeriodValidator(IntGreaterEqualThanParentValidator):
    pass


validator.WidgetValidatorDiscriminators(CustodyPeriodValidator,
                                        field=ILifeCycle['custody_period'])

grok.global_adapter(CustodyPeriodValidator)

# ---------- CUSTODY PERIOD -----------
# Vocabulary