Exemplo n.º 1
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)
Exemplo n.º 2
0
 def deleteUserFromGroup(self, group_id, user_name):
     if user_name:
         User.deleteUserFromGroup(group_id, user_name)
         lists = GroupLists.getAllLists(group_id)
         if lists:
             for list in lists:
                 List.deleteUserFromList(user_name, list)
Exemplo n.º 3
0
	def checkIfTheNameExists(self,list_name,group_id):
		lists = GroupLists.getAllLists(group_id)
		if lists:
			for list in lists:
				query = List.query(List.ListID == list).get()
				if query:
					if query.ListName == list_name:
						return True
		return False
Exemplo n.º 4
0
 def deleteGroup(self, group_id):
     query = Group.query(Group.GroupID == group_id).get()
     if query:
         key = query.key.id()
         query.key.delete()
         User.deleteGroup(key)
         lists = GroupLists.getAllLists(key)
         if lists:
             for list in lists:
                 List.deleteList(list.ListID, key)
Exemplo n.º 5
0
 def createList(self, list_name, list_admin, group_id):
     groupLists = GroupLists.getAllLists(group_id)
     if groupLists is None:
         List.createList(list_name, list_admin, group_id)
         return True
     else:
         for group in groupLists:
             if (group.GroupID == group_id):
                 return False
         List.createList(list_name, list_admin, group_id)
         return True
Exemplo n.º 6
0
	def getAllListsName(self,group_id):
		listNames = []
		if group_id:	
			my_groupListsIds = GroupLists.getAllLists(group_id)
			if my_groupListsIds:
				for list in my_groupListsIds:
					lName = List.getListNameByID(list)
					IdAndName =[list,lName]
					listNames.append(IdAndName)
				listNames.sort(key=lambda x: x[1].lower())
				return listNames
			else:
				return None
Exemplo n.º 7
0
	def getAllListsNameOfTheUser(self,group_id, user_email):
		listNames = []
		if group_id:	
			my_groupListsIds = GroupLists.getAllLists(group_id)
			if my_groupListsIds:
				for list_id in my_groupListsIds:
					userInList = List.checkIfUserInList(list_id, user_email)
					if userInList == True:
						lName = List.getListNameByID(list_id)
						IdAndName =[list_id,lName]
						listNames.append(IdAndName)
				listNames.sort(key=lambda x: x[1].lower())
				return listNames
			else:
				return None
Exemplo n.º 8
0
	def createList(list_name,list_admin, group_id):
		if List.checkIfTheNameExists(list_name,group_id) == False:
			list = List()
			list.ListName =list_name
			list.ListAdmin = list_admin
			list.put()
			list.ListID = list.key.id()
			list.put()
			groupList = GroupLists()
			groupList.ListID = list.key.id()
			groupList.GroupID = group_id
			groupList.put()
			return list
		return None