Exemplo n.º 1
0
def db_update_fieldattr(store, field_id, fieldattr):
    attr = store.find(
        models.FieldAttr,
        And(models.FieldAttr.field_id == field_id,
            models.FieldAttr.name == fieldattr['name'])).one()
    if not attr:
        attr = models.FieldAttr()

    fieldattr['field_id'] = field_id

    attr.update(fieldattr)

    store.add(attr)

    return attr.id
Exemplo n.º 2
0
def db_update_fieldattr(store, field_id, attr_name, attr_dict, language):
    attr = store.find(models.FieldAttr, And(models.FieldAttr.field_id == field_id, models.FieldAttr.name == attr_name)).one()
    if not attr:
        attr = models.FieldAttr()

    attr_dict['name'] = attr_name
    attr_dict['field_id'] = field_id

    if attr_dict['type'] == 'bool':
        attr_dict['value'] = 'True' if attr_dict['value'] == True else 'False'
    elif attr_dict['type'] == u'localized':
        fill_localized_keys(attr_dict, ['value'], language)

    attr.update(attr_dict)

    store.add(attr)

    return attr.id