Use refactored method + improved ordered_at time shown to user
This commit is contained in:
parent
ca41a9bcab
commit
2c1a9986f4
1 changed files with 8 additions and 12 deletions
|
@ -81,18 +81,9 @@ class ListProducts(Resource):
|
|||
products = client.get_prefix("/v1/products/", value_in_json=False)
|
||||
prod_dict = {}
|
||||
for p in products:
|
||||
p_json = json.loads(p.value)
|
||||
product_id = p.key[p.key.rindex("/")+1:]
|
||||
actual_product = {
|
||||
"name": p_json["name"],
|
||||
"description": p_json["description"],
|
||||
"product_id": product_id,
|
||||
"pricing": get_pricing(p_json["price"], p_json["type"],
|
||||
p_json["recurring_period"]),
|
||||
"minimum_subscription_period":
|
||||
p_json["minimum_subscription_period"]
|
||||
}
|
||||
prod_dict[product_id] = actual_product
|
||||
p_dict = json.loads(p.value)
|
||||
uf_product = get_user_friendly_product(p_dict)
|
||||
prod_dict[uf_product["product_id"]] = uf_product
|
||||
logging.debug("Products = {}".format(prod_dict))
|
||||
return prod_dict, 200
|
||||
|
||||
|
@ -344,6 +335,11 @@ class ProductOrder(Resource):
|
|||
client.put("/v1/user/{}/orders".format(
|
||||
data['name']), json.dumps(order_obj),
|
||||
value_in_json=True)
|
||||
order_obj["ordered_at"] = datetime.fromtimestamp(
|
||||
order_obj["ordered_at"]).strftime("%c")
|
||||
order_obj["product"] = get_user_friendly_product(
|
||||
product_obj
|
||||
)
|
||||
return {"message": "Order successful",
|
||||
"order_details": order_obj}, 200
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue