Example #1
0
def Signin(request):

	# Load strings language to template login.html
	try:
		lang = strLang()
	except:
		lang = ''

	if request.method == 'POST':
		registerForm = RegisterForm(request.POST)

		if registerForm.is_valid(): 
			user = User.objects.create_user(request.POST['username'], request.POST['email'], request.POST['password'])
			user.is_staff = False
			user.first_name = request.POST['first_name']
			user.last_name = request.POST['last_name']
			userProfile = UserProfile(user=user)
			user.save()
			userProfile.save()

			user = authenticate(username=request.POST['username'], password=request.POST['password'])
			login(request, user)

			

			return render_to_response('mobile/welcome.html', {})

		else:
			return render_to_response('mobile/signin.html', {
				'user_me': request.user,
				'registerForm': registerForm,
				'lang': lang,
			})

	else: # If get request, generate a new form
		registerForm = RegisterForm() # An unbound form

		return render_to_response('mobile/signin.html', {
			'user_me': request.user,
			'registerForm': registerForm,
			'lang': lang,
		})
Example #2
0
def Signin(request):


	if request.method == 'POST':
		print request.POST
		registerForm = RegisterForm(request.POST)
		
		timezone = request.POST['timezone']

		if registerForm.is_valid(): 
			user = User.objects.create_user(request.POST['username'], request.POST['email'], request.POST['password'])
			user.is_staff = False
			user.first_name = request.POST['first_name']
			user.last_name = request.POST['last_name']
			userProfile = UserProfile(user=user, timezone=timezone)
			user.save()
			userProfile.save()

			user = authenticate(username=request.POST['username'], password=request.POST['password'])
			login(request, user)

			#return HttpResponseRedirect("/next-games")

			if request.mobile:
				return HttpResponse(get_template('mobile/welcome.html').render(RequestContext(request, {})))

				#return render_to_response('mobile/welcome.html', {})

# 			return HttpResponse(get_template('custom/welcome.html').render(RequestContext(request, {
# 				'user': request.user
# 			})))
			return HttpResponseRedirect("/active-tournaments")

			#return render_to_response('custom/welcome.html', {
			#	'user': request.user
			#})
			

		else:
			template = get_template('custom/signin.html')

			if request.mobile:
				template = get_template('mobile/signin.html')

			return HttpResponse(template.render(RequestContext(request, {
				'user_me': request.user,
				'registerForm': registerForm
			})))


	else: # If get request, generate a new form
		registerForm = RegisterForm() # An unbound form

		template = get_template('custom/signin.html')

		if request.mobile:
			template = get_template('mobile/signin.html')

		return HttpResponse(template.render(RequestContext(request, {
			'user_me': request.user,
			'registerForm': registerForm
		})))			
Example #3
0
def register(request):

	# Load strings language to template login.html
	try:
		lang = strLang()
	except:
		lang = ''

	if request.method == 'POST':
		registerForm = RegisterForm(request.POST) # A form bound to the POST data
		loginForm = LoginForm()
		if registerForm.is_valid(): 
			user = User.objects.create_user(request.POST['username'], request.POST['email'], request.POST['password'])
			user.is_staff = False
			user.first_name = request.POST['first_name']
			user.last_name = request.POST['last_name']
			userProfile = UserProfile(user=user)
			user.save()
			userProfile.save()

			loginForm = LoginForm()
			registerForm = RegisterForm()

			# We show a notification user
			try:
	 			box = setBox('success_register_account')
			except:
				box = ''

			return render_to_response('login.html', {
				'user_me': request.user,
				'registerForm': registerForm,
				'loginForm': loginForm,
				'box': box,
				'lang': lang,
			})
		else:
			return render_to_response('login.html', {
				'user_me': request.user,
				'registerForm': registerForm,
				'loginForm': loginForm,
				'lang': lang,
			})
	else: # If get request, generate a new form
		registerForm = RegisterForm() # An unbound form
		loginForm = LoginForm()

		# Must we show a notification user?
		try:
	 		if request.GET['status']:
	 			box = setBox(request.GET['status'])
		except:
			box = ''

		return render_to_response('login.html', {
			'user_me': request.user,
			'registerForm': registerForm,
			'loginForm': loginForm,
			'lang': lang,
			'box': box,
		})