示例#1
0
def success(request):
    if request.method == 'POST':
        f = Favorite(user=request.user.username, video=request.POST['video'])
        favorites = Favorite.objects.all()
        v = request.POST['video']
        fs = Favorite.objects.filter(video=v)
        fu = Favorite.objects.filter(user=request.user.username)
        if fs and fu:
            return HttpResponse(v + " is already in your favorites.")
        f.save()
        return HttpResponse("Video: " + v + " was added to your favorites!")
示例#2
0
def success(request):
	if request.method == 'POST':
		f = Favorite(user = request.user.username,
			video = request.POST['video'])
		favorites = Favorite.objects.all()
		v = request.POST['video']
		fs = Favorite.objects.filter(video=v)
		fu = Favorite.objects.filter(user=request.user.username)
		if fs and fu:
			return HttpResponse(v + " is already in your favorites.")
		f.save()
		return HttpResponse("Video: "+ v + " was added to your favorites!")
示例#3
0
def success(request): 
	#How a user adds videos to their favorites. 
	#If the video is already saved it won't add. 
	if request.method == 'POST':
		f = Favorite(user = request.user.username,
			video = request.POST['video'])
		favorites = Favorite.objects.all()
		v = request.POST['video']
		fs = Favorite.objects.filter(video=v, user=request.user.username)
		#fu = Favorite.objects.filter(user=request.user.username)
		if fs:
			return HttpResponseRedirect("/nodice/")
		f.save()
		return HttpResponseRedirect("/myfavs/")