mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-03-16 22:20:24 +00:00
Fix flake8 errors
This commit is contained in:
parent
f5701e5c15
commit
f3ff443373
15 changed files with 41 additions and 41 deletions
6
.eggs/README.txt
Normal file
6
.eggs/README.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
|
||||
|
||||
This directory caches those eggs to prevent repeated downloads.
|
||||
|
||||
However, it is safe to delete this directory.
|
||||
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import division, absolute_import, unicode_literals
|
||||
from . import core
|
||||
from . import types
|
||||
|
||||
__version__ = '0.6.1'
|
||||
|
||||
|
|
@ -10,10 +12,6 @@ VERSION = __version__ # synonym
|
|||
# Default datetime input and output formats
|
||||
ISO_8601 = 'iso-8601'
|
||||
|
||||
from . import core
|
||||
from . import types
|
||||
|
||||
|
||||
default = core.Admin2()
|
||||
ModelAdmin2 = types.ModelAdmin2
|
||||
Admin2TabularInline = types.Admin2TabularInline
|
||||
|
|
|
|||
|
|
@ -169,7 +169,6 @@ class DeleteSelectedAction(BaseListAction):
|
|||
# objects, so render a template asking for their confirmation.
|
||||
return self.get(request)
|
||||
|
||||
|
||||
def process_queryset(self):
|
||||
# The user has confirmed that they want to delete the objects.
|
||||
self.get_queryset().delete()
|
||||
|
|
|
|||
|
|
@ -208,4 +208,3 @@ class Admin2(object):
|
|||
def urls(self):
|
||||
# We set the application and instance namespace here
|
||||
return self.get_urls(), self.name, self.name
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import collections
|
|||
from itertools import chain
|
||||
|
||||
from django import forms
|
||||
from django.forms.util import flatatt
|
||||
from django.forms.utils import flatatt
|
||||
from django.utils.html import format_html
|
||||
from django.utils.encoding import force_text, force_bytes
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.forms import widgets as django_widgets
|
||||
from django.utils import six
|
||||
|
|
@ -97,7 +97,7 @@ def build_list_filter(request, model_admin, queryset):
|
|||
'fields': fields,
|
||||
},
|
||||
)
|
||||
return type(type_str('%sFilterSet' % queryset.model.__name__),(django_filters.FilterSet, ),filterset_dict,)(request.GET, queryset=queryset)
|
||||
return type(type_str('%sFilterSet' % queryset.model.__name__), (django_filters.FilterSet, ), filterset_dict,)(request.GET, queryset=queryset)
|
||||
|
||||
|
||||
def build_date_filter(request, model_admin, queryset, field_name="published_date"):
|
||||
|
|
|
|||
|
|
@ -166,9 +166,7 @@ _django_to_floppyforms_widget = {
|
|||
django.forms.extras.widgets.SelectDateWidget:
|
||||
_create_widget(
|
||||
floppyforms.widgets.SelectDateWidget,
|
||||
init_arguments=
|
||||
('years',)
|
||||
if django.VERSION >= (1, 7) else ('years', 'required')),
|
||||
init_arguments=('years',) if django.VERSION >= (1, 7) else ('years', 'required')),
|
||||
}
|
||||
|
||||
_django_field_to_floppyform_widget = {
|
||||
|
|
@ -272,8 +270,10 @@ def modelform_factory(model, form=django.forms.models.ModelForm, fields=None,
|
|||
|
||||
# Translators : %(username)s will be replaced by the username_field name
|
||||
# (default : username, but could be email, or something else)
|
||||
ERROR_MESSAGE = ugettext_lazy("Please enter the correct %(username)s and password "
|
||||
"for a staff account. Note that both fields may be case-sensitive.")
|
||||
ERROR_MESSAGE = ugettext_lazy(
|
||||
"Please enter the correct %(username)s and password "
|
||||
"for a staff account. Note that both fields may be case-sensitive."
|
||||
)
|
||||
|
||||
|
||||
class AdminAuthenticationForm(AuthenticationForm):
|
||||
|
|
@ -285,8 +285,11 @@ class AdminAuthenticationForm(AuthenticationForm):
|
|||
error_messages = {
|
||||
'required': ugettext_lazy("Please log in again, because your session has expired."),
|
||||
}
|
||||
this_is_the_login_form = django.forms.BooleanField(widget=floppyforms.HiddenInput,
|
||||
initial=1, error_messages=error_messages)
|
||||
this_is_the_login_form = django.forms.BooleanField(
|
||||
widget=floppyforms.HiddenInput,
|
||||
initial=1,
|
||||
error_messages=error_messages
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
username = self.cleaned_data.get('username')
|
||||
|
|
|
|||
|
|
@ -82,13 +82,13 @@ def model_permission(permission):
|
|||
assert model_class, (
|
||||
'Cannot apply model permissions on a view that does not '
|
||||
'have a `.model` or `.queryset` property.')
|
||||
|
||||
|
||||
try:
|
||||
# django 1.8+
|
||||
model_name = model_class._meta.model_name
|
||||
except AttributeError:
|
||||
model_name = model_class._meta.module_name
|
||||
|
||||
|
||||
permission_name = permission.format(
|
||||
app_label=model_class._meta.app_label,
|
||||
model_name=model_name)
|
||||
|
|
@ -363,7 +363,6 @@ class TemplatePermissionChecker(object):
|
|||
else:
|
||||
return self._view.has_permission(self._obj)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
if self._view is None:
|
||||
return ''
|
||||
|
|
|
|||
|
|
@ -26,24 +26,24 @@ class ActionTest(TestCase):
|
|||
self.admin2.registry[Thing].list_actions.extend([
|
||||
TestAction,
|
||||
test_function,
|
||||
])
|
||||
])
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[0]
|
||||
),
|
||||
),
|
||||
'Delete selected items'
|
||||
)
|
||||
)
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[1]
|
||||
),
|
||||
),
|
||||
'Test Action Class'
|
||||
)
|
||||
)
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[2]
|
||||
),
|
||||
),
|
||||
'Test function'
|
||||
)
|
||||
)
|
||||
self.admin2.registry[Thing].list_actions.remove(TestAction)
|
||||
self.admin2.registry[Thing].list_actions.remove(test_function)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class TagsTests(TestCase):
|
|||
self.assertEquals(
|
||||
admin2_tags.formset_visible_fieldlist(formset),
|
||||
[u'Visible 1', u'Visible 2']
|
||||
)
|
||||
)
|
||||
|
||||
def test_verbose_name_for(self):
|
||||
app_verbose_names = {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class NumberRendererTest(TestCase):
|
|||
self.assertEqual('42.5', out)
|
||||
|
||||
def testEndlessFloat(self):
|
||||
out = self.renderer(1.0/3, None)
|
||||
out = self.renderer(1.0 / 3, None)
|
||||
if six.PY2:
|
||||
self.assertEqual('0.333333333333', out)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from django.db import models
|
||||
from django.test import TestCase
|
||||
from django.views.generic import View
|
||||
|
||||
from .. import views
|
||||
from ..types import ModelAdmin2, immutable_admin_factory
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class UtilsTest(TestCase):
|
|||
self.assertEquals(
|
||||
UtilsTestModel._meta,
|
||||
utils.model_options(UtilsTestModel)
|
||||
)
|
||||
)
|
||||
UtilsTestModel._meta.verbose_name = "Utils Test Model"
|
||||
UtilsTestModel._meta.verbose_name_plural = "Utils Test Models"
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class UtilsTest(TestCase):
|
|||
self.assertEquals(
|
||||
self.instance._meta,
|
||||
utils.model_options(self.instance)
|
||||
)
|
||||
)
|
||||
self.instance._meta.verbose_name = "Utils Test Model"
|
||||
self.instance._meta.verbose_name_plural = "Utils Test Models"
|
||||
|
||||
|
|
@ -166,8 +166,6 @@ class UtilsTest(TestCase):
|
|||
"str"
|
||||
)
|
||||
|
||||
|
||||
|
||||
def test_get_attr(self):
|
||||
class Klass(object):
|
||||
attr = "value"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from django.test import TestCase
|
||||
from django.views.generic import View
|
||||
|
||||
from .. import views
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from django.db.models.fields.related import ForeignObjectRel
|
|||
from django.utils import six
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
|
||||
|
||||
def lookup_needs_distinct(opts, lookup_path):
|
||||
"""
|
||||
Returns True if 'distinct()' should be used to query the given lookup path.
|
||||
|
|
@ -91,10 +92,8 @@ def get_attr(obj, attr):
|
|||
and the __str__ attribute.
|
||||
"""
|
||||
if attr == '__str__':
|
||||
if six.PY2:
|
||||
value = unicode(obj)
|
||||
else:
|
||||
value = str(obj)
|
||||
from builtins import str as text
|
||||
value = text(obj)
|
||||
else:
|
||||
attribute = getattr(obj, attr)
|
||||
value = attribute() if callable(attribute) else attribute
|
||||
|
|
@ -109,7 +108,6 @@ class NestedObjects(Collector):
|
|||
https://github.com/django/django/blob/1.8c1/django/contrib/admin/utils.py#L160-L221
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NestedObjects, self).__init__(*args, **kwargs)
|
||||
self.edges = {} # {from_instance: [to_instances]}
|
||||
|
|
@ -199,4 +197,4 @@ def type_str(text):
|
|||
if six.PY2:
|
||||
return force_bytes(text)
|
||||
else:
|
||||
return force_text(text)
|
||||
return force_text(text)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ from .viewmixins import Admin2Mixin, AdminModel2Mixin, Admin2ModelFormMixin
|
|||
from .filters import build_list_filter, build_date_filter
|
||||
from .models import LogEntry
|
||||
|
||||
|
||||
class AdminView(object):
|
||||
|
||||
def __init__(self, url, view, name=None):
|
||||
|
|
@ -462,7 +463,7 @@ class ModelDeleteView(AdminModel2Mixin, generic.DeleteView):
|
|||
opts = utils.model_options(obj)
|
||||
return '%s: %s' % (force_text(capfirst(opts.verbose_name)),
|
||||
force_text(obj))
|
||||
|
||||
|
||||
using = router.db_for_write(self.get_object()._meta.model)
|
||||
collector = utils.NestedObjects(using=using)
|
||||
collector.collect([self.get_object()])
|
||||
|
|
@ -542,6 +543,7 @@ class PasswordChangeView(Admin2Mixin, generic.UpdateView):
|
|||
from django.contrib.auth import get_user_model
|
||||
return get_user_model()._default_manager.all()
|
||||
|
||||
|
||||
class PasswordChangeDoneView(Admin2Mixin, generic.TemplateView):
|
||||
|
||||
default_template_name = 'auth/password_change_done.html'
|
||||
|
|
|
|||
Loading…
Reference in a new issue