Skip to content

Commit 8ac600e

Browse files
committed
code clean
1 parent 725fcb3 commit 8ac600e

File tree

4 files changed

+36
-37
lines changed

4 files changed

+36
-37
lines changed

src/concurrency/admin.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def response_action(self, request, queryset): # noqa
107107
for x in selected:
108108
try:
109109
pk, version = x.split(",")
110-
except ValueError:
110+
except ValueError: # pragma: no cover
111111
raise ImproperlyConfigured('`ConcurrencyActionMixin` error.'
112112
'A tuple with `primary_key, version_number` '
113113
'expected: `%s` found' % x)
@@ -255,31 +255,30 @@ class ConcurrentModelAdmin(ConcurrencyActionMixin,
255255
form = ConcurrentForm
256256
formfield_overrides = {forms.VersionField: {'widget': VersionWidget}}
257257

258-
if django.VERSION[:2] >= (1, 11):
259-
def check(self, **kwargs):
260-
errors = []
261-
if self.fields:
262-
version_field = self.model._concurrencymeta.field
263-
if version_field.name not in self.fields:
264-
errors.append(
265-
Error(
266-
'Missed version field in {} fields definition'.format(self),
267-
hint="Please add '{}' to the 'fields' attribute".format(version_field.name),
268-
obj=None,
269-
id='concurrency.A001',
270-
)
258+
def check(self, **kwargs):
259+
errors = []
260+
if self.fields:
261+
version_field = self.model._concurrencymeta.field
262+
if version_field.name not in self.fields:
263+
errors.append(
264+
Error(
265+
'Missed version field in {} fields definition'.format(self),
266+
hint="Please add '{}' to the 'fields' attribute".format(version_field.name),
267+
obj=None,
268+
id='concurrency.A001',
271269
)
272-
if self.fieldsets:
273-
version_field = self.model._concurrencymeta.field
274-
fields = flatten([v['fields'] for k, v in self.fieldsets])
275-
276-
if version_field.name not in fields:
277-
errors.append(
278-
Error(
279-
'Missed version field in {} fieldsets definition'.format(self),
280-
hint="Please add '{}' to the 'fieldsets' attribute".format(version_field.name),
281-
obj=None,
282-
id='concurrency.A002',
283-
)
270+
)
271+
if self.fieldsets:
272+
version_field = self.model._concurrencymeta.field
273+
fields = flatten([v['fields'] for k, v in self.fieldsets])
274+
275+
if version_field.name not in fields:
276+
errors.append(
277+
Error(
278+
'Missed version field in {} fieldsets definition'.format(self),
279+
hint="Please add '{}' to the 'fieldsets' attribute".format(version_field.name),
280+
obj=None,
281+
id='concurrency.A002',
284282
)
285-
return errors
283+
)
284+
return errors

src/concurrency/compat.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, unicode_literals
33

4-
try:
5-
from django.template.base import TemplateDoesNotExist
6-
except ImportError:
7-
from django.template.exceptions import TemplateDoesNotExist # noqa - django 1.9
4+
# try:
5+
# from django.template.base import TemplateDoesNotExist
6+
# except ImportError:
7+
from django.template.exceptions import TemplateDoesNotExist # noqa - django 1.9
88

9-
try:
10-
from django.urls.utils import get_callable
11-
except ImportError:
12-
from django.core.urlresolvers import get_callable # noqa
9+
# try:
10+
from django.urls.utils import get_callable
11+
# except ImportError:
12+
# from django.core.urlresolvers import get_callable # noqa

src/concurrency/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_signer():
7878
raise ImproperlyConfigured('Error loading concurrency signer %s: "%s"' % (module, e))
7979
try:
8080
signer_class = getattr(mod, attr)
81-
except AttributeError:
81+
except AttributeError: # pragma: no cover
8282
raise ImproperlyConfigured('Module "%s" does not define a valid signer named "%s"' % (module, attr))
8383
return signer_class()
8484

src/concurrency/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def get_classname(o):
133133
target = o.__class__
134134
try:
135135
return target.__qualname__
136-
except AttributeError:
136+
except AttributeError: # pragma: no cover
137137
return target.__name__
138138

139139

0 commit comments

Comments
 (0)