Пример #1
0
def _get_last_version_created_in_transaction(event: ISheetReferenceNewVersion)\
        -> IItemVersion:
    if event.is_batchmode:
        new_version = get_last_new_version(event.registry, event.object)
    else:
        new_version = get_following_new_version(event.registry, event.object)
    return new_version
Пример #2
0
def _get_last_version_created_in_transaction(event: ISheetReferenceNewVersion)\
        -> IItemVersion:
    if event.is_batchmode:
        new_version = get_last_new_version(event.registry, event.object)
    else:
        new_version = get_following_new_version(event.registry, event.object)
    return new_version
Пример #3
0
def validate_linear_history_no_fork(node: colander.SchemaNode, value: list):
    """Validate lineare history (no fork) for the follows field.

    :param:'value': list of one 'follows' resource.

    :raises colander.Invalid: if value does not reference the last version.
    """
    context = node.bindings['context']
    request = node.bindings['request']
    if is_batchmode(request):
        last_new_version = get_last_new_version(request.registry, context)
        if last_new_version is not None:
            # Store ths last new version created in this transaction
            # so :func:`adhocracy_core.rest.views.ItemPoolView.post`
            # can do an put instead of post action in batch requests.
            request.validated['_last_new_version_in_transaction'] =\
                last_new_version
            return
    last = get_last_version(context, request.registry)
    _assert_follows_eq_last_version(node, value, last)
Пример #4
0
def validate_linear_history_no_fork(node: colander.SchemaNode, value: list):
    """Validate lineare history (no fork) for the follows field.

    :param:'value': list of one 'follows' resource.

    :raises colander.Invalid: if value does not reference the last version.
    """
    context = node.bindings['context']
    request = node.bindings['request']
    if is_batchmode(request):
        last_new_version = get_last_new_version(request.registry, context)
        if last_new_version is not None:
            # Store ths last new version created in this transaction
            # so :func:`adhocracy_core.rest.views.ItemPoolView.post`
            # can do an put instead of post action in batch requests.
            request.validated['_last_new_version_in_transaction'] =\
                last_new_version
            return
    last = get_last_version(context, request.registry)
    _assert_follows_eq_last_version(node, value, last)