Insert product
This commit is contained in:
@@ -734,6 +734,7 @@ def myproduct(current_user):
|
|||||||
@token_required
|
@token_required
|
||||||
def subscription_start(current_user):
|
def subscription_start(current_user):
|
||||||
print( current_user )
|
print( current_user )
|
||||||
|
#{'user': {'id': 5, 'member_id': 5, 'uid': '1f92e1ae-c084-4622-9e7c-dfeedf698c58'}, 'exp': 1736713281}
|
||||||
data = request.json
|
data = request.json
|
||||||
product_id = data.get('product_id')
|
product_id = data.get('product_id')
|
||||||
if not product_id:
|
if not product_id:
|
||||||
@@ -755,8 +756,12 @@ def subscription_start(current_user):
|
|||||||
if product_found == 0 :
|
if product_found == 0 :
|
||||||
return jsonify({'status': "INVALID",'message': 'Error - Invalid product'}), 403
|
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) VALUES (%s, %s)"
|
||||||
|
val_insert = (member_id, product_id)
|
||||||
|
with connection:
|
||||||
|
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||||
|
cursor.execute(INSERT_NEW_PRODUCT,val_insert)
|
||||||
|
|
||||||
print(product_id)
|
print(product_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user