~chipaca/unity-lens-video/custom-user-agent

« back to all changes in this revision

Viewing changes to accounts/views.py

  • Committer: Janos Gyerik
  • Date: 2012-04-04 13:22:47 UTC
  • Revision ID: burlyman@titan2x.com-20120404132247-2s7liq2i4e7nn8ul
minor improvement to create_user_profile signal

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from django.contrib.auth.models import User
2
 
from django.contrib.auth.forms import UserCreationForm
3
 
from django.template import RequestContext
4
 
from django.shortcuts import render_to_response
5
 
from django.core.urlresolvers import reverse as reverse_url
6
 
from django.http import HttpResponseRedirect
7
 
 
8
 
from django.contrib.auth import authenticate as django_authenticate
9
 
from django.contrib.auth import login as django_login
10
 
 
11
 
from bashoneliners.main.models import Hacker
12
 
 
13
 
def create_user(request, template_name='registration/create_user_form.html'):
14
 
    if request.method == 'POST':
15
 
        form = UserCreationForm(request.POST)
16
 
        if form.is_valid():
17
 
            hacker = Hacker.objects.create_user(form.cleaned_data['username'], '', form.cleaned_data['password1'])
18
 
 
19
 
            django_user = django_authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password1'])
20
 
            django_login(request, django_user)
21
 
 
22
 
            return HttpResponseRedirect('/')
23
 
    else:
24
 
        form = UserCreationForm()
25
 
 
26
 
    return render_to_response(template_name, {
27
 
        'form': form,
28
 
        }, context_instance=RequestContext(request))
29
 
 
30
 
def profile(request, template_name='registration/profile.html'):
31
 
    return render_to_response(template_name, { 'user': request.user })
32
 
 
33
 
# eof