示例#1
0
def getItems(client_id, cart_id):
	auxJSON = []
	try:
		client_key = ndb.Key(Clients, client_id)
		cart_key = ndb.Key(Carts, cart_id) #Entiendo que el cart_id es unico.
	except:
		abort(404)
	ItemList = Items.query(ancestor=cart_key)
	auxJSON = Items.toJSONlist(ItemList)
	client = client_key.get()
	return make_response(jsonify({'email_client':client.email,'items':auxJSON}), 200)
def addItem(client_id, cart_id):
    if not request.json or not 'name' in request.json:
        abort(400)
    name = request.json['name']
    try:
        cart_key = ndb.Key(Carts, cart_id)
    except:
        abort(404)
    new_item = Items(parent=cart_key, name=name)
    item_id = new_item.put()
    return make_response(jsonify({'added': item_id.urlsafe()}), 201)
示例#3
0
def addItem(client_id, cart_id):
    if not request.json or not "name" in request.json:
        abort(400)
    name = request.json["name"]
    try:
        cart_key = ndb.Key(Carts, cart_id)
    except:
        abort(404)
    new_item = Items(parent=cart_key, name=name)
    item_id = new_item.put()
    return make_response(jsonify({"added": item_id.urlsafe()}), 201)
def getCartItems():
    if not request.args.get('ClientID') and request.args.get('CartID'):
        abort(400)
    client_id = request.args.get('ClientID')
    cart_id = request.args.get('CartID')
    client_key = ndb.Key(urlsafe=client_id)
    cart_key = ndb.Key(urlsafe=cart_id)
    ItemList = Items.query(ancestor=cart_key)
    auxJSON = Items.toJSONlist(ItemList)
    client = client_key.get()
    cart = cart_key.get()
    return make_response(jsonify({"items": auxJSON}))
示例#5
0
def getCartItems():
        if not request.args.get('ClientID') and request.args.get('CartID'):
                abort(400)
        client_id = request.args.get('ClientID')
        cart_id = request.args.get('CartID')
        client_key = ndb.Key(urlsafe=client_id)
        cart_key = ndb.Key(urlsafe=cart_id)
        ItemList = Items.query(ancestor=cart_key)
        auxJSON = Items.toJSONlist(ItemList)
        client = client_key.get()
        cart = cart_key.get()
        return make_response(jsonify({"items":auxJSON}))
def getItems(client_id, cart_id):
    auxJSON = []
    try:
        client_key = ndb.Key(Clients, client_id)
        cart_key = ndb.Key(Carts, cart_id)  #Entiendo que el cart_id es unico.
    except:
        abort(404)
    ItemList = Items.query(ancestor=cart_key)
    auxJSON = Items.toJSONlist(ItemList)
    client = client_key.get()
    return make_response(
        jsonify({
            'email_client': client.email,
            'items': auxJSON
        }), 200)
示例#7
0
def addItem(client_id, cart_id):
	if not request.json or not 'name' in request.json:
		abort(400)
	name = request.json['name']
	try:
		cart_key = ndb.Key(urlsafe= cart_id)
	except:
		abort(404)
	new_item = Items(
		parent = cart_key,
		name = name
	)
	cart = cart_key.get()
	item_id = new_item.put()
	cart.items.append(item_id)
	cart.put()
	return make_response(jsonify({'added':item_id.urlsafe()}), 201)