예제 #1
0
def get_cart_for_user():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")

    return auth_user(db, username, accessToken) \
        .then(carts.get_cart_for_user) \
        .as_dict()
예제 #2
0
def set_item_data():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")
    return auth_user(db, username, accessToken, 1) \
        .then(read_item_data) \
        .then(save_item_data) \
        .as_dict()
예제 #3
0
def delete_item():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")
    item_id = request.args.get('itemId', 0, type=int)
    return auth_user(db, username, accessToken, 1) \
        .then(lambda u: products.remove_product(item_id)) \
        .as_dict()
예제 #4
0
def create_item():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")
    return auth_user(db, username, accessToken, 1) \
        .then(read_item_data) \
        .then(create_item_object) \
        .then(lambda p: None) \
        .as_dict()
예제 #5
0
def load_image():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")
    product_id = request.args.get('productId', -1, type=int)

    return auth_user(db, username, accessToken, 1) \
        .then(lambda u: images.load_image(product_id, request.data)) \
        .as_dict()
예제 #6
0
def order_cart():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")
    return auth_user(db, username, accessToken) \
        .then(carts.order) \
        .peek(lambda a: mailer.notify_ordered(a[0])) \
        .then(lambda a: a[1]) \
        .as_dict()
예제 #7
0
def remove_item_from_cart():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")
    batchId = request.args.get('batchId', 0, type=int)

    return auth_user(db, username, accessToken, 0) \
        .then(lambda u: carts.remove_item_from_cart(batchId, u)) \
        .as_dict()
예제 #8
0
def get_order_for_user():
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")

    return auth_user(db, username, accessToken) \
        .then(lambda u: {"items": carts.get_orders(u),
                         "type": "normal" if u.permission_level == 0 else "super"}) \
        .as_dict()
예제 #9
0
def add_item_to_cart():
    item_id = request.args.get("itemId", -1, type=int)
    accessToken = request.headers.get('accessToken', "")
    username = request.headers.get('username', "")
    amount = request.args.get('amount', 0, type=int)

    return auth_user(db, username, accessToken) \
        .then(lambda u: carts.add_item_to_cart(item_id, u, amount)) \
        .as_dict()