Beispiel #1
0
def db_insert_consumption_record(user_id, food_id):
    try:
        user = db_retrieve_user(user_id)
        food = db_retrieve_food(food_id)
        record = ConsumptionHistory(food=food, user=user)
        record.save()
        return record
    except:
        return False
def db_insert_consumption_record(user_id,food_id):
    try:
        user = db_retrieve_user(user_id)
        food = db_retrieve_food(food_id)
        record = ConsumptionHistory(
            food=food,
            user=user
        )
        record.save()
        return record
    except:
        return False
Beispiel #3
0
def db_insert_tag(tag_dict):
    generic_id = tag_dict['generic_id']
    if tag_dict["type"] == "Food":
        generic_object = db_retrieve_food(generic_id)
    else:
        generic_object = db_retrieve_user(generic_id)
    new_tag = TagModel(
        tag_label=tag_dict['tag_name'],
        semantic_tag_item=tag_dict['tag_id'],
        semantic_tag_item_label=tag_dict['tag_label'],
        semantic_tag_item_description=tag_dict['tag_description'],
        tagged_object=generic_object)
    try:
        new_tag.save()
        return True
    except:
        return False
def db_insert_tag(tag_dict):
    generic_id = tag_dict['generic_id']
    if tag_dict["type"] == "Food":
        generic_object = db_retrieve_food(generic_id)
    else:
        generic_object = db_retrieve_user(generic_id)
    new_tag = TagModel(
        tag_label=tag_dict['tag_name'],
        semantic_tag_item=tag_dict['tag_id'],
        semantic_tag_item_label=tag_dict['tag_label'],
        semantic_tag_item_description=tag_dict['tag_description'],
        tagged_object=generic_object
    )
    try:
        new_tag.save()
        return True
    except:
        return False