Commit 8d241fb3 authored by Ahmad Anvari's avatar Ahmad Anvari

Add route for order

parent 67fa4b13
from app import app
from middlewares.auth import login_required
from flask import request, jsonify
from db.product import Product
from db.order import Order
#
# @app.route('/orders', methods=["GET"])
# def search_products():
# tags = request.args.get('tags')
# if tags is None:
# tags = []
# else:
# tags = tags.split(',')
# count = request.args.get('count')
# if count is None:
# count = 5
# else:
# count = int(count)
# r = Product.search(count=count, tags=tags)
# return jsonify(r)
@app.route('/orders', methods=["POST"])
@login_required
def add_order():
body = request.json
product_id = body["product_id"]
user_id = request.user.get_id()
o = Order(user_id=user_id, product_id=product_id)
id = o.store()
return jsonify({"id": id})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment