def add_item(category_slug=None): """ Add a new Item Form. :param category_slug: The category slug """ # Get the current category using the slug current_category = Category.where('slug', category_slug).first() return render_template('items/add.html', categories=Category.all(), current_category=current_category)
def list_items(category_slug): """ Get all items of the current category :param category_slug: """ # Get the category and check if it's exist or fail to 404 page if not category = Category.where('slug', category_slug).first_or_fail() return render_template('items/index.html', category=category, items=category.items)