From 7bcf5ef491e8fa6862f0b12c481eb4f2d581d720 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Fri, 10 Jan 2025 10:53:18 -0500 Subject: [PATCH] Insert missing --- services/web/project/__init__.py | 36 +++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/services/web/project/__init__.py b/services/web/project/__init__.py index 9433f78..809bc16 100644 --- a/services/web/project/__init__.py +++ b/services/web/project/__init__.py @@ -141,6 +141,9 @@ def hello_world(): @app.route("/test/products") def test_product(): + myproudct = myproduct_detail(1 , 'A000001') + print(myproudct) + products_data = { "last_update": datetime.datetime.utcnow(), "products": [ @@ -162,8 +165,8 @@ def test_product(): productJS = json.dumps( [dict(ix) for ix in products_list] ) print(productJS) array3 = json.loads(productJS) - return jsonify(products_data=products_data, products_list=array3) - + #return jsonify(products_data=products_data, products_list=array3) + return jsonify(myproudct=myproudct) # GLOBAL_AVG = """SELECT * FROM members WHERE id > 0;""" # # result = pd.read_sql(GLOBAL_AVG, engine) @@ -726,7 +729,6 @@ def myproduct(current_user): "subscription_text" : "Start with your goals in mind and then work possible.ith yand Goals. If the plan doesn’t support the vision then change it!", "promotion_text": "Start Free Today !", "price_text" : "90 days free and 3.95/Month", - } return jsonify(myproduct_data=myproduct_data) @@ -757,7 +759,7 @@ def subscription_start(current_user): return jsonify({'status': "INVALID",'message': 'Error - Invalid product'}), 403 member_id = current_user['user']['member_id'] - INSERT_NEW_PRODUCT ="INSERT INTO members_products (member_id ,product_id,status) VALUES (%s, %s)" + INSERT_NEW_PRODUCT ="INSERT INTO members_products (member_id ,product_id,status) VALUES (%s, %s, %s)" val_insert = (member_id, product_id,6) with connection: with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor: @@ -767,4 +769,28 @@ def subscription_start(current_user): myproduct_data = [] - return jsonify(myproduct_data=myproduct_data) \ No newline at end of file + return jsonify(myproduct_data=myproduct_data) + +def myproduct_detail(member_id ,product_id): + FIND_PRODUCT= "SELECT uid,product_id,name,description,banner,status FROM products WHERE product_id='"+product_id+"'" + with connection: + with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor: + cursor.execute(FIND_PRODUCT) + product = cursor.fetchall() +# print(product[0]["uid"]) + + product_found = count = len( product ) + myproduct_data = { + "myproduct_uid":"", + "status": product[0]["status"], + "product_id": product[0]["product_id"], + "product_uid": product[0]["uid"], + "banner": product[0]["banner"], + "product_name": product[0]["name"], + "description": "Product Description - Commitment is something that comes from understanding that everything has its price and then having the willingness to pay that price. This is important because nobody wants to put significant effort into something, only to find out after the fact that the price was too high.The price is something not necessarily defined as financial. It could be time, effort, sacrifice, money or perhaps, something else.", + "title": product[0]["description"], + "subscription_text" : "Start with your goals in mind and then work possible.ith yand Goals. If the plan doesn’t support the vision then change it!", + "promotion_text": "Start Free Today !", + "price_text" : "90 days free and 3.95/Month", + } + return myproduct_data;