1 from forum.models import User
2 from django.shortcuts import render_to_response
3 from django.template import RequestContext
4 from django.utils.translation import ugettext as _
6 from forms import ClassicRegisterForm
7 from forum.views.auth import login_and_forward
8 from forum.actions import UserJoinsAction
10 def register(request):
11 if request.method == 'POST':
12 form = ClassicRegisterForm(request.POST)
15 username = form.cleaned_data['username']
16 password = form.cleaned_data['password1']
17 email = form.cleaned_data['email']
19 user_ = User(username=username, email=email)
20 user_.set_password(password)
22 if User.objects.all().count() == 0:
23 user_.is_superuser = True
27 UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()
29 return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
31 form = ClassicRegisterForm(initial={'next':'/'})
33 return render_to_response('auth/complete.html', {
35 }, context_instance=RequestContext(request))