Пример #1
0
    def get(self):
        claims = get_jwt_claims()
        if not claims['is_admin']:
            return {'message': 'admin privilege required.'}, 401

        orders = [order.json() for order in OrderModel.find_all()]
        return {'orders': orders}, 200
Пример #2
0
    def get(cls):
        uid = get_jwt_identity()
        orders = []

        if StoreModel.find_by_id(uid):
            for order in OrderModel.find_all():
                if order.status == 'pending':
                    items = fetching_order(order.order_items)
                    message = order.message
                    orders.append({
                        'id': order.id,
                        'status': order.status,
                        'items': items,
                        'message': message
                    })
            return orders, 200
        elif CustomerModel.find_by_id(uid):
            for order in OrderModel.find_customer_completed_orders(
                    customer_id=uid):
                items = fetching_order(order.order_items)
                message = order.message
                orders.append({
                    'id': order.id,
                    'items': items,
                    'message': message
                })
            return orders, 200
        return 401
Пример #3
0
 def get(cls):
     """
     This endpoint is solely for testing purpose so that we can get a better idea what is happening
     for each successful/failed charge.
     :return: a list of all orders
     """
     # You could also define a `OrderSchema(many=True)` above, like we did for items and stores!
     return order_schema.dump(OrderModel.find_all(), many=True), 200
Пример #4
0
 def get(cls):
     return list_orders_schema.dump(OrderModel.find_all()), 200
Пример #5
0
 def get(cls):
     return order_schema.dump(OrderModel.find_all(), many=True), 200
Пример #6
0
 def test_order(self):
     with self.app_context():
         print(self.order_schema.dump(OrderModel.find_all(), many=True))
Пример #7
0
 def get(cls):
     # return multiple_order_schema.dump(OrderModel.find_all()), 200
     return order_schema.dump(OrderModel.find_all(), many=True), 200
Пример #8
0
 def get(cls):
     return multiple_order_schema.dump(OrderModel.find_all()), 200
Пример #9
0
 def get(cls):
     return {"items": order_list_schema.dump(OrderModel.find_all())}, 200
Пример #10
0
 def get(cls):
     return {'orders': orderListSchema.dump(OrderModel.find_all())}, 200