83 lines
2.1 KiB
Python
Executable File
83 lines
2.1 KiB
Python
Executable File
from flask import jsonify
|
|
from app.query import query
|
|
from app import db
|
|
from app.classes.admin import Admin_Company
|
|
from app.classes.query import (Query_StateList,
|
|
Query_DeliveryStatusList,
|
|
Query_DeliveryStatusList_Schema,
|
|
Query_StateList_Schema,
|
|
Query_CustomerTypeList,
|
|
Query_CustomerTypeList_Schema,
|
|
Query_EmployeeTypeList,
|
|
Query_EmployeeTypeList_Schema)
|
|
|
|
@query.route("/company/<int:company_id>", methods=["GET"])
|
|
def get_company(company_id):
|
|
"""
|
|
This will get the company from env variable
|
|
"""
|
|
|
|
query_data = (db.session
|
|
.query(Admin_Company)
|
|
.filter(Admin_Company.id == company_id)
|
|
.first())
|
|
delivery_schema = Query_DeliveryStatusList_Schema(many=False)
|
|
return jsonify(delivery_schema.dump(query_data))
|
|
|
|
@query.route("/states", methods=["GET"])
|
|
def get_state_list():
|
|
"""
|
|
This will get states
|
|
"""
|
|
|
|
query_data = db.session \
|
|
.query(Query_StateList) \
|
|
.all()
|
|
|
|
customer_schema = Query_StateList_Schema(many=True)
|
|
return jsonify(customer_schema.dump(query_data))
|
|
|
|
|
|
@query.route("/customertype", methods=["GET"])
|
|
def get_customer_type_list():
|
|
"""
|
|
This will get types of customers
|
|
"""
|
|
|
|
query_data = db.session \
|
|
.query(Query_CustomerTypeList) \
|
|
.all()
|
|
customer_schema = Query_CustomerTypeList_Schema(many=True)
|
|
return jsonify(customer_schema.dump(query_data))
|
|
|
|
|
|
|
|
|
|
@query.route("/employeetype", methods=["GET"])
|
|
def get_employee_type_list():
|
|
"""
|
|
This will get types of service
|
|
"""
|
|
|
|
query_data = db.session \
|
|
.query(Query_EmployeeTypeList) \
|
|
.all()
|
|
customer_schema = Query_EmployeeTypeList_Schema(many=True)
|
|
return jsonify(customer_schema.dump(query_data))
|
|
|
|
|
|
@query.route("/deliverystatus", methods=["GET"])
|
|
def get_delivery_status_list():
|
|
"""
|
|
This will get delivery status
|
|
"""
|
|
|
|
query_data = db.session \
|
|
.query(Query_DeliveryStatusList) \
|
|
.all()
|
|
delivery_schema = Query_DeliveryStatusList_Schema(many=True)
|
|
return jsonify(delivery_schema.dump(query_data))
|
|
|
|
|
|
|