def edit_shoppinglist(_id): page_title = "Edit" index_ = Data.get_index(_id, Data.shoppinglists) form = Shoppinglist_nameForm(request.form) form.name.data = Data.shoppinglists[index_]['Name'] if form.validate_on_submit(): title = request.form['name'] Data.shoppinglists[index_]['title'] = title flash('Your Shopping list has been updated') return redirect(url_for('dashboard')) return render_template('dashboard.html', form=form, title=page_title)
def edit_shoppinglist_item(_id): page_title = "Edit" index_ = Data.get_index(_id, Data.items) form = ShoppingitemForm() # ### populating the form for user to edit ### form.name.data = Data.items[index_]['item_name'] form.quantity.data = Data.items[index_]['quantity'] if form.validate_on_submit(): title = request.form['title'] quantity = request.form['body'] Data.items[index_]['item_name'] = title Data.items[index_]['quantity'] = quantity flash('Your Item has been updated', 'success') return redirect( url_for('shoppinglist_items', _id=Data.items[index_]['owner_id'])) return render_template('list_items.html', form=form, title=page_title)
def delete_item(_id): index_ = Data.get_index(_id, Data.items) sh_id = Data.items[index_]['owner_id'] Data.delete_dictionary(_id, Data.items) flash('Item deleted') return redirect(url_for('shoppinglist_items', _id=sh_id))