Ejemplo n.º 1
0
def next_correction_id(key, data, errors, context):
    # if there was an error before calling our validator
    # don't bother with our validation
    if errors[key]:
        return

    data[key] = h.next_correction_id()
Ejemplo n.º 2
0
def correction_create_name(key, data, errors, context):
    # if there was an error before calling our validator
    # don't bother with our validation
    if errors[key]:
        return

    current_name = data.get(key, "")
    if not current_name or current_name is missing or current_name.endswith("-clone"):
        correction_id = _data_lookup(("correction_id",), data)
        if not correction_id or (current_name is not missing and current_name.endswith("-clone")):
            correction_id = h.next_correction_id()
            _data_update(correction_id, ("correction_id",), data)

        new_name = u"correction-{correction_id}".format(correction_id=correction_id).lower()
        _data_update(new_name, ("name",), data)
        _data_update(new_name, ("title",), data)
Ejemplo n.º 3
0
def correction_create_name(key, data, errors, context):
    # if there was an error before calling our validator
    # don't bother with our validation
    if errors[key]:
        return

    current_name = data.get(key, '')
    if (not current_name or current_name is missing
            or current_name.endswith('-clone')):
        correction_id = _data_lookup(('correction_id', ), data)
        if not correction_id or (current_name is not missing
                                 and current_name.endswith('-clone')):
            correction_id = h.next_correction_id()
            _data_update(correction_id, ('correction_id', ), data)

        new_name = u'correction-{correction_id}'.format(
            correction_id=correction_id).lower()
        _data_update(new_name, ('name', ), data)
        _data_update(new_name, ('title', ), data)
Ejemplo n.º 4
0
def correction_create_name(key, data, errors, context):
    # if there was an error before calling our validator
    # don't bother with our validation
    if errors[key]:
        return

    current_name = data.get(key, '')
    correction_id = _data_lookup(('correction_id',), data)
    if not correction_id or \
       current_name is missing or \
       current_name.endswith('-clone'):
        correction_id = h.next_correction_id()
        _data_update(correction_id, ('correction_id',), data)

    new_name = u'correction-{correction_id}'.format(
        correction_id=correction_id
    ).lower()
    _data_update(new_name, ('name',), data)
    _data_update(new_name, ('title',), data)