(id)
| 43 | |
| 44 | @app.route('/<int:id>/edit/', methods=('GET', 'POST')) |
| 45 | def edit(id): |
| 46 | products = get_products(id) |
| 47 | |
| 48 | if request.method == 'POST': |
| 49 | title = request.form['title'] |
| 50 | price = request.form['price'] |
| 51 | |
| 52 | if not title: |
| 53 | flash('Title is required!') |
| 54 | |
| 55 | elif not price: |
| 56 | flash('Content is required!') |
| 57 | |
| 58 | else: |
| 59 | conn = get_db_connection() |
| 60 | conn.execute('UPDATE products SET title = ?, price = ?' |
| 61 | ' WHERE id = ?', |
| 62 | (title, price, id)) |
| 63 | conn.commit() |
| 64 | conn.close() |
| 65 | return redirect(url_for('index')) |
| 66 | |
| 67 | return render_template('edit.html', products=products) |
| 68 | |
| 69 | |
| 70 | @app.route('/<int:id>/delete/', methods=('POST',)) |
nothing calls this directly
no test coverage detected