[debexpo-devel] [PATCH] Fix the country list in /my

Andrey Rahmatullin wrar at wrar.name
Tue Nov 9 17:55:32 CET 2010


Properly display the country list, with database ids and in the alphabetical
order.

Signed-off-by: Andrey Rahmatullin <wrar at wrar.name>
---
 debexpo/controllers/my.py       |    4 ++--
 debexpo/templates/my/index.mako |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/debexpo/controllers/my.py b/debexpo/controllers/my.py
index 4bfbb8c..819004b 100644
--- a/debexpo/controllers/my.py
+++ b/debexpo/controllers/my.py
@@ -189,10 +189,10 @@ class MyController(BaseController):
         c.user = self.user
 
         # Create the countries values.
-        countries = { '' : -1 }
+        countries = { -1: '' }
 
         for country in meta.session.query(UserCountry).all():
-            countries[country.name] = country.id
+            countries[country.id] = country.name
 
         c.countries = countries
 
diff --git a/debexpo/templates/my/index.mako b/debexpo/templates/my/index.mako
index 54fb76d..570e9bf 100644
--- a/debexpo/templates/my/index.mako
+++ b/debexpo/templates/my/index.mako
@@ -110,7 +110,7 @@
   <table>
     <tr>
       <td>${ _('Country') }:</td>
-      <td>${ h.html.tags.select('country', c.current_country, c.countries) }</td>
+      <td>${ h.html.tags.select('country', c.current_country, sorted(c.countries.iteritems(), key=lambda x: x[1])) }</td>
     </tr>
 
     <tr>
-- 
1.7.2.3



More information about the debexpo-devel mailing list