changeset 353:07f50e9b308f

fixed sorting bug.
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 21 Jul 2010 22:53:04 +0200
parents 76f8bef61098
children 7a086a83f00b
files pylons_app/controllers/hg.py
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/controllers/hg.py	Fri Jul 16 14:10:29 2010 +0200
+++ b/pylons_app/controllers/hg.py	Wed Jul 21 22:53:04 2010 +0200
@@ -2,7 +2,7 @@
 # encoding: utf-8
 # hg controller for pylons
 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
- 
+# 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; version 2
@@ -38,19 +38,20 @@
         
     def index(self):
         c.current_sort = request.GET.get('sort', 'name')
-        cs = c.current_sort
+        sort_by = c.current_sort
         sortables = ['name', 'description', 'last_change', 'tip', 'contact']
         
-        if cs not in sortables:
-            cs = 'name'
-        c.cs_slug = cs.replace('-', '')
+        c.cs_slug = sort_by.replace('-', '')
+        
+        if c.cs_slug not in sortables:
+            sort_by = 'name'
         
         cached_repo_list = HgModel().get_repos()
-        if cs and c.cs_slug in sortables:
-            sort_key = c.cs_slug + '_sort'
-            if cs.startswith('-'):
-                c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=True)
-            else:
-                c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=False)
+        
+        sort_key = c.cs_slug + '_sort'
+        if sort_by.startswith('-'):
+            c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=True)
+        else:
+            c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=False)
             
         return render('/index.html')