Beispiel #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
Beispiel #2
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  
Beispiel #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
Beispiel #4
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