Пример #1
0
def show_product_post(catname, prodid):
	message = ""
	status = ""
	if 'send' in request.form:
		if add_to_basket(prodid, current_user.uid):
			status = "success"
			message = "Product Added To Basket!"
	elif 'post_comment' in request.form:
		try:
			post_comment(current_user.uid, prodid, request.form['comment_text'])
			message = "You Commented!"
			status = "success"
		except IntegrityError:
			message = "You have already commented."
			status = "error"
	elif 'vote_up' in request.form:
		vote(current_user.uid, prodid, 1)	
		message = 'You voted up!'
		status = "success"
	elif 'vote_down' in request.form:
		vote(current_user.uid, prodid, -1)	
		message = 'You voted down.'
		status = "success"
	else:
		abort(500)

	product_info = read_product_info(prodid)
	cats = read_categories()
	current_user.numbasket = prods_in_basket(current_user.get_id())
	return render_template("catalogue.html", rating = read_score(prodid), comments=read_comments(prodid),
						   catname=catname, prodid=prodid, c = cats, prod = product_info, status=status,
						   message=message)
Пример #2
0
def add_from_catalogue(catname):
	prodid = request.form['add_basket_id']
	if add_to_basket(prodid, current_user.uid):
		status = "success"
		message = "Product Added To Basket!"
	products = read_products(catname)
	cats = read_categories()
	current_user.numbasket = prods_in_basket(current_user.get_id())
	return render_template("catalogue.html", catname=catname, c = cats, p = products, status=status, message=message)