[damned-lies] Sort domain by name in statistics



commit 6a398d0787da4b1de7c870754ec19092d316f7e9
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Sep 5 18:49:17 2009 +0200

    Sort domain by name in statistics

 stats/models.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 5bcc5f6..31c0ead 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -26,6 +26,7 @@ from datetime import datetime
 from django.conf import settings
 from django.utils.translation import ungettext, ugettext as _, ugettext_noop
 from django.utils import dateformat
+from django.utils.datastructures import SortedDict
 from django.db import models, connection
 
 from stats import utils, signals
@@ -244,8 +245,10 @@ class Branch(models.Model):
                      'po-tips': [potstat, polang1, polang2, ...]}
             mandatory_langs is a list of language objects whose stats should be added even if no translation exists.
         """
-        stats = {}; stats_langs = {}
-        pot_stats = Statistics.objects.select_related("language", "domain", "branch").filter(branch=self, language__isnull=True, domain__dtype=typ)
+        stats = SortedDict(); stats_langs = {}
+        pot_stats = Statistics.objects.select_related("language", "domain", "branch"
+                        ).filter(branch=self, language__isnull=True, domain__dtype=typ
+                        ).order_by('domain__name')
         for stat in pot_stats.all():
             stats[stat.domain.name] = [stat,]
             stats_langs[stat.domain.name] = []



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]