コード例 #1
0
def category_dict(category_name):
    """
    Return the items related to a category as a dictionary

    Args:
      category_name: the category's name.
    """
    category = db_helper.get_category_by_name(category_name)

    category_json = category.serialize
    items = db_helper.get_items(category.id)

    items_json = []
    for item in items:
        items_json.append(item.serialize)

    category_json['items'] = items_json

    return category_json
コード例 #2
0
ファイル: application.py プロジェクト: rruizriol/item-catalog
def category_dict(category_name):
    """
    Return the items related to a category as a dictionary

    Args:
      category_name: the category's name.
    """
    category = db_helper.get_category_by_name(category_name)
    
    category_json = category.serialize
    items = db_helper.get_items(category.id)
        
    items_json = []
    for item in items:
        items_json.append(item.serialize)
            
    category_json['items'] = items_json
    
    return category_json  
コード例 #3
0
def catalog_dict():
    """Return the catalog data as a dictionary"""
    categories = db_helper.get_categories()

    categories_json = []

    for category in categories:
        category_json = category.serialize
        items = db_helper.get_items(category.id)

        items_json = []

        for item in items:
            items_json.append(item.serialize)

        category_json['items'] = items_json
        categories_json.append(category_json)

    return categories_json
コード例 #4
0
ファイル: application.py プロジェクト: rruizriol/item-catalog
def catalog_dict():
    """Return the catalog data as a dictionary"""
    categories = db_helper.get_categories()
    
    categories_json = []
    
    for category in categories:
        category_json = category.serialize
        items = db_helper.get_items(category.id)
        
        items_json = []
        
        for item in items:
            items_json.append(item.serialize)
            
        category_json['items'] = items_json
        categories_json.append(category_json)
        
    return categories_json