# HG changeset patch # User nishanth # Date 1275909571 -19800 # Node ID 3673ed3ca27ca373ad0052b4be18165546cccb33 # Parent c736873f35cba0626b19d6831595090a2e5fec3a fixed a few bugs diff -r c736873f35cb -r 3673ed3ca27c sdi/forms.py --- a/sdi/forms.py Mon Jun 07 16:00:42 2010 +0530 +++ b/sdi/forms.py Mon Jun 07 16:49:31 2010 +0530 @@ -157,12 +157,13 @@ def clean_username(self): username = self.cleaned_data['username'] - password = self.clean_password() + try: + password = self.data['password'] + except KeyError: + raise forms.ValidationError("Invalid username or password") if not authenticate(username=username, password=password): raise forms.ValidationError("Invalid username or password") return username - def clean_password(self): - return self.cleaned_data['password'] diff -r c736873f35cb -r 3673ed3ca27c sdi/views.py --- a/sdi/views.py Mon Jun 07 16:00:42 2010 +0530 +++ b/sdi/views.py Mon Jun 07 16:49:31 2010 +0530 @@ -7,6 +7,7 @@ from sage_days.sdi.models import Registrant from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm, LoginForm from sage_days.sdi.events import send_reg_complete_mail, mail_invi +from sage_days.settings import APACHE_URL_PREFIX as aup def register(request): """ The user register page. @@ -105,17 +106,23 @@ """ basic login. """ + redirect_url = "/%s/registration/stats"%aup + + user = request.user + if user.is_authenticated(): + return redirect(redirect_url) + if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): - data = form.cleaned_data() + data = form.cleaned_data username = data['username'] password = data['password'] user = authenticate(username=username, password=password) login(request, user) - return redirect("/registration/stats") + return redirect(redirect_url) else: return render_to_response("login.html", {"form":form}) else: