Beispiel #1
0
def generate_lookup(store_id):
    from application.models.base import db
    ''' insert store info on lookup'''

    lookups_title = _descriptions()
    version = 1

    try:
        for name, type, description in lookups_title:
            lookup = Lookup.create(store_id=store_id,
                                   name=name,
                                   type=type,
                                   description=description,
                                   version=version)
            if lookup is not None:
                lookup.save()
        db.session.commit()
    except Exception as e:
        raise e

    result = Lookup.get_all_store_ids(store_id)

    lookup_ids = dict()
    for lookups in result:
        lookup_ids[str(lookups.name).strip()] = lookups.id

    return lookup_ids
Beispiel #2
0
def get_lookup_values_by_store(store_id):
    ids = Lookup.get_all_store_ids(store_id)
    return LookupValue.find_all_by_lookup_ids([id.id for id in ids])