make value_in_json=True
This commit is contained in:
parent
1a76d2b5f3
commit
200a7672f2
4 changed files with 23 additions and 24 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import json
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
|
|
@ -19,10 +18,10 @@ from helper import get_plan_id_from_product, calculate_charges
|
|||
class ListProducts(Resource):
|
||||
@staticmethod
|
||||
def get():
|
||||
products = client.get_prefix('/v1/products/', value_in_json=False)
|
||||
products = client.get_prefix('/v1/products/')
|
||||
products = [
|
||||
product
|
||||
for product in [json.loads(p.value) for p in products]
|
||||
for product in [p.value for p in products]
|
||||
if product['active']
|
||||
]
|
||||
prod_dict = {}
|
||||
|
|
@ -63,7 +62,7 @@ class AddProduct(Resource):
|
|||
product_value['uuid'] = product_uuid
|
||||
|
||||
logger.debug('Adding product data: {}'.format(str(product_value)))
|
||||
client.put(product_key, product_value, value_in_json=True)
|
||||
client.put(product_key, product_value)
|
||||
if not previous_product:
|
||||
return make_return_message('Product created.')
|
||||
else:
|
||||
|
|
@ -201,7 +200,7 @@ class ProductOrder(Resource):
|
|||
)
|
||||
)
|
||||
|
||||
with client.client.lock('product-order') as lock:
|
||||
with client.client.lock('product-order') as _:
|
||||
# Initiate a one-time/subscription based on product type
|
||||
if recurring_charge > 0:
|
||||
logger.debug('Product {} is recurring payment'.format(product['name']))
|
||||
|
|
@ -234,11 +233,10 @@ class ProductOrder(Resource):
|
|||
client.put(
|
||||
'/v1/user/{}/orders/{}'.format(
|
||||
cleaned_values['username'], order_obj['order-id']
|
||||
),
|
||||
order_obj, value_in_json=True
|
||||
), order_obj
|
||||
)
|
||||
product['quantity'] -= 1
|
||||
client.put('/v1/products/{}'.format(product['uuid']), product, value_in_json=True)
|
||||
client.put('/v1/products/{}'.format(product['uuid']), product)
|
||||
|
||||
return {
|
||||
'message': 'Order Successful.',
|
||||
|
|
@ -246,6 +244,7 @@ class ProductOrder(Resource):
|
|||
}
|
||||
else:
|
||||
logger.error('Could not create plan {}'.format(plan_id))
|
||||
return make_return_message('Something wrong happened. Contact administrator', 400)
|
||||
|
||||
elif recurring_charge == 0 and one_time_charge > 0:
|
||||
logger.debug('Product {} is one-time payment'.format(product['name']))
|
||||
|
|
@ -268,10 +267,10 @@ class ProductOrder(Resource):
|
|||
}
|
||||
client.put(
|
||||
'/v1/user/{}/orders/{}'.format(cleaned_values['username'], order_obj['order-id']),
|
||||
order_obj, value_in_json=True
|
||||
order_obj
|
||||
)
|
||||
product['quantity'] -= 1
|
||||
client.put('/v1/products/{}'.format(product['uuid']), product, value_in_json=True)
|
||||
client.put('/v1/products/{}'.format(product['uuid']), product)
|
||||
|
||||
return {'message': 'Order successful', **order_obj}, 200
|
||||
|
||||
|
|
@ -288,9 +287,7 @@ class OrderList(Resource):
|
|||
return make_return_message(err, 400)
|
||||
else:
|
||||
cleaned_values = validator.get_cleaned_values()
|
||||
orders = client.get_prefix(
|
||||
'/v1/user/{}/orders'.format(cleaned_values['username']), value_in_json=True
|
||||
)
|
||||
orders = client.get_prefix('/v1/user/{}/orders'.format(cleaned_values['username']))
|
||||
orders_dict = {
|
||||
order.value['order-id']: {
|
||||
**order.value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue