diff options
author | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-01 06:14:25 -0400 |
---|---|---|
committer | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-01 06:14:25 -0400 |
commit | 67d5552db4e48582587b0a09ce5659422d2e2d25 (patch) | |
tree | 5268b01db4fa9375ac57336718310b4a0818525a /views/accounts.py | |
parent | afd6cbf2f6911500df4c32417dc041192da41d62 (diff) | |
download | hyperkitty-67d5552db4e48582587b0a09ce5659422d2e2d25.tar.gz hyperkitty-67d5552db4e48582587b0a09ce5659422d2e2d25.tar.xz hyperkitty-67d5552db4e48582587b0a09ce5659422d2e2d25.zip |
Basic user registration up
Diffstat (limited to 'views/accounts.py')
-rw-r--r-- | views/accounts.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/views/accounts.py b/views/accounts.py index 1eeb8c9..b79943d 100644 --- a/views/accounts.py +++ b/views/accounts.py @@ -18,6 +18,7 @@ from django.utils.translation import gettext as _ from urllib2 import HTTPError from urlparse import urlparse +from forms import RegistrationForm from gsoc.utils import log def user_logout(request): @@ -65,3 +66,28 @@ def user_profile(request, user_email = None): }) return HttpResponse(t.render(c)) + + +def user_registration(request): + if request.user.is_authenticated(): + # Already registed, redirect back to home page + return redirect('index') + + if request.POST: + form = RegistrationForm(request.POST) + if form.is_valid(): + # Save the user data. + form.save(form.cleaned_data) + user = authenticate(username=form.cleaned_data['username'], + password=form.cleaned_data['password1']) + + if user is not None: + log('debug', user) + if user.is_active: + login(request,user) + return redirect('index') + else: + form = RegistrationForm() + + return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request)) + |