示例#1
0
 def get_products(self):
     result = Schema().get_inventory()
     products = []
     for product in result:
         products.append({
             "id": product[0],
             "name": product[1],
             "src": "/static/%s" % (product[2]),
             "price": "$%.2f" % (product[3] / 100.0),
             "stock": "%d left" % (product[4]),
         })
     return products
示例#2
0
 def get_info(self, product_id):
     product = Schema().get_product_info(product_id)
     if product != 'Invalid product ID!' and product != "Insufficient stock!":
         info = [{
             "id": product[0],
             "name": product[1],
             "src": product[2][7:],
             "price": "$%.2f" % (product[3] / 100.0),
         }]
         return info
     else:
         return product
示例#3
0
    def __init__(self, schema=None, parent=None):
        super(ChartWindow, self).__init__(parent)
        lay = QtGui.QHBoxLayout()
        self.setWindowTitle("qt-flowgraph")
        self.setLayout(lay)
        self.setMinimumSize(500, 300)
        self.tb = ToolBar(self)
        self.view = QtGui.QGraphicsView(self)
        self.view.setRenderHint(QtGui.QPainter.Antialiasing)
        self.view.setRenderHint(QtGui.QPainter.HighQualityAntialiasing)
        self.schema = schema or Schema()
        self.sv = SchemaView(self.schema)
        self.view.setScene(self.sv)

        lay.addWidget(self.tb)
        lay.addWidget(self.view)

        self.tb.node_clicked.connect(self.schema.add_node)
示例#4
0
    return "Hello World!"


@app.route("/<name>")
def hello_name(name):
    return "Hello " + name


@app.route("/todo", methods=["GET"])
def list_todo():
    return jsonify(ToDoService().list())


@app.route("/todo", methods=["POST"])
def create_todo():
    return jsonify(ToDoService().create(request.get_json()))


@app.route("/todo/<item_id>", methods=["PUT"])
def update_item(item_id):
    return jsonify(ToDoService().update(item_id, request.get_json()))


@app.route("/todo/<item_id>", methods=["DELETE"])
def delete_item(item_id):
    return jsonify(ToDoService().delete(item_id))


if __name__ == "__main__":
    Schema()
    app.run(debug=True, port=8888)
示例#5
0
 def add_peice(self, name: str, img: str, price: int, stock: int):
     return Schema().add_to_inventory(name, img, price, stock)
示例#6
0
 def purchase(self, product_id):
     return Schema().do_purchase(product_id)
示例#7
0
 def initialize(self):
     Schema().initialize_db()
示例#8
0
 def get_profit(self):
     result = Schema().get_transactions()
     earnings = result / 100.0 if result else 0
     return earnings