Exemplo n.º 1
0
def item_dict(category_name, item_title):
    """Return the item data as a dictionary.

    Args:
      category_name: the category's name.
      item_title: the category's name.
    """
    category = db_helper.get_category_by_name(category_name)
    item = db_helper.get_item_by_title(item_title, category.id)
    return item.serialize
Exemplo n.º 2
0
def item_dict(category_name, item_title):
    """Return the item data as a dictionary.

    Args:
      category_name: the category's name.
      item_title: the category's name.
    """
    category = db_helper.get_category_by_name(category_name)
    item = db_helper.get_item_by_title(item_title, category.id)
    return item.serialize  
Exemplo n.º 3
0
def category_page(category_name):
    """Render a page with items associated to a category.

    Args:
      category_name: the category's name.
    """
    categories = db_helper.get_categories()
    category   = db_helper.get_category_by_name(category_name)
    items_view = db_helper.get_items_view(category.id)
    return render_template('category.html', items_view=items_view,
                           categories=categories, category_name = category_name) 
Exemplo n.º 4
0
def category_page(category_name):
    """Render a page with items associated to a category.

    Args:
      category_name: the category's name.
    """
    categories = db_helper.get_categories()
    category = db_helper.get_category_by_name(category_name)
    items_view = db_helper.get_items_view(category.id)
    return render_template('category.html',
                           items_view=items_view,
                           categories=categories,
                           category_name=category_name)
Exemplo n.º 5
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
Exemplo n.º 6
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