Repository: translate/pootle

Issue:
Use `collections.OrderedDict` instead of `django.utils.datastructures.SortedDict`
In Django 1.9 [`django.utils.datastructures.SortedDict`](https://docs.djangoproject.com/en/1.7/ref/utils/#django.utils.datastructures.SortedDict) will be removed, it is deprecated in Django 1.7.  Use [`collections.OrderedDict`](https://docs.python.org/3/library/collections.html#collections.OrderedDict) from the Python standard library instead.

The use of `OrderedDict` requires Python 3 compatibility.



Discussion:
> The use of OrderedDict requires Python 3 compatibility.

It doesn't, it was backported to 2.7.

> > The use of OrderedDict requires Python 3 compatibility.
> 
> It doesn't, it was backported to 2.7.

Indeed, [collections.OrderedDict](https://docs.python.org/2/library/collections.html#collections.OrderedDict) on Python 2.7


Resolving patch:
diff --git a/pootle/apps/pootle_app/views/admin/util.py b/pootle/apps/pootle_app/views/admin/util.py
--- a/pootle/apps/pootle_app/views/admin/util.py
+++ b/pootle/apps/pootle_app/views/admin/util.py
@@ -20,7 +20,7 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from django.forms.models import modelformset_factory
-from django.forms.util import ErrorList
+from django.forms.utils import ErrorList
 from django.shortcuts import render
 from django.utils.safestring import mark_safe
 from django.utils.translation import ugettext as _
diff --git a/pootle/apps/pootle_language/models.py b/pootle/apps/pootle_language/models.py
--- a/pootle/apps/pootle_language/models.py
+++ b/pootle/apps/pootle_language/models.py
@@ -19,13 +19,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from collections import OrderedDict
+
 from django.conf import settings
 from django.core.cache import cache
 from django.core.urlresolvers import reverse
 from django.db import models
 from django.db.models.signals import post_delete, post_save
 from django.dispatch import receiver
-from django.utils.datastructures import SortedDict
 from django.utils.translation import ugettext_lazy as _
 
 from pootle.core.mixins import TreeItem
@@ -65,7 +66,7 @@ def get_queryset(self):
     def cached_dict(self):
         languages = cache.get(CACHE_KEY)
         if not languages:
-            languages = SortedDict(
+            languages = OrderedDict(
                 self.order_by('fullname').values_list('code', 'fullname')
             )
             cache.set(CACHE_KEY, languages, settings.OBJECT_CACHE_TIMEOUT)
diff --git a/pootle/apps/pootle_project/models.py b/pootle/apps/pootle_project/models.py
--- a/pootle/apps/pootle_project/models.py
+++ b/pootle/apps/pootle_project/models.py
@@ -22,6 +22,7 @@
 
 import logging
 import os
+from collections import OrderedDict
 
 from django.conf import settings
 from django.contrib.auth import get_user_model
@@ -32,7 +33,6 @@
 from django.db.models import Q
 from django.db.models.signals import post_delete, post_save
 from django.dispatch import receiver
-from django.utils.datastructures import SortedDict
 from django.utils.encoding import iri_to_uri
 from django.utils.functional import cached_property
 from django.utils.translation import ugettext_lazy as _
@@ -75,7 +75,7 @@ def cached_dict(self, user):
         projects = cache.get(cache_key)
         if not projects:
             logging.debug('Cache miss for %s', cache_key)
-            projects = SortedDict(
+            projects = OrderedDict(
                 self.for_user(user).order_by('fullname')
                                    .values_list('code', 'fullname')
             )


Test patch: