# CLASSIFICATION: Vocabulary and default value
CLASSIFICATION_UNPROTECTED = u'unprotected'
CLASSIFICATION_CONFIDENTIAL = u'confidential'
CLASSIFICATION_CLASSIFIED = u'classified'
CLASSIFICATION_OPTIONS = (
    # 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'

# CLASSIFICATION: Vocabulary and default value
CLASSIFICATION_UNPROTECTED = u'unprotected'
CLASSIFICATION_CONFIDENTIAL = u'confidential'
CLASSIFICATION_CLASSIFIED = u'classified'
CLASSIFICATION_OPTIONS = (
    # 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),
Beispiel #3
0
        pos = int(nums[- i - 1])
        options.append((pos, num))

    return options


def _is_retention_period_restricted(vocabulary):
    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):
Beispiel #4
0
        num = int(num)
        pos = int(nums[-i - 1])
        options.append((pos, num))

    return options


def _is_retention_period_restricted(vocabulary):
    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