Fixed #28907 -- Removed unnecessary if statements.

This commit is contained in:
Tim Graham 2017-12-07 17:12:00 -05:00 committed by GitHub
parent c6864a01b2
commit 02d9419fe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 45 deletions

View File

@ -104,7 +104,6 @@ class ChangeList:
raise DisallowedModelAdminLookup("Filtering by %s not allowed" % key)
filter_specs = []
if self.list_filter:
for list_filter in self.list_filter:
if callable(list_filter):
# This is simply a custom list filter class.
@ -116,8 +115,8 @@ class ChangeList:
field, field_list_filter_class = list_filter
else:
# This is simply a field name, so use the default
# FieldListFilter class that has been registered for
# the type of the given field.
# FieldListFilter class that has been registered for the
# type of the given field.
field, field_list_filter_class = list_filter, FieldListFilter.create
if not isinstance(field, models.Field):
field_path = field
@ -126,11 +125,11 @@ class ChangeList:
lookup_params_count = len(lookup_params)
spec = field_list_filter_class(
field, request, lookup_params,
self.model, self.model_admin, field_path=field_path
self.model, self.model_admin, field_path=field_path,
)
# field_list_filter_class removes any lookup_params it
# processes. If that happened, check if distinct() is
# needed to remove duplicate results.
# processes. If that happened, check if distinct() is needed to
# remove duplicate results.
if lookup_params_count > len(lookup_params):
use_distinct = use_distinct or lookup_needs_distinct(self.lookup_opts, field_path)
if spec and spec.has_output():

View File

@ -62,7 +62,6 @@ class ModelIterable(BaseIterable):
related_populators = get_related_populators(klass_info, select, db)
for row in compiler.results_iter(results):
obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
if related_populators:
for rel_populator in related_populators:
rel_populator.populate(row, obj)
if annotation_col_map:
@ -1771,7 +1770,6 @@ class RelatedPopulator:
obj = None
else:
obj = self.model_cls.from_db(self.db, self.init_list, obj_data)
if self.related_populators:
for rel_iter in self.related_populators:
rel_iter.populate(row, obj)
self.local_setter(from_obj, obj)

View File

@ -1363,7 +1363,6 @@ def url(parser, token):
asvar = bits[-1]
bits = bits[:-2]
if bits:
for bit in bits:
match = kwarg_re.match(bit)
if not match: