deleted unwanted code to start using django-registration.
authoranoop
Wed, 17 Feb 2010 17:46:16 +0530
changeset 40 43853e376bb8
parent 39 476613c3ab0a
child 41 b742f22b62d1
deleted unwanted code to start using django-registration.
taskapp/forms/user.py
taskapp/views/user.py
urls.py
--- a/taskapp/forms/user.py	Mon Feb 15 15:14:27 2010 +0530
+++ b/taskapp/forms/user.py	Wed Feb 17 17:46:16 2010 +0530
@@ -4,18 +4,6 @@
 from pytask.taskapp.models import GENDER_CHOICES, Profile
 from django.forms import ModelForm
 
-class RegistrationForm(forms.Form):
-    username = forms.CharField(max_length=30, required=True)
-    password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput)
-    repeat_password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput)
-    email = forms.EmailField(max_length=30, required=True)
-    gender = forms.ChoiceField(choices=GENDER_CHOICES, required = True)
-    dob = forms.DateField(required=True, help_text = "(YYYY-MM-DD)")
-
-class LoginForm(forms.Form):
-    username = forms.CharField(max_length=30, required=True)
-    password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput)
-
 class UserProfileEditForm(ModelForm):
     class Meta:
         model = Profile
--- a/taskapp/views/user.py	Mon Feb 15 15:14:27 2010 +0530
+++ b/taskapp/views/user.py	Wed Feb 17 17:46:16 2010 +0530
@@ -1,9 +1,8 @@
 from django.http import HttpResponse
 from django.shortcuts import redirect, render_to_response
 from pytask.taskapp.models import Task
-from pytask.taskapp.forms.user import RegistrationForm, LoginForm, UserProfileEditForm
+from pytask.taskapp.forms.user import UserProfileEditForm
 from pytask.taskapp.events.user import createUser, updateProfile
-from django.contrib.auth import login, logout, authenticate
 from django.contrib.auth.models import User
 from pytask.taskapp.models import Profile
 from django.contrib.auth.decorators import login_required
@@ -48,59 +47,6 @@
                    
         return render_to_response('index.html', context)
 
-
-def register(request):
-    """ user registration: gets the user details and create the user and userprofile if data entered is valid"""
-    if request.method == 'POST':
-        form = RegistrationForm(request.POST)
-        if form.is_valid():
-            data = form.cleaned_data
-            if data['password'] == data['repeat_password']:
-                if data['username'].isalnum():
-                    try:
-                        if User.objects.get(username__exact = data['username']):
-                            errors=['Choose some other username']
-                            return render_to_response('user/register.html',{'form':form,'errors':errors})
-                    except:
-                         u = createUser(username=data['username'], email=data['email'], password=data['password'],dob = data['dob'],gender = data['gender'])
-                    return redirect('/accounts/login/')
-                else:
-                    errors = ['Username can contain only alphabets and numbers!']
-                    return render_to_response('user/register.html',{'form':form,'errors':errors})
-            else:
-                errors=['Password do not match']
-                form = RegistrationForm(request.POST)
-                return render_to_response('user/register.html',{'form':form,'errors':errors})#HttpResponse('Password did not match')
-        else:
-            form = RegistrationForm(request.POST)
-    else:
-        form = RegistrationForm()
-    return render_to_response('user/register.html', {'form': form})
-
-def user_login(request):
-    if request.method == 'POST':
-        username = request.POST['username']
-        password = request.POST['password']
-        user = authenticate(username=username, password=password)
-        if user is not None:
-            if user.is_active:
-                login(request, user)
-                return redirect('/')# Redirect to a success page.
-            else:
-                return show_msg('username is not active, please contact the administrator')# Return a 'disabled account' error message
-        else:
-            errors = ['Please check your username and password']
-            form = LoginForm()
-            return render_to_response('user/login.html',{'form':form,'errors':errors})# Return an 'invalid login' error message.
-        return redirect('/')
-    else:
-        form = LoginForm()
-        return render_to_response('user/login.html',{'form': form})
-
-def user_logout(request):
-    logout(request)
-    return show_msg('You have logged off successfully!!!')
-
 @login_required
 def view_my_profile(request,uid):
     """ allows the user to view the profiles of users """
--- a/urls.py	Mon Feb 15 15:14:27 2010 +0530
+++ b/urls.py	Wed Feb 17 17:46:16 2010 +0530
@@ -29,10 +29,6 @@
     
     (r'^admin/', include(admin.site.urls)),
     
-    (r'^accounts/register/$', userViews.register),
-    (r'^accounts/login/$', userViews.user_login),
-    (r'^accounts/logout/$', userViews.user_logout),
-    
     (r'^user/view/uid=(\d+)$', userViews.view_my_profile),
     (r'^user/edit/?$', userViews.edit_my_profile),
     (r'^user/browse/?$', userViews.browse_users),