Пример #1
0
def get_order(order_id=0):
    a = []
    if order_id != 0:
        for row in session.query(Orders).filter_by(id=order_id):
            a = [Orders.ToList(row)]
    elif order_id == 0:
        for row in session.query(Orders).all():
            a += [Orders.ToList(row)]
    session.commit()

    return jsonify(a), 201
Пример #2
0
def create_order():
    if not request.json:
        abort(400)
    order = Orders(request.json['name'], request.json['cellphone'],
                   request.json['address'], request.json['description'], request.json['status'])

    session.add(order)
    session.commit()
    return jsonify({}), 201
Пример #3
0
def get_orders(courier_id):
    a = []
    for row in session.query(Couriers).filter_by(id=courier_id):
        for i in row.list.split():
            for order in session.query(Orders).filter_by(id=i):
                a += [Orders.ToList(order)]
    session.commit()

    return jsonify(a), 201
Пример #4
0
def update_task(cser):
    if not request.json:
        abort(400)
    a = {}
    if cser == 'admin' or cser == 'courier':
        for row in session.query(Orders).filter_by(id=request.json['id']):
            row.status = request.json['status']
            a = Orders.ToList(row)
    session.commit()
    return jsonify(a), 201
Пример #5
0
def add_order_to_db(cookie_id,quantity):
    print("checking...")
    add_order_session = Session()
    order = Orders(cookie_id=cookie_id, order_quantity=quantity)
    add_order_session.add(order)

    add_order_session.commit()
    print("order added successfully")
    add_order_session.close()
    return order