def selectWishListByUser(user): try: wish_list = MODELS.WishList.objects.filter(user = user.id).order_by('date').reverse() if len(wish_list) == 0: wish_list = [] wish = MODELS.WishList() wish.item_category = 5 wish.item_id = MSGS.NO_WISHES wish_list.append(wish) else: mod_wish_list = [] for wish in wish_list: mod_wish = ModWish() mod_wish.item_category = wish.item_category mod_wish.item = selectItemByCategoryAndId(wish.item_category, wish.item_id) mod_wish.date = wish.date if mod_wish.item: mod_wish_list.append(mod_wish) wish_list = mod_wish_list return wish_list except: wish_list = [] wish = MODELS.WishList() wish.item_category = 5 wish.item_id = MSGS.NO_WISHES wish_list.append(wish) return wish_list
def addVenueWish(user, venue): try: wish = MODELS.WishList() wish.item_category = 3 wish.item_id = venue.id wish.user = user wish.save() return True except: return False
def addBeerWish(user, beer): try: wish = MODELS.WishList() wish.item_category = 1 wish.item_id = beer.id wish.user = user wish.save() return True except: return False
def addBreweryWish(user, brewery): try: wish = MODELS.WishList() wish.item_category = 2 wish.item_id = brewery.id wish.user = user wish.save() return True except: return False
def addCommentWish(user, comment): try: wish = MODELS.WishList() wish.item_category = 4 wish.item_id = comment.id wish.user = user wish.save() return True except: return False