PEP8 cleanups.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
from os.path import join, getsize
|
||||
|
||||
BASE_PATH = 'mayan/apps'
|
||||
|
||||
@@ -18,7 +17,6 @@ def print_views_summary(module_filename):
|
||||
if line.startswith('def') and 'request' in line:
|
||||
count_function_based_views += 1
|
||||
|
||||
|
||||
print ' class based views: {}'.format(count_class_based_views)
|
||||
print ' function based views: {}'.format(count_function_based_views)
|
||||
return count_class_based_views, count_function_based_views
|
||||
@@ -29,7 +27,6 @@ def print_tests_summary(module_filename):
|
||||
print ' module:', module_filename
|
||||
count_tests = 0
|
||||
for line in file_object:
|
||||
#if 'def test' in line:
|
||||
if line.startswith(' def test'):
|
||||
count_tests += 1
|
||||
|
||||
@@ -63,7 +60,7 @@ if __name__ == '__main__':
|
||||
except IOError:
|
||||
# Check for multiple view files inside a view directory
|
||||
try:
|
||||
module_path = os.path.join(module_path, 'views')
|
||||
module_path = os.path.join(app_path, 'views')
|
||||
for module_name in os.listdir(module_path):
|
||||
if not module_name.startswith('__init__.py') and not module_name.endswith('.pyc'):
|
||||
module_filename = os.path.join(module_path, module_name)
|
||||
@@ -85,7 +82,6 @@ if __name__ == '__main__':
|
||||
# No API views directory, skip app
|
||||
print ' No API views'
|
||||
|
||||
|
||||
print '\n Tests'
|
||||
module_path = os.path.join(app_path, 'tests')
|
||||
try:
|
||||
@@ -100,7 +96,6 @@ if __name__ == '__main__':
|
||||
# No tests directory, skip app
|
||||
print ' No tests'
|
||||
|
||||
|
||||
print '-' * 10
|
||||
|
||||
print 'Totals:'
|
||||
|
||||
@@ -3,8 +3,7 @@ from __future__ import absolute_import
|
||||
import ldap
|
||||
from django_auth_ldap.config import LDAPSearch
|
||||
|
||||
from .base import *
|
||||
from django.conf import settings
|
||||
from .base import * # NOQA
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
SECRET_KEY = '<your secret key>'
|
||||
@@ -27,22 +26,24 @@ AUTH_LDAP_BIND_DN = LDAP_ADMIN_DN
|
||||
AUTH_LDAP_BIND_PASSWORD = LDAP_PASSWORD
|
||||
|
||||
|
||||
AUTH_LDAP_USER_SEARCH = LDAPSearch('%s,%s'%(LDAP_ADDITIONAL_USER_DN, LDAP_BASE_DN), ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
|
||||
AUTH_LDAP_USER_SEARCH = LDAPSearch(
|
||||
'%s,%s' % (LDAP_ADDITIONAL_USER_DN, LDAP_BASE_DN),
|
||||
ldap.SCOPE_SUBTREE, '(uid=%(user)s)'
|
||||
)
|
||||
AUTH_LDAP_USER_ATTR_MAP = {
|
||||
"first_name": "cn",
|
||||
"last_name": "sn",
|
||||
"email": "mail"
|
||||
'first_name': 'cn',
|
||||
'last_name': 'sn',
|
||||
'email': 'mail'
|
||||
}
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'django_auth_ldap.backend.LDAPBackend',
|
||||
'mayan.settings.settings_local.EmailOrUsernameModelBackend',
|
||||
)
|
||||
|
||||
|
||||
class EmailOrUsernameModelBackend(object):
|
||||
"""
|
||||
This is a ModelBacked that allows authentication with either a username or an email address.
|
||||
|
||||
"""
|
||||
def authenticate(self, username=None, password=None):
|
||||
if '@' in username:
|
||||
@@ -53,7 +54,7 @@ class EmailOrUsernameModelBackend(object):
|
||||
user = get_user_model().objects.get(**kwargs)
|
||||
if user.check_password(password):
|
||||
return user
|
||||
except User.DoesNotExist:
|
||||
except get_user_model().DoesNotExist:
|
||||
return None
|
||||
|
||||
def get_user(self, username):
|
||||
|
||||
Reference in New Issue
Block a user