46 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
| from flask import jsonify
 | |
| from app.info import info
 | |
| from app import db
 | |
| from app.classes.pricing import Pricing_Oil_Oil, Pricing_Oil_Oil_schema
 | |
| from app.classes.admin import Admin_Company
 | |
| 
 | |
| 
 | |
| @info.route("/price/oil", methods=["GET"])
 | |
| def get_oil_price_today():
 | |
|     get_price_query = (db.session
 | |
|                      .query(Pricing_Oil_Oil)
 | |
|                      .order_by(Pricing_Oil_Oil.date.desc())
 | |
|                      .first())
 | |
|     return jsonify({"ok": True,
 | |
|                     'price_from_supplier': get_price_query.price_from_supplier,
 | |
|                     'price_for_customer': get_price_query.price_for_customer,
 | |
|                     'price_for_employee': get_price_query.price_for_employee,
 | |
|                     'price_same_day': get_price_query.price_same_day,
 | |
|                     'price_prime': get_price_query.price_prime,
 | |
|                     }), 200
 | |
| 
 | |
| 
 | |
| @info.route("/price/oil/table", methods=["GET"])
 | |
| def get_pricing():
 | |
|     get_price_query = (db.session
 | |
|                      .query(Pricing_Oil_Oil)
 | |
|                      .order_by(Pricing_Oil_Oil.date.desc())
 | |
|                      .first())
 | |
|     delivery_schema = Pricing_Oil_Oil_schema(many=False)
 | |
|     return jsonify(delivery_schema.dump(get_price_query))
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| @info.route("/company", methods=["GET"])
 | |
| def get_company():
 | |
|     get_data_company = (db.session
 | |
|                         .query(Admin_Company)
 | |
|                         .first())
 | |
| 
 | |
|     return jsonify({"ok": True,
 | |
|                     'name': get_data_company.company_name,
 | |
|                     'telephone': get_data_company.company_phone_number,
 | |
|                     }), 200
 |