added description
This commit is contained in:
@@ -6,7 +6,9 @@ from datetime import datetime
|
||||
from app.classes.cards import Card_Card
|
||||
from app.classes.customer import \
|
||||
Customer_Customer, \
|
||||
Customer_Customer_schema
|
||||
Customer_Customer_schema,\
|
||||
Customer_Description, \
|
||||
Customer_Description_schema
|
||||
from app.classes.admin import Admin_Company
|
||||
from app.classes.auto import Auto_Delivery
|
||||
import string
|
||||
@@ -84,6 +86,7 @@ def create_customer():
|
||||
customer_phone_number = request.json["customer_phone_number"]
|
||||
customer_address = request.json["customer_address"]
|
||||
customer_apt = request.json["customer_apt"]
|
||||
customer_description_msg = request.json["customer_description"]
|
||||
|
||||
if response_customer_automatic is True:
|
||||
auto_customer = 1
|
||||
@@ -109,12 +112,20 @@ def create_customer():
|
||||
customer_address=customer_address,
|
||||
customer_apt=customer_apt,
|
||||
company_id=1,
|
||||
|
||||
)
|
||||
|
||||
db.session.add(new_customer)
|
||||
db.session.flush()
|
||||
|
||||
new_description = Customer_Description(
|
||||
customer_id = new_customer.id,
|
||||
account_number = made_account_number,
|
||||
description = customer_description_msg,
|
||||
fill_location=None,
|
||||
company_id=1,
|
||||
)
|
||||
db.session.add(new_description)
|
||||
|
||||
|
||||
new_auto = Auto_Delivery(
|
||||
customer_id = new_customer.id,
|
||||
account_number = made_account_number,
|
||||
@@ -154,8 +165,10 @@ def edit_customer(customer_id):
|
||||
.query(Customer_Customer)
|
||||
.filter(Customer_Customer.id == customer_id)
|
||||
.first())
|
||||
|
||||
|
||||
get_customer_description = (db.session
|
||||
.query(Customer_Description)
|
||||
.filter(Customer_Description.customer_id == customer_id)
|
||||
.first())
|
||||
response_customer_last_name = request.json["customer_last_name"]
|
||||
response_customer_first_name = request.json["customer_first_name"]
|
||||
response_customer_town = request.json["customer_town"]
|
||||
@@ -167,6 +180,12 @@ def edit_customer(customer_id):
|
||||
response_customer_address = request.json["customer_address"]
|
||||
response_customer_automatic = request.json["customer_automatic"]
|
||||
|
||||
response_customer_description = request.json["customer_description"]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if response_customer_automatic is True:
|
||||
get_auto = (db.session
|
||||
@@ -197,6 +216,10 @@ def edit_customer(customer_id):
|
||||
|
||||
else:
|
||||
auto = 0
|
||||
if get_customer_description is not None:
|
||||
get_customer_description.description = response_customer_description
|
||||
|
||||
db.session.add(get_customer_description)
|
||||
|
||||
|
||||
get_customer.customer_address = response_customer_address
|
||||
@@ -290,6 +313,41 @@ def customer_automatic_status(customer_id):
|
||||
}), 200
|
||||
|
||||
|
||||
@customer.route("/description/<int:customer_id>", methods=["GET"])
|
||||
@login_required
|
||||
def customer_description(customer_id):
|
||||
"""
|
||||
"""
|
||||
get_customer = (db.session
|
||||
.query(Customer_Customer)
|
||||
.filter(Customer_Customer.id == customer_id)
|
||||
.first())
|
||||
get_customer_description = (db.session
|
||||
.query(Customer_Description)
|
||||
.filter(Customer_Description.customer_id == customer_id)
|
||||
.first())
|
||||
|
||||
|
||||
if get_customer_description is None:
|
||||
new_description = Customer_Description(
|
||||
customer_id = get_customer.id,
|
||||
account_number = get_customer.account_number,
|
||||
description = None,
|
||||
fill_location=None,
|
||||
company_id=1,
|
||||
)
|
||||
db.session.add(new_description)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
get_customer_description = (db.session
|
||||
.query(Customer_Description)
|
||||
.filter(Customer_Description.customer_id == customer_id)
|
||||
.first())
|
||||
|
||||
customer_schema = Customer_Description_schema(many=False)
|
||||
return jsonify(customer_schema.dump(get_customer_description))
|
||||
|
||||
|
||||
@customer.route("/automatic/assign/<int:customer_id>", methods=["GET"])
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user