Refactor + improve order list
This commit is contained in:
parent
2c1a9986f4
commit
56725af770
1 changed files with 12 additions and 3 deletions
|
@ -3,6 +3,7 @@ import json
|
|||
|
||||
import requests
|
||||
from decouple import config, Csv
|
||||
from datetime import datetime
|
||||
from flask import Flask, request
|
||||
from flask_restful import Resource, Api
|
||||
from pyotp import TOTP
|
||||
|
@ -369,9 +370,17 @@ class OrderList(Resource):
|
|||
orders = client.get_prefix("/v1/user/{}/orders".format(data['name']), value_in_json=True)
|
||||
orders_dict = {}
|
||||
for p in orders:
|
||||
order_dict[p.key] = p.value
|
||||
logging.debug("Orders = {}".format(order_dict))
|
||||
return order_dict, 200
|
||||
order_dict = json.loads(p.value)
|
||||
logging.debug("order_dict = " + str(order_dict))
|
||||
logging.debug("type p.value = " + str(type(p.value)))
|
||||
logging.debug("p.value = " + str(p.value))
|
||||
order_dict["ordered_at"] = datetime.fromtimestamp(
|
||||
order_dict["ordered_at"]).strftime("%c")
|
||||
order_dict["product"] = get_user_friendly_product(
|
||||
order_dict["product"])
|
||||
orders_dict[p.key] = order_dict
|
||||
logging.debug("Orders = {}".format(orders_dict))
|
||||
return orders_dict, 200
|
||||
|
||||
except KeyError as kerr:
|
||||
logging.error(str(kerr))
|
||||
|
|
Loading…
Reference in a new issue