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
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)
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)
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