diff --git a/services/web/project/__init__.py b/services/web/project/__init__.py index 609fe24..1f4a47e 100644 --- a/services/web/project/__init__.py +++ b/services/web/project/__init__.py @@ -141,7 +141,7 @@ def hello_world(): @app.route("/test/products") def test_product(): - myproudct = myproduct_detail(1 , 'A000001') + myproudct = myproduct_detail(5 , 'A000001') print(myproudct) products_data = { @@ -710,26 +710,29 @@ def myproduct(current_user): }, 400 print(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"]) +# 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"]) - 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", - } + member_id = current_user['user']['member_id'] + myproduct_data = myproduct_detail(member_id , product_id) + +# 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 jsonify(myproduct_data=myproduct_data) @app.route("/panel/myproduct/subscription", methods=["POST"]) @@ -759,7 +762,7 @@ def subscription_start(current_user): return jsonify({'status': "INVALID",'message': 'Error - Invalid product'}), 403 member_id = current_user['user']['member_id'] - internal_url = str(random.randint(10000, 99999)) + product_id + ".mermsemr.com" + internal_url = str(random.randint(10000, 99999)) + "." + product_id + ".mermsemr.com" INSERT_NEW_PRODUCT ="INSERT INTO members_products (member_id ,product_id,status,internal_url) VALUES (%s, %s, %s, %s)" val_insert = (member_id, product_id,6,internal_url) with connection: @@ -779,11 +782,23 @@ def myproduct_detail(member_id ,product_id): cursor.execute(FIND_PRODUCT) product = cursor.fetchall() # print(product[0]["uid"]) + status = product[0]["status"]; + + MEMBER_PRODUCT = f"SELECT uid AS member_product_uid , status FROM members_products WHERE member_id= {member_id} AND product_id = '" + product_id + "'" + val_select = (member_id, product_id) + with connection: + with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor: + cursor.execute(MEMBER_PRODUCT) + myproduct = cursor.fetchall() product_found = count = len( product ) + mproduct_found = count = len( myproduct ) + if mproduct_found == 1 : + status = myproduct[0]['status'] + myproduct_data = { "myproduct_uid":"", - "status": product[0]["status"], + "status": status, "product_id": product[0]["product_id"], "product_uid": product[0]["uid"], "banner": product[0]["banner"],