# HG changeset patch # User anoop # Date 1264783303 -19800 # Node ID 232d40a28118fefa9e7c0f7f1a54a73e627528c6 # Parent 94136f9a48bc31c843c1c28da7cc1e1b217b56c7 imposed a filter on username that it contains only alphabets and numbers. diff -r 94136f9a48bc -r 232d40a28118 pytask/taskapp/views/users.py --- a/pytask/taskapp/views/users.py Fri Jan 29 21:37:13 2010 +0530 +++ b/pytask/taskapp/views/users.py Fri Jan 29 22:11:43 2010 +0530 @@ -50,13 +50,17 @@ if form.is_valid(): data = form.cleaned_data if data['password'] == data['repeat_password']: - 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/') + 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)