def add_items(): email = '*****@*****.**' username = '******' user = User.create(email=email, username=username, picture='') for category_path in items: category = Category.get_one(category_path) for item in items[category_path]: Item.add(user, category, Item(**item))
def add_item(category_path): category = Category.get_one(category_path) fields = field_list() if request.method == 'GET': return render_template('add.html', fields=fields, category=category) else: error = check_request_fields(fields) if error: return render_template('add.html', fields=fields, category=category, error=error) else: obj = {} for field in fields: obj[field['name']] = field['value'] error = Item.add(g.current_user, category, Item(**obj)) if error: return render_template('add.html', fields=fields, category=category, error=error) else: return redirect( url_for('show_category', category_path=category.path))