Merge remote-tracking branch 'remotes/nyergler/pep8-ification'

Conflicts:
	mediagoblin/db/migrations.py
	mediagoblin/db/models.py
	mediagoblin/user_pages/views.py
	mediagoblin/util.py
This commit is contained in:
Christopher Allan Webber
2011-11-13 20:23:26 -06:00
44 changed files with 159 additions and 123 deletions

View File

@@ -59,9 +59,10 @@ class ForgotPassForm(wtforms.Form):
'Username or email',
[wtforms.validators.Required()])
def validate_username(form,field):
if not (re.match(r'^\w+$',field.data) or
re.match(r'^.+@[^.].*\.[a-z]{2,10}$',field.data, re.IGNORECASE)):
def validate_username(form, field):
if not (re.match(r'^\w+$', field.data) or
re.match(r'^.+@[^.].*\.[a-z]{2,10}$', field.data,
re.IGNORECASE)):
raise wtforms.ValidationError(u'Incorrect input')
@@ -82,4 +83,3 @@ class ChangePassForm(wtforms.Form):
token = wtforms.HiddenField(
'',
[wtforms.validators.Required()])

View File

@@ -94,6 +94,7 @@ EMAIL_VERIFICATION_TEMPLATE = (
u"http://{host}{uri}?"
u"userid={userid}&token={verification_key}")
def send_verification_email(user, request):
"""
Send the verification email to users to activate their accounts.
@@ -128,6 +129,7 @@ EMAIL_FP_VERIFICATION_TEMPLATE = (
u"http://{host}{uri}?"
u"userid={userid}&token={fp_verification_key}")
def send_fp_verification_email(user, request):
"""
Send the verification email to users to change their password.
@@ -151,4 +153,3 @@ def send_fp_verification_email(user, request):
[user['email']],
'GNU MediaGoblin - Change forgotten password!',
rendered_email)

View File

@@ -33,7 +33,8 @@ auth_routes = [
controller='mediagoblin.views:simple_template_render'),
Route('mediagoblin.auth.forgot_password', '/forgot_password/',
controller='mediagoblin.auth.views:forgot_password'),
Route('mediagoblin.auth.verify_forgot_password', '/forgot_password/verify/',
Route('mediagoblin.auth.verify_forgot_password',
'/forgot_password/verify/',
controller='mediagoblin.auth.views:verify_forgot_password'),
Route('mediagoblin.auth.fp_changed_success',
'/forgot_password/changed_success/',

View File

@@ -160,7 +160,7 @@ def verify_email(request):
you are lucky :)
"""
# If we don't have userid and token parameters, we can't do anything; 404
if not request.GET.has_key('userid') or not request.GET.has_key('token'):
if not 'userid' in request.GET or not 'token' in request.GET:
return render_404(request)
user = request.db.User.find_one(
@@ -253,8 +253,7 @@ def forgot_password(request):
request, 'mediagoblin.user_pages.user_home',
user=user['username'])
# do not reveal whether or not there is a matching user, just move along
# do not reveal whether or not there is a matching user
return redirect(request, 'mediagoblin.auth.fp_email_sent')
return render_to_response(
@@ -328,6 +327,6 @@ def _process_for_token(request):
formdata = {
'vars': formdata_vars,
'has_userid_and_token':
formdata_vars.has_key('userid') and formdata_vars.has_key('token')}
'userid' in formdata_vars and 'token' in formdata_vars}
return formdata