示例#1
0
def get_order(id_):
    existing_order = Order.objects(user_id=request.current_user['id'],
                                   id=id_).first()

    if not existing_order:
        raise NotFoundError('Order not found')

    return existing_order.response()
示例#2
0
def expiration_complete_callback(ch, method, props, body):
    body = json.loads(body)
    print("inside order expiration complete callback", flush=True)
    print(body, flush=True)
    existing_order = Order.objects(id=body['data']['order_id']).first()

    if not existing_order:
        raise Exception('Order not found')

    existing_order.modify(status=EventType.Order.CANCELLED)
    existing_order.save()

    publish_event(publish_channel,
                  OrderCancelledEvent(data=existing_order.response()))

    ch.basic_ack(delivery_tag=method.delivery_tag)
示例#3
0
def delete_order(id_):
    existing_order = Order.objects(id=id_).first()

    if not existing_order:
        raise NotFoundError('Order not found')

    existing_order.status = EventType.Order.CANCELLED
    existing_order.save()

    publish_event(
        publish_channel,
        OrderCancelledEvent(
            data={
                "id": str(existing_order.id),
                "ticket": {
                    "id": str(existing_order.ticket.id),
                },
                "version": existing_order.version
            }))

    return {}, 204
示例#4
0
def get_orders():
    all_orders = Order.objects(user_id=request.current_user['id'])
    return jsonify([orders.response() for orders in all_orders])