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()
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)
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
def get_orders(): all_orders = Order.objects(user_id=request.current_user['id']) return jsonify([orders.response() for orders in all_orders])