def new_ad(): if request.method == 'GET': return render_template('new_ad.html', ads=Ad.all()) elif request.method == 'POST': ad = Ad.find(request.form['ad_id']) values = (None, request.form['title'], request.form['description'], request.form['price'], request.form['date'], request.form['is_active'], request.form['buyer'], ad) Ad(*values).create() return redirect('/')
def buy_ad(id): ad = Ad.find(id) ad.buy() return redirect('/')
def delete_ad(id): ad = Ad.find(id) ad.delete() return redirect('/')
def show_ad(id): ad = Ad.find(id) return render_template('ad.html', ad=ad)