Ejemplo n.º 1
0
def password_change(request, send_mail=True):
	if request.method == "POST":
		form = PasswordChangeForm(request.user, request.POST)
		if form.is_valid():
			form.save()
			password = '******' % request.POST['new_password1']
			if send_mail==True:
				xemple_send_mail('new_user', Context({'user':request.user, 'password':password}))
			return HttpResponseRedirect(reverse('password_change_done'))
	else:
		form = PasswordChangeForm(request.user)
	return render_to_response('authentication/password_change.html', {'form': form,}, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def client_new(request, send_mail=True):
	redirect_to = request.REQUEST.get('next', '')
	if request.POST.has_key('register'):
		form = NewClientForm(request.POST)
		if form.is_valid():
			username, password = form.save()
			print "USERNAME : %s" % username
			print "PASSWORD : %s" % password
			user = authenticate(username=username, password=password)
			if user is not None:
				if user.is_active:
					login(request, user)
					infos = '%s // %s' % (username, password)
					if send_mail==True:
						xemple_send_mail('new_user', Context({'user':request.user, 'password':password}))
					if redirect_to == '':
						return HttpResponseRedirect(reverse('manager_panel'))
					else:
						return HttpResponseRedirect(redirect_to)
			return HttpResponseRedirect(reverse('client_new'))
	else:
		form = NewClientForm()
	return render_to_response('client/client_form.html', {'form':form, 'next':redirect_to}, context_instance=RequestContext(request))