added user login and registration

This commit is contained in:
Raynaldo Rivera
2014-10-03 15:45:42 -07:00
parent 74ad02b677
commit 4ca6c7dbb0
14 changed files with 168 additions and 5 deletions

0
registration/__init__.py Normal file
View File

3
registration/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

8
registration/forms.py Normal file
View File

@@ -0,0 +1,8 @@
from django import forms
class RegistrationForm(forms.Form):
username = forms.CharField(max_length=16, required = True)
password = forms.CharField(widget=forms.PasswordInput())
email = forms.CharField(max_length=254, required = True)
api_id = forms.CharField(max_length=254, required = True)
api_key = forms.CharField(max_length=254, required = True)

3
registration/models.py Normal file
View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
registration/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

26
registration/views.py Normal file
View File

@@ -0,0 +1,26 @@
from django.http import Http404,HttpResponseRedirect
from django.shortcuts import render_to_response, render
from django.template import RequestContext
from authentication.models import AllianceUserManager
from forms import RegistrationForm
# Create your views here.
def register(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
userManager = AllianceUserManager()
userManager.create_user_withapi(
form.cleaned_data['username'],
form.cleaned_data['email'],
form.cleaned_data['password'],
form.cleaned_data['api_id'],
form.cleaned_data['api_key']
)
return HttpResponseRedirect("/")
else:
form = RegistrationForm()
return render_to_response('public/register.html',{'form':form}, context_instance=RequestContext(request))