def new_price_tier(product_id): form = PriceTierForm() product = Product.query.get_or_404(product_id) if form.validate_on_submit(): pt = PriceTier(form.name.data) pt.prices = [Price('GBP', form.price_gbp.data), Price('EUR', form.price_eur.data)] # Only activate this price tier if it's the first one added. pt.active = (len(product.price_tiers) == 0) product.price_tiers.append(pt) db.session.commit() return redirect(url_for('.price_tier_details', tier_id=pt.id)) return render_template('admin/products/price-tier-new.html', product=product, form=form)
def new_price_tier(product_id): form = NewPriceTierForm() product = Product.query.get_or_404(product_id) if form.validate_on_submit(): pt = PriceTier(form.name.data, personal_limit=form.personal_limit.data) pt.prices = [ Price("GBP", form.price_gbp.data), Price("EUR", form.price_eur.data), ] # Only activate this price tier if it's the first one added. pt.active = len(product.price_tiers) == 0 product.price_tiers.append(pt) db.session.commit() return redirect(url_for(".price_tier_details", tier_id=pt.id)) return render_template("admin/products/price-tier-new.html", product=product, form=form)