Beispiel #1
0
def wineByName():	
	if not request.args.get('name'):
		abort(400)
	name = request.args.get('name')
	auxJSON = []
	winesByName = Wines.query(Wines.name == name)
	auxJSON = Wines.toJSONlist(winesByName)
	return make_response(jsonify({'winesbyname':auxJSON}), 200)	
Beispiel #2
0
def wineByType():
	if not request.args.get('type'):
		abort(400)
	wine_type = request.args.get('type')
	auxJSON = []
	winesByType = Wines.query(Wines.wine_type == wine_type)
	auxJSON = Wines.toJSONlist(winesByType)
	return make_response(jsonify({'winesbytype':auxJSON}), 200)
Beispiel #3
0
def wineBetweenPrices():
	if not request.args.get('min') or not request.args.get('max'):
		abort(400)
	minimum = float(request.args.get('min'))
	maximum = float(request.args.get('max'))
	auxJSON = [] 
	winesBetweenPrices = Wines.query(Wines.price >= minimum, Wines.price <= maximum)
	auxJSON = Wines.toJSONlist(winesBetweenPrices)
	return make_response(jsonify({'winesbetweenprices':auxJSON}))
Beispiel #4
0
def addWine():
	if not request.json or not 'name' in request.json or not 'type' in request.json:
		abort(400)
	name = request.json['name']
	wine_type = request.json['type']
	new_wine = Wines(
		name = name,
		wine_type = wine_type,
		grade = request.json.get('grade', ),	
		size = request.json.get('size', ),	
		varietals = request.json.get('varietals', ),	
		do = request.json.get('do', ),	
		price = request.json.get('price', ),
		photo = request.json.get('photo', ))
	if wine_type == 'Tinto':
		new_wine.cask = request.json.get('cask', )
		new_wine.bottle = request.json.get('bottle', )	
	wine_id = new_wine.put()
	return make_response(jsonify({'created':wine_id.urlsafe()}), 201)
Beispiel #5
0
def addWine():
    if not request.json or not "name" in request.json or not "type" in request.json:
        abort(400)
    name = request.json["name"]
    wine_type = request.json["type"]
    new_wine = Wines(
        name=name,
        wine_type=wine_type,
        grade=request.json.get("grade"),
        size=request.json.get("size"),
        varietals=request.json.get("varietals"),
        do=request.json.get("do"),
        price=request.json.get("price"),
        photo=request.json.get("photo"),
    )
    if wine_type == "Tinto":
        new_wine.cask = request.json.get("cask")
        new_wine.bottle = request.json.get("bottle")
    wine_id = new_wine.put()
    return make_response(jsonify({"created": wine_id.urlsafe()}), 201)
def deleteWines():
    for wines in Wines.query():
        wines.key.delete()
    return make_response('deleted')
Beispiel #7
0
def allWines():
	return make_response(jsonify({'wines':Wines.getWinesName()}))
Beispiel #8
0
def deleteWines():
	for wines in Wines.query():
		wines.key.delete()
	return make_response('deleted')
def allWines():
    return make_response(jsonify({'wines': Wines.getWinesName()}))