Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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