Commit 07876cf0 authored by Curtis Maloney's avatar Curtis Maloney Committed by Tim Graham
Browse files

Deprecated SortedDict (replaced with collections.OrderedDict)

Thanks Loic Bistuer for the review.
parent b278f747
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
from collections import OrderedDict
import copy
import operator
from functools import partial, reduce, update_wrapper
@@ -29,7 +30,6 @@ from django.http.response import HttpResponseBase
from django.shortcuts import get_object_or_404
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.utils.decorators import method_decorator
from django.utils.datastructures import SortedDict
from django.utils.html import escape, escapejs
from django.utils.safestring import mark_safe
from django.utils import six
@@ -672,7 +672,7 @@ class ModelAdmin(BaseModelAdmin):
        # want *any* actions enabled on this page.
        from django.contrib.admin.views.main import _is_changelist_popup
        if self.actions is None or _is_changelist_popup(request):
            return SortedDict()
            return OrderedDict()

        actions = []

@@ -693,8 +693,8 @@ class ModelAdmin(BaseModelAdmin):
        # get_action might have returned None, so filter any of those out.
        actions = filter(None, actions)

        # Convert the actions into a SortedDict keyed by name.
        actions = SortedDict([
        # Convert the actions into an OrderedDict keyed by name.
        actions = OrderedDict([
            (name, (func, name, desc))
            for func, name, desc in actions
        ])
+3 −3
Original line number Diff line number Diff line
from collections import OrderedDict
import sys
import warnings

@@ -7,7 +8,6 @@ from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.utils import six
from django.utils.datastructures import SortedDict
from django.utils.deprecation import RenameMethodsBase
from django.utils.encoding import force_str, force_text
from django.utils.translation import ugettext, ugettext_lazy
@@ -319,13 +319,13 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)):

    def get_ordering_field_columns(self):
        """
        Returns a SortedDict of ordering field column numbers and asc/desc
        Returns an OrderedDict of ordering field column numbers and asc/desc
        """

        # We must cope with more than one column having the same underlying sort
        # field, so we base things on column numbers.
        ordering = self._get_default_ordering()
        ordering_fields = SortedDict()
        ordering_fields = OrderedDict()
        if ORDER_VAR not in self.params:
            # for ordering specified on ModelAdmin or model Meta, we don't know
            # the right column numbers absolutely, because there might be more
+3 −2
Original line number Diff line number Diff line
from __future__ import unicode_literals

from collections import OrderedDict

from django import forms
from django.forms.util import flatatt
from django.template import loader
from django.utils.datastructures import SortedDict
from django.utils.encoding import force_bytes
from django.utils.html import format_html, format_html_join
from django.utils.http import urlsafe_base64_encode
@@ -324,7 +325,7 @@ class PasswordChangeForm(SetPasswordForm):
            )
        return old_password

PasswordChangeForm.base_fields = SortedDict([
PasswordChangeForm.base_fields = OrderedDict([
    (k, PasswordChangeForm.base_fields[k])
    for k in ['old_password', 'new_password1', 'new_password2']
])
+8 −8
Original line number Diff line number Diff line
@@ -2,13 +2,13 @@ from __future__ import unicode_literals

import base64
import binascii
from collections import OrderedDict
import hashlib
import importlib

from django.dispatch import receiver
from django.conf import settings
from django.test.signals import setting_changed
from django.utils.datastructures import SortedDict
from django.utils.encoding import force_bytes, force_str, force_text
from django.core.exceptions import ImproperlyConfigured
from django.utils.crypto import (
@@ -243,7 +243,7 @@ class PBKDF2PasswordHasher(BasePasswordHasher):
    def safe_summary(self, encoded):
        algorithm, iterations, salt, hash = encoded.split('$', 3)
        assert algorithm == self.algorithm
        return SortedDict([
        return OrderedDict([
            (_('algorithm'), algorithm),
            (_('iterations'), iterations),
            (_('salt'), mask_hash(salt)),
@@ -320,7 +320,7 @@ class BCryptSHA256PasswordHasher(BasePasswordHasher):
        algorithm, empty, algostr, work_factor, data = encoded.split('$', 4)
        assert algorithm == self.algorithm
        salt, checksum = data[:22], data[22:]
        return SortedDict([
        return OrderedDict([
            (_('algorithm'), algorithm),
            (_('work factor'), work_factor),
            (_('salt'), mask_hash(salt)),
@@ -368,7 +368,7 @@ class SHA1PasswordHasher(BasePasswordHasher):
    def safe_summary(self, encoded):
        algorithm, salt, hash = encoded.split('$', 2)
        assert algorithm == self.algorithm
        return SortedDict([
        return OrderedDict([
            (_('algorithm'), algorithm),
            (_('salt'), mask_hash(salt, show=2)),
            (_('hash'), mask_hash(hash)),
@@ -396,7 +396,7 @@ class MD5PasswordHasher(BasePasswordHasher):
    def safe_summary(self, encoded):
        algorithm, salt, hash = encoded.split('$', 2)
        assert algorithm == self.algorithm
        return SortedDict([
        return OrderedDict([
            (_('algorithm'), algorithm),
            (_('salt'), mask_hash(salt, show=2)),
            (_('hash'), mask_hash(hash)),
@@ -429,7 +429,7 @@ class UnsaltedSHA1PasswordHasher(BasePasswordHasher):
    def safe_summary(self, encoded):
        assert encoded.startswith('sha1$$')
        hash = encoded[6:]
        return SortedDict([
        return OrderedDict([
            (_('algorithm'), self.algorithm),
            (_('hash'), mask_hash(hash)),
        ])
@@ -462,7 +462,7 @@ class UnsaltedMD5PasswordHasher(BasePasswordHasher):
        return constant_time_compare(encoded, encoded_2)

    def safe_summary(self, encoded):
        return SortedDict([
        return OrderedDict([
            (_('algorithm'), self.algorithm),
            (_('hash'), mask_hash(encoded, show=3)),
        ])
@@ -496,7 +496,7 @@ class CryptPasswordHasher(BasePasswordHasher):
    def safe_summary(self, encoded):
        algorithm, salt, data = encoded.split('$', 2)
        assert algorithm == self.algorithm
        return SortedDict([
        return OrderedDict([
            (_('algorithm'), algorithm),
            (_('salt'), salt),
            (_('hash'), mask_hash(data, show=3)),
+11 −9
Original line number Diff line number Diff line
from collections import OrderedDict
import re

from django import forms
@@ -5,7 +6,6 @@ from django.shortcuts import redirect
from django.core.urlresolvers import reverse
from django.forms import formsets, ValidationError
from django.views.generic import TemplateView
from django.utils.datastructures import SortedDict
from django.utils.decorators import classonlymethod
from django.utils.translation import ugettext as _
from django.utils import six
@@ -158,7 +158,7 @@ class WizardView(TemplateView):
        form_list = form_list or kwargs.pop('form_list',
            getattr(cls, 'form_list', None)) or []

        computed_form_list = SortedDict()
        computed_form_list = OrderedDict()

        assert len(form_list) > 0, 'at least one form is needed'

@@ -206,7 +206,7 @@ class WizardView(TemplateView):
        The form_list is always generated on the fly because condition methods
        could use data from other (maybe previous forms).
        """
        form_list = SortedDict()
        form_list = OrderedDict()
        for form_key, form_class in six.iteritems(self.form_list):
            # try to fetch the value from condition list, by default, the form
            # gets passed to the new list.
@@ -498,9 +498,10 @@ class WizardView(TemplateView):
        if step is None:
            step = self.steps.current
        form_list = self.get_form_list()
        key = form_list.keyOrder.index(step) + 1
        if len(form_list.keyOrder) > key:
            return form_list.keyOrder[key]
        keys = list(form_list.keys())
        key = keys.index(step) + 1
        if len(keys) > key:
            return keys[key]
        return None

    def get_prev_step(self, step=None):
@@ -512,9 +513,10 @@ class WizardView(TemplateView):
        if step is None:
            step = self.steps.current
        form_list = self.get_form_list()
        key = form_list.keyOrder.index(step) - 1
        keys = list(form_list.keys())
        key = keys.index(step) - 1
        if key >= 0:
            return form_list.keyOrder[key]
            return keys[key]
        return None

    def get_step_index(self, step=None):
@@ -524,7 +526,7 @@ class WizardView(TemplateView):
        """
        if step is None:
            step = self.steps.current
        return self.get_form_list().keyOrder.index(step)
        return list(self.get_form_list().keys()).index(step)

    def get_context_data(self, form, **kwargs):
        """
Loading