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