Commit 0fa8d43e authored by Ramiro Morales's avatar Ramiro Morales
Browse files

Replaced `and...or...` constructs with PEP 308 conditional expressions.

parent d228c119
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ class RelatedFieldListFilter(FieldListFilter):
            }

FieldListFilter.register(lambda f: (
        hasattr(f, 'rel') and bool(f.rel) or
        bool(f.rel) if hasattr(f, 'rel') else
        isinstance(f, models.related.RelatedObject)), RelatedFieldListFilter)


+2 −2
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ class AdminField(object):
            classes.append('required')
        if not self.is_first:
            classes.append('inline')
        attrs = classes and {'class': ' '.join(classes)} or {}
        attrs = {'class': ' '.join(classes)} if classes else {}
        return self.field.label_tag(contents=mark_safe(contents), attrs=attrs)

    def errors(self):
@@ -144,7 +144,7 @@ class AdminReadonlyField(object):
        # {{ field.name }} must be a useful class name to identify the field.
        # For convenience, store other field-related data here too.
        if callable(field):
            class_name = field.__name__ != '<lambda>' and field.__name__ or ''
            class_name = field.__name__ if field.__name__ != '<lambda>' else ''
        else:
            class_name = field
        self.field = {
+1 −1
Original line number Diff line number Diff line
@@ -53,4 +53,4 @@ def get_admin_log(parser, token):
        if tokens[4] != 'for_user':
            raise template.TemplateSyntaxError(
                "Fourth argument to 'get_admin_log' must be 'for_user'")
    return AdminLogNode(limit=tokens[1], varname=tokens[3], user=(len(tokens) > 5 and tokens[5] or None))
    return AdminLogNode(limit=tokens[1], varname=tokens[3], user=(tokens[5] if len(tokens) > 5 else None))
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ def bookmarklets(request):
    admin_root = urlresolvers.reverse('admin:index')
    return render_to_response('admin_doc/bookmarklets.html', {
        'root_path': admin_root,
        'admin_url': "%s://%s%s" % (request.is_secure() and 'https' or 'http', request.get_host(), admin_root),
        'admin_url': "%s://%s%s" % ('https' if request.is_secure() else 'http', request.get_host(), admin_root),
    }, context_instance=RequestContext(request))

@staff_member_required
@@ -287,7 +287,7 @@ def template_detail(request, template):
            templates.append({
                'file': template_file,
                'exists': os.path.exists(template_file),
                'contents': lambda: os.path.exists(template_file) and open(template_file).read() or '',
                'contents': lambda: open(template_file).read() if os.path.exists(template_file) else '',
                'site_id': settings_mod.SITE_ID,
                'site': site_obj,
                'order': list(settings_mod.TEMPLATE_DIRS).index(dir),
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ class PasswordResetForm(forms.Form):
                'uid': int_to_base36(user.pk),
                'user': user,
                'token': token_generator.make_token(user),
                'protocol': use_https and 'https' or 'http',
                'protocol': 'https' if use_https else 'http',
            }
            subject = loader.render_to_string(subject_template_name, c)
            # Email subject *must not* contain newlines
Loading