Updated packages. Added new session type
This commit is contained in:
@@ -61,6 +61,7 @@ app.config['SECRET_KEY'] = ApplicationConfig.SECRET_KEY
|
||||
session.configure(bind=ApplicationConfig.SQLALCHEMY_DATABASE_URI)
|
||||
db = SQLAlchemy(app)
|
||||
bcrypt = Bcrypt(app)
|
||||
app.config['SESSION_SQLALCHEMY'] = db
|
||||
server_session = Session(app)
|
||||
ma = Marshmallow(app)
|
||||
mail = Mail(app)
|
||||
|
||||
@@ -19,8 +19,15 @@ import string
|
||||
import random
|
||||
|
||||
|
||||
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
|
||||
return ''.join(random.choice(chars) for _ in range(size))
|
||||
def generate_random_number_string(length):
|
||||
# Ensure the length is at least 1
|
||||
if length < 1:
|
||||
raise ValueError("Length must be at least 1")
|
||||
|
||||
# Generate a random number with the specified length
|
||||
random_number = ''.join(random.choices(string.digits, k=length))
|
||||
|
||||
return random_number
|
||||
|
||||
|
||||
|
||||
@@ -143,24 +150,31 @@ def create_customer():
|
||||
.query(Admin_Company)
|
||||
.filter(Admin_Company.id == 1)
|
||||
.first())
|
||||
last_customer = (db.session
|
||||
.query(Customer_Customer)
|
||||
.order_by(Customer_Customer.id.desc())
|
||||
.first())
|
||||
|
||||
get_company = (db.session
|
||||
.query(Admin_Company)
|
||||
.filter(Admin_Company.id == 1)
|
||||
.first())
|
||||
|
||||
|
||||
random_string = generate_random_number_string(6)
|
||||
|
||||
made_account_number = str(get_company.account_prefix) + '-' + str(random_string)
|
||||
see_if_exists = (db.session.query(Customer_Customer).filter(Customer_Customer.account_number == made_account_number).first())
|
||||
|
||||
new_customer_id = last_customer.id + 1
|
||||
if len(str(new_customer_id)) == 2:
|
||||
new_customer_id = '000' + str(new_customer_id)
|
||||
if len(str(new_customer_id)) == 3:
|
||||
new_customer_id = '00' + str(new_customer_id)
|
||||
if len(str(new_customer_id)) == 4:
|
||||
new_customer_id = '0' + str(new_customer_id)
|
||||
if see_if_exists is not None:
|
||||
|
||||
starter_digits = str(get_company.account_prefix) + '-' + str(new_customer_id)
|
||||
random_string = generate_random_number_string(10)
|
||||
|
||||
made_account_number = str(get_company.account_prefix) + '-' + str(random_string)
|
||||
see_if_exists = (db.session.query(Customer_Customer).filter(Customer_Customer.account_number == made_account_number).first())
|
||||
|
||||
made_account_number = starter_digits
|
||||
if see_if_exists is not None:
|
||||
|
||||
random_string = generate_random_number_string(10)
|
||||
|
||||
made_account_number = str(get_company.account_prefix) + '-' + str(random_string)
|
||||
see_if_exists = (db.session.query(Customer_Customer).filter(Customer_Customer.account_number == made_account_number).first())
|
||||
|
||||
response_customer_last_name = request.json["customer_last_name"]
|
||||
response_customer_first_name = request.json["customer_first_name"]
|
||||
|
||||
@@ -136,6 +136,8 @@ def get_customer_past_delivery1(customer_id):
|
||||
get_customer_past_delivery = (db.session
|
||||
.query(Delivery_Delivery)
|
||||
.filter(Delivery_Delivery.customer_id == customer_id)
|
||||
.filter(Delivery_Delivery.delivery_status == 10)
|
||||
.order_by(Delivery_Delivery.id.desc())
|
||||
.limit(5))
|
||||
|
||||
delivery_schema = Delivery_Delivery_schema(many=True)
|
||||
@@ -148,6 +150,8 @@ def get_customer_past_delivery2(customer_id):
|
||||
get_customer_past_delivery = (db.session
|
||||
.query(Delivery_Delivery)
|
||||
.filter(Delivery_Delivery.customer_id == customer_id)
|
||||
|
||||
.order_by(Delivery_Delivery.id.desc())
|
||||
.offset(5)
|
||||
.limit(5))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user