def _fetchComplementingCarts(self, cart_ids): """ Fetches complementing carts to given cart_ids related to all carts in DB. """ carts = [self._fetchCart(cart_id) for cart_id in cart_ids] all_carts = Cart.objects() return [cart for cart in all_carts if cart not in carts]
def _fetchCart(self, cart_id): """ Fetches cart by given ID. """ try: return Cart.objects(cart_id=cart_id).get() except: return None
def _fetchCart(self, cart_id): """ Fetches cart by given ID. """ try: return Cart.objects(cart_id=str(cart_id)).get() except: return None
def put(self, cart_id: str) -> Response: """ PUT response method for updating a product. JSON Web Token is required. Authorization is required: Access(admin=true) :return: JSON object """ data = request.get_json() print('cartupdate') print(data) y = json.loads(data['products']) print(y) hh = {'products': y} put_user = Cart.objects(id=cart_id).update(**hh) #**data return jsonify({'result': put_user})
def current_state_of_carts(): carts = Cart.objects() return jsonify(title='As of {}'.format(datetime.now()), msg=[cart.toMinimalJson() for cart in carts])