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