Example #1
0
 def get(self):
     args = Product.get_parser.parse_args()
     rows = db.query(db.P).select()
     col, _ord = args.pop('col'), args.pop('ord')
     cols, vals = utils.marshal(args)
     rows.eql(*vals).where(*cols)
     rows.order_by(col, _ord)
     return utils.jsonify(rows.eval())
Example #2
0
 def post(self):
     print(request.json)
     print(request.form)
     args = Product.post_parser.parse_args()
     print(args)
     rows = db.query(db.P)
     cols, vals = utils.marshal(args)
     rows.write(*vals).into(*cols)
     return utils.jsonify(rows.eval())
Example #3
0
 def get(self):
     args = Supplier.get_parser.parse_args()
     rows = db.query(db.S).select()
     cols, vals = utils.marshal(args)
     rows.eql(*vals).where(*cols)
     suppliers = utils.jsonify(rows.eval())
     for ind, sup in enumerate(suppliers):
         if sup['s_id'] == -1:
             del suppliers[ind]
             break
     return suppliers
 def get(self):
     args = ProductSupplierMap.get_parser.parse_args()
     rows = db.query(db.PSM).select().join(db.S).on("s_id").join(
         db.P).on("p_id")
     cols, vals = utils.marshal(args)
     rows.eql(*vals).where(*cols)
     suppliers = utils.jsonify(rows.eval())
     #remove empty, preferrably id
     # for ind,sup in enumerate(suppliers):
     #     for key, val in sup.items():
     #         if val == -1:
     #             del suppliers[ind]
     return suppliers
 def post(self):
     args = ProductSupplierMap.post_parser.parse_args()
     rows = db.query(db.PSM)
     cols, vals = utils.marshal(args)
     rows.write(*vals).into(*cols)
     return utils.jsonify(rows.eval())