Beispiel #1
0
def auth_simple_sign_up(request):
	form = SimpleSignUpForm(request.POST or None)
	
	if form.is_valid():
		
		cleaned_form = form.cleaned_data
		username     = cleaned_form['username']
		password     = cleaned_form['password']
		confirmation = cleaned_form['confirm']

		user,created = User.objects.get_or_create(username=username)
		
		if created:
			session_finalized_fundraiser = SessionVariable(request).session_finalized_fundraiser()
			user.set_password(password)
			user.save()
			if session_finalized_fundraiser is None:
				title = 'session expired. call back office to set up account.'
				messages.error(request,title)
				return HttpResponseRedirect(reverse('describe_fundraiser'))

			profile = session_finalized_fundraiser.profile
			profile.account = user 
			profile.save()
			session_finalized_fundraiser.account = user
			session_finalized_fundraiser.save()
			
			auth = authenticate(username=username,password=password)
			
			login(request,auth)

			title = str(user.username) + ', You have successfully signed up! See your profile to manage your Organization.'
			messages.success(request,title)
			return HttpResponseRedirect(reverse('process_checkout'))
		else:
			title = 'Username exists, pick a more unique username!'
			messages.error(request,title)
			return HttpResponseRedirect(reverse('process_checkout'))
	else:
		title = 'There was an error in creating your account. Make sure passwords match!'
		messages.error(request,title)
		return HttpResponseRedirect(reverse('process_checkout'))