--- 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: