Ejemplo n.º 1
0
	def deleteProductFromList(self, list_id, pid):

		if list_id ==None or pid ==None:
			return False
		Product.deleteProduct(pid)
		ListOfProducts.deleteProduct(pid)
		return True
Ejemplo n.º 2
0
	def deleteList(self,list_id, group_id):
		query = List.query(List.ListID == list_id).fetch()
		if query:
			for list in query:
				list.key.delete()
			GroupLists.deleteList(list_id)
			productsIds = ListOfProducts.getAllProductsIDs(list_id)
			if productsIds:
				for productID in productsIds:
					Product.deleteProduct(productID)
			ListOfProducts.deleteList(list_id)
Ejemplo n.º 3
0
 def checkIfProductExists(self, product_name, list_id):
     p_list = Product.getProductByName(product_name)
     if p_list:
         for p in p_list:
             query = ListOfProducts.query(
                 ListOfProducts.ProductID == p.ProductID,
                 ListOfProducts.ListID == list_id).get()
             if query:
                 return True
     else:
         return False
Ejemplo n.º 4
0
	def addProduct(self, list_id, product_name,product_quantity,product_units):
		products = ListOfProducts.getAllProductsIDs(list_id)
		if len(products)!=0:
			for product_id in products:
				product = Product.getProductByID(product_id)
				if product is None:
					Product.addProduct(product_name,product_quantity,product_units, list_id)
					return True
				else:
					return False
		else:
			Product.addProduct(product_name,product_quantity,product_units, list_id)
			return True
Ejemplo n.º 5
0
 def addProduct(self, product_name, product_quantity, product_units,
                list_id):
     product = Product()
     product.ProductName = product_name
     product.ProductQuantity = product_quantity
     product.ProductUnits = product_units
     product.isChecked = False
     product.put()
     product.ProductID = product.key.id()
     product.put()
     listOfProducts = ListOfProducts()
     listOfProducts.ListID = list_id
     listOfProducts.ProductName = product_name
     listOfProducts.ProductID = product.key.id()
     listOfProducts.put()
Ejemplo n.º 6
0
	def getAllProductsOfTheList(self, list_id):
		i=0
		products = []
		productsIds = ListOfProducts.getAllProductsIDs(list_id)
		if productsIds:
			for productid in productsIds:
				p = Product.getProductByID(productsIds[i])
				pData = []
				if p:
					pData.append(p.ProductName)
					pData.append(p.ProductQuantity)
					pData.append(p.ProductUnits)
					pData.append(p.ProductID)
					pData.append(p.isChecked)
					products.append(pData)
					i+=1
			if products:
				return products
		else:
			return None
Ejemplo n.º 7
0
	def deleteAllProducts(self, list_id):
		AllPids = ListOfProducts.query(ListOfProducts.ListID==list_id).fetch()
		if AllPids:
			for product in AllPids:
				List.deleteProductFromList(list_id,product.ProductID)