Update: discount calculation

parent e84a2e96
......@@ -6,37 +6,40 @@ import json
from bson.objectid import ObjectId
@app.route("/discount/<id>", methods=["POST"])
@app.route("/discount/<id>", methods=["GET"])
# @check_for_token
def calculate_discount(id):
user_earns = db.CropData.find_one({"_id": ObjectId(id)})
print(user_earns)
user_points = user_earns['points']
print(user_points)
# if points >= 1:
# discount = 1
# elif points > 2:
# discount = 2
# elif points > 3:
# discount = 3
# elif points > 4:
# discount = 4
# elif points > 5:
# discount = 5
# elif points > 6:
# discount = 6
# elif points > 7:
# discount = 7
# elif points > 8:
# discount = 8
# elif points > 9:
# discount = 9
# elif points > 10:
# discount = 10
if user_points == 1:
discount = 1
elif user_points == 2:
discount = 2
elif user_points == 3:
discount = 3
elif user_points == 4:
discount = 4
elif user_points == 5:
discount = 5
elif user_points == 6:
discount = 6
elif user_points == 7:
discount = 7
elif user_points == 8:
discount = 8
elif user_points == 9:
discount = 9
elif user_points == 10:
discount = 10
return Response(
response= json.dumps({"Discount price": discount}),
response= json.dumps({"Discount percentage": discount}),
status=200,
)
\ No newline at end of file
......@@ -10,6 +10,7 @@ import Agripreneur_App.Routes.User
import Agripreneur_App.Auth.Token
import Agripreneur_App.Routes.Leaderboard
import Agripreneur_App.Routes.Gamification
import Agripreneur_App.Routes.PricePage
......
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