Commit 11cd7388 authored by Simon Charette's avatar Simon Charette
Browse files

Fixed #20989 -- Removed useless explicit list comprehensions.

parent e4a67fd9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -287,8 +287,8 @@ FieldListFilter.register(lambda f: bool(f.choices), ChoicesFieldListFilter)
class DateFieldListFilter(FieldListFilter):
    def __init__(self, field, request, params, model, model_admin, field_path):
        self.field_generic = '%s__' % field_path
        self.date_params = dict([(k, v) for k, v in params.items()
                                 if k.startswith(self.field_generic)])
        self.date_params = dict((k, v) for k, v in params.items()
                                if k.startswith(self.field_generic))

        now = timezone.now()
        # When time zone support is enabled, convert "now" to the user's time
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ class Fieldline(object):
                yield AdminField(self.form, field, is_first=(i == 0))

    def errors(self):
        return mark_safe('\n'.join([self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields]).strip('\n'))
        return mark_safe('\n'.join(self.form[f].errors.as_ul() for f in self.fields if f not in self.readonly_fields).strip('\n'))

class AdminField(object):
    def __init__(self, form, field, is_first):
+3 −3
Original line number Diff line number Diff line
@@ -698,16 +698,16 @@ class ModelAdmin(BaseModelAdmin):
            # Avoid trying to iterate over None
            if not class_actions:
                continue
            actions.extend([self.get_action(action) for action in class_actions])
            actions.extend(self.get_action(action) for action in class_actions)

        # get_action might have returned None, so filter any of those out.
        actions = filter(None, actions)

        # Convert the actions into an OrderedDict keyed by name.
        actions = OrderedDict([
        actions = OrderedDict(
            (name, (func, name, desc))
            for func, name, desc in actions
        ])
        )

        return actions

+3 −3
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ def url_params_from_lookup_dict(lookups):
            if callable(v):
                v = v()
            if isinstance(v, (tuple, list)):
                v = ','.join([str(x) for x in v])
                v = ','.join(str(x) for x in v)
            elif isinstance(v, bool):
                # See django.db.fields.BooleanField.get_prep_lookup
                v = ('0', '1')[v]
@@ -154,7 +154,7 @@ class ForeignKeyRawIdWidget(forms.TextInput):

            params = self.url_parameters()
            if params:
                url = '?' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()])
                url = '?' + '&'.join('%s=%s' % (k, v) for k, v in params.items())
            else:
                url = ''
            if "class" not in attrs:
@@ -199,7 +199,7 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
            # The related object is registered with the same AdminSite
            attrs['class'] = 'vManyToManyRawIdAdminField'
        if value:
            value = ','.join([force_text(v) for v in value])
            value = ','.join(force_text(v) for v in value)
        else:
            value = ''
        return super(ManyToManyRawIdWidget, self).render(name, value, attrs)
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ def trim_docstring(docstring):
        return ''
    # Convert tabs to spaces and split into lines
    lines = docstring.expandtabs().splitlines()
    indent = min([len(line) - len(line.lstrip()) for line in lines if line.lstrip()])
    indent = min(len(line) - len(line.lstrip()) for line in lines if line.lstrip())
    trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]]
    return "\n".join(trimmed).strip()

Loading