def SecretSantaPage(request, post_id, invite=''):
	try:
		SS = SecretSantaGroup.objects.get(pk=post_id)
	except Exception as e:
		return redirect('secretsantaapp.views.homepage')

	if (request.user not in SS.members.all()):
		return redirect('secretsantaapp.views.homepage')

	inv = request.POST.get("invite", "")
	assign = {}

	#check if an invite was sent
	if (inv != ''):
		alreadyInvited = False

		#check if the owner is sending an invite
		if (request.user != SS.owner):
			return render(request, 'secret_santa_page.html', {'SecretSanta':SS})

		#I need to check to see if the invitee is an actual user
		try:
			invitee = User.objects.get(username=inv)
		except Exception as e:
			return redirect('secretsantaapp.views.SecretSantaPage', post_id)

		#check if that user is already invited
		for invitees in SS.invites.all():
			if (invitee.username == invitees.username):
				alreadyInvited = True

		#if user is already invited, return to the santa group page
		if (alreadyInvited == True):
			return redirect('secretsantaapp.views.SecretSantaPage', post_id)

		try:
			newInfo = UserInfo()
			newInfo.user = invitee
			newInfo.save()
			newInfo.invites.add(SS)
			newInfo.save()
		except Exception as e:
			newInfo = UserInfo.objects.get(user=invitee)
			newInfo.invites.add(SS)
			newInfo.save()
			print(newInfo.user)


		SS.invites.add(invitee)

		return render(request, 'secret_santa_page.html', {'SecretSanta':SS})


	if (SS.assignments_generated == True):
		assign = assignment.objects.get(group=SS, giver=request.user)

	return render(request, 'secret_santa_page.html', {'SecretSanta':SS, 'assignment':assign})
def register_user(request):
	if request.method == 'POST':
		form = UserCreationForm(request.POST)

		if form.is_valid():
			form.save()
			username = form.data['username']
			initializeUserInfo = UserInfo()
			initializeUserInfo.user = User.objects.get(username=username)
			initializeUserInfo.save()

			return HttpResponseRedirect('/accounts/register_success')

	args = {}
	args.update(csrf(request))
	args['form'] = UserCreationForm()

	return render_to_response('register.html', args)