mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
PEP8 fixes
This commit is contained in:
@@ -34,7 +34,7 @@ def db_type(cname="default"):
|
||||
:param str cname: connection name
|
||||
:return: a string or None
|
||||
"""
|
||||
if not cname in settings.DATABASES:
|
||||
if cname not in settings.DATABASES:
|
||||
raise InternalError(
|
||||
_("Connection to database %s not configured" % cname))
|
||||
for t in ['postgres', 'mysql', 'sqlite']:
|
||||
|
||||
@@ -34,14 +34,17 @@ Extracted from `this blog
|
||||
|
||||
"""
|
||||
import ldap
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from modoboa.core.password_hashers import get_password_hasher
|
||||
from modoboa.lib import parameters
|
||||
from modoboa.lib.exceptions import InternalError
|
||||
|
||||
|
||||
class LDAPAuthBackend(object):
|
||||
|
||||
def __init__(self):
|
||||
self.server_uri = self._setting(
|
||||
"AUTH_LDAP_SERVER_URI", "ldap://localhost"
|
||||
@@ -102,7 +105,9 @@ class LDAPAuthBackend(object):
|
||||
try:
|
||||
self.connect_to_server(user, password)
|
||||
if self.ldap_ad:
|
||||
newpassword = ('"%s"' % newpassword).encode('utf-16').lstrip('\377\376')
|
||||
newpassword = (
|
||||
('"%s"' % newpassword).encode('utf-16').lstrip('\377\376')
|
||||
)
|
||||
ldif = [(ldap.MOD_REPLACE,
|
||||
self.pwd_attr,
|
||||
self._crypt_password(newpassword))]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from modoboa.lib import parameters
|
||||
|
||||
|
||||
@@ -16,7 +17,7 @@ def get_sort_order(qdict, default, allowed_values=None):
|
||||
sort_order = sort_order[1:]
|
||||
else:
|
||||
sort_dir = ""
|
||||
if allowed_values is not None and not sort_order in allowed_values:
|
||||
if allowed_values is not None and sort_order not in allowed_values:
|
||||
return (default, "")
|
||||
return (sort_order, sort_dir)
|
||||
|
||||
|
||||
@@ -81,7 +81,8 @@ def grant_access_to_objects(user, objects, ct):
|
||||
"""
|
||||
for obj in objects:
|
||||
try:
|
||||
ObjectAccess.objects.create(user=user, content_type=ct, object_id=obj.id)
|
||||
ObjectAccess.objects.create(
|
||||
user=user, content_type=ct, object_id=obj.id)
|
||||
except IntegrityError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
"""
|
||||
Custom signals.
|
||||
"""
|
||||
"""Custom signals."""
|
||||
|
||||
from django.dispatch import Signal
|
||||
|
||||
request_accessor = Signal()
|
||||
|
||||
|
||||
def get_request():
|
||||
"""Get the current request from anywhere.
|
||||
"""
|
||||
"""Get the current request from anywhere."""
|
||||
return request_accessor.send(None)[0][1]
|
||||
|
||||
@@ -63,7 +63,7 @@ def render_fields_group(form, pattern):
|
||||
haserror = len(first.errors) != 0
|
||||
while True:
|
||||
fname = "%s_%d" % (pattern, cpt)
|
||||
if not fname in form.fields:
|
||||
if fname not in form.fields:
|
||||
break
|
||||
bfield = forms.forms.BoundField(form, form.fields[fname], fname)
|
||||
if len(bfield.errors):
|
||||
|
||||
@@ -11,13 +11,14 @@ class ModoTestCase(TestCase):
|
||||
|
||||
def setUp(self, username="admin", password="password"):
|
||||
self.clt = Client()
|
||||
self.assertEqual(self.clt.login(username=username, password=password), True)
|
||||
self.assertEqual(
|
||||
self.clt.login(username=username, password=password), True)
|
||||
|
||||
def ajax_request(self, method, url, params=None, status=200):
|
||||
if params is None:
|
||||
params = {}
|
||||
response = getattr(self.clt, method) \
|
||||
(url, params, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
response = getattr(self.clt, method)(
|
||||
url, params, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, status)
|
||||
return json.loads(response.content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user