update: area calculation and value price

parent 6cf873f1
from extensions import mongo, db
from Main import app
from flask import Response, request
from flask import Response, request, session
# import pymongo
import json
from bson.objectid import ObjectId
......@@ -13,16 +13,51 @@ from Agripreneur_App.Auth.Token import check_for_token
@app.route("/points/<id>", methods=["POST"])
# @check_for_token
@check_for_token
def add_points_earns(id):
# print(request.headers)
# print(request.form)
request.headers
area = request.form['name']
print(area)
gArea = int(area)
title = request.form['title']
print(title)
id = session['Auth']['_id']
print(id)
try:
# points 1-10
# points = 4000
# calculation of earned with area given by user with the selected crop which is given from FE
if title == "carrot":
number_plants_can_be_grown_each_meter = 100
number_of_plants_can_be_grown_in_givenArea = 100 * gArea
number_of_plants_contain_in_1kg = 400000
number_of_kg_of_plant_can_be_grown_in_givenArea = number_of_plants_can_be_grown_in_givenArea/number_of_plants_contain_in_1kg
kg1_price_of_plants =150
earns = kg1_price_of_plants * number_of_kg_of_plant_can_be_grown_in_givenArea
if title == "tomato":
number_plants_can_be_grown_each_meter = 100
number_of_plants_can_be_grown_in_givenArea = 100 * gArea
number_of_plants_contain_in_1kg = 400000
number_of_kg_of_plant_can_be_grown_in_givenArea = number_of_plants_can_be_grown_in_givenArea/number_of_plants_contain_in_1kg
kg1_price_of_plants =150
earns = kg1_price_of_plants * number_of_kg_of_plant_can_be_grown_in_givenArea
if title == "chilli":
number_plants_can_be_grown_each_meter = 100
number_of_plants_can_be_grown_in_givenArea = 100 * gArea
number_of_plants_contain_in_1kg = 400000
number_of_kg_of_plant_can_be_grown_in_givenArea = number_of_plants_can_be_grown_in_givenArea/number_of_plants_contain_in_1kg
kg1_price_of_plants =150
earns = kg1_price_of_plants * number_of_kg_of_plant_can_be_grown_in_givenArea
# area_earn = request.form.get("earns")
earns = 50000
# earns = 50000
points=0
# points calculation algorithm
if earns >= 5000:
points = 10
......
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