Skip to content

Instantly share code, notes, and snippets.

@Pacodastre
Created December 11, 2014 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pacodastre/2116c68c68fa466b40e7 to your computer and use it in GitHub Desktop.
Save Pacodastre/2116c68c68fa466b40e7 to your computer and use it in GitHub Desktop.
commit 9f4f41cfb42396cb6dd7281814958fa4ed5aded2
Author: Francois Ribemont <francois.ribemont@openapp.ie>
Date: Sat Oct 18 17:11:26 2014 +0100
PEP8 compliance
diff --git a/django_auth_policy/forms.py b/django_auth_policy/forms.py
index 123cecd..a91454d 100644
--- a/django_auth_policy/forms.py
+++ b/django_auth_policy/forms.py
@@ -39,26 +39,31 @@ class StrictAuthenticationForm(AuthenticationForm):
remote_addr, host)
if username and password:
- self.user_cache = authenticate(username=username, password=password)
+ self.user_cache = authenticate(username=username,
+ password=password)
if self.user_cache is None:
logger.info(u'Authentication failure, username=%s, '
'address=%s, invalid authentication.',
attempt.username, attempt.source_address)
raise forms.ValidationError(
- self.error_messages['invalid_login'],
- code='invalid_login',
- params={'username': self.username_field.verbose_name},
- )
+ self.error_messages['invalid_login'],
+ code='invalid_login',
+ params={'username': self.username_field.verbose_name},
+ )
else:
attempt.user = self.user_cache
attempt.save(update_fields=['user'])
- attempt = self.auth_policy.post_auth_checks(attempt,
- skip_auth_success=True)
+ attempt = self.auth_policy.post_auth_checks(
+ attempt,
+ skip_auth_success=True
+ )
attempt = self.auth_policy.auth_success(attempt)
- self.password_change_policy.update_session(self.request,
- self.user_cache)
+ self.password_change_policy.update_session(
+ self.request,
+ self.user_cache
+ )
return self.cleaned_data
diff --git a/django_auth_policy/handlers.py b/django_auth_policy/handlers.py
index ae96773..321645e 100644
--- a/django_auth_policy/handlers.py
+++ b/django_auth_policy/handlers.py
@@ -142,10 +142,12 @@ class AuthenticationPolicyHandler(object):
pol.post_auth_check(attempt)
if not skip_auth_success:
- logger.warning(u'Deprecation warning: Future versions of '
- 'Django Auth Policy\'s '
- 'handlers.AuthenticationPolicyHandler.post_auth_checks '
- 'will no longer run auth_success.')
+ logger.warning(
+ u'Deprecation warning: Future versions of '
+ 'Django Auth Policy\'s '
+ 'handlers.AuthenticationPolicyHandler.post_auth_checks '
+ 'will no longer run auth_success.'
+ )
return self.auth_success(attempt)
else:
return attempt
diff --git a/django_auth_policy/middleware.py b/django_auth_policy/middleware.py
index de0595b..bc32d7a 100644
--- a/django_auth_policy/middleware.py
+++ b/django_auth_policy/middleware.py
@@ -118,8 +118,8 @@ class LoginRequiredMiddleware(object):
# Django should not serve STATIC files in production, but for
# DEBUG mode this should be no problem (development)
- if (settings.STATIC_URL and
- request.path.startswith(settings.STATIC_URL)):
+ if(settings.STATIC_URL
+ and request.path.startswith(settings.STATIC_URL)):
if settings.DEBUG:
return None
@@ -129,8 +129,8 @@ class LoginRequiredMiddleware(object):
# When serving MEDIA files through Django we will not display a login
# form, but instead return HTTP 401, but for DEBUG mode this should be
# no problem (development)
- if (settings.MEDIA_URL and
- request.path.startswith(settings.MEDIA_URL)):
+ if(settings.MEDIA_URL
+ and request.path.startswith(settings.MEDIA_URL)):
if settings.DEBUG:
return None
diff --git a/django_auth_policy/user_admin.py b/django_auth_policy/user_admin.py
index c498a3e..57bb790 100644
--- a/django_auth_policy/user_admin.py
+++ b/django_auth_policy/user_admin.py
@@ -131,13 +131,17 @@ class StrictUserAdmin(UserAdmin):
request=request,
password=password)
- return template.response.TemplateResponse(request,
+ return template.response.TemplateResponse(
+ request,
'admin/django_auth_policy/set_temporary_password.html',
- {'passwords': passwords})
+ {'passwords': passwords}
+ )
- return template.response.TemplateResponse(request,
+ return template.response.TemplateResponse(
+ request,
'admin/django_auth_policy/confirm_temporary_password.html',
- {'for_users': users})
+ {'for_users': users}
+ )
def save_model(self, request, obj, form, change):
obj.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment