##// END OF EJS Templates
fixed bug when, sortables have wrong value
marcink -
r338:1eb2267a default
parent child Browse files
Show More
@@ -1,52 +1,56 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3 # hg controller for pylons
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 5
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; version 2
9 9 # of the License or (at your opinion) any later version of the license.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19 # MA 02110-1301, USA.
20 20 """
21 21 Created on February 18, 2010
22 22 hg controller for pylons
23 23 @author: marcink
24 24 """
25 25 from operator import itemgetter
26 26 from pylons import tmpl_context as c, request
27 27 from pylons_app.lib.auth import LoginRequired
28 28 from pylons_app.lib.base import BaseController, render
29 29 from pylons_app.model.hg_model import HgModel
30 30 import logging
31 31 log = logging.getLogger(__name__)
32 32
33 33 class HgController(BaseController):
34 34
35 35 @LoginRequired()
36 36 def __before__(self):
37 37 super(HgController, self).__before__()
38 38
39 39 def index(self):
40 40 c.current_sort = request.GET.get('sort', 'name')
41 41 cs = c.current_sort
42 sortables = ['name', 'description', 'last_change', 'tip', 'contact']
43
44 if cs not in sortables:
45 cs = 'name'
42 46 c.cs_slug = cs.replace('-', '')
43 sortables = ['name', 'description', 'last_change', 'tip', 'contact']
47
44 48 cached_repo_list = HgModel().get_repos()
45 49 if cs and c.cs_slug in sortables:
46 50 sort_key = c.cs_slug + '_sort'
47 51 if cs.startswith('-'):
48 52 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=True)
49 53 else:
50 54 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=False)
51 55
52 56 return render('/index.html')
General Comments 0
You need to be logged in to leave comments. Login now