def change_item(self, item_id, operation): product = Products().get_one(item_id) if product: if operation == 'add': self.items.append(product) elif operation == 'remove': cart_product = filter(lambda x: x['id'] == product['id'], self.items) self.items.remove(cart_product[0]) self.update() return True else: return False
def change_item(self, item_id, operation): """ Remove items in cart """ product = Products().get_one(item_id) if product: if operation == 'add': self.items.append(product) elif operation == 'remove': cart_p = [x for x in self.items if x['id'] == product['id']] self.items.remove(cart_p[0]) self.update() return True else: return False
def list_products(self): return Products().get_all()
def list_products(): """ Product list """ products = Products().get_all() return render_template('products.jinja2', products=products, cart=session['cart'])