Show More
@@ -1,31 +1,29 b'' | |||||
1 | #!/usr/bin/python |
|
1 | #!/usr/bin/python | |
2 | # -*- coding: utf-8 -*- |
|
2 | # -*- coding: utf-8 -*- | |
3 | import logging |
|
3 | import logging | |
4 | from operator import itemgetter |
|
4 | from operator import itemgetter | |
5 | from pylons import tmpl_context as c, request, config |
|
5 | from pylons import tmpl_context as c, request, config | |
6 | from pylons_app.lib.base import BaseController, render |
|
6 | from pylons_app.lib.base import BaseController, render | |
7 | from pylons_app.lib.utils import get_repo_slug |
|
|||
8 | from pylons_app.model.hg_model import HgModel |
|
|||
9 | from pylons_app.lib.auth import LoginRequired |
|
7 | from pylons_app.lib.auth import LoginRequired | |
10 | log = logging.getLogger(__name__) |
|
8 | log = logging.getLogger(__name__) | |
11 |
|
9 | |||
12 | class HgController(BaseController): |
|
10 | class HgController(BaseController): | |
13 |
|
11 | |||
14 | @LoginRequired() |
|
12 | @LoginRequired() | |
15 | def __before__(self): |
|
13 | def __before__(self): | |
16 | super(HgController, self).__before__() |
|
14 | super(HgController, self).__before__() | |
17 |
|
15 | |||
18 | def index(self): |
|
16 | def index(self): | |
19 | c.current_sort = request.GET.get('sort', 'name') |
|
17 | c.current_sort = request.GET.get('sort', 'name') | |
20 | cs = c.current_sort |
|
18 | cs = c.current_sort | |
21 | c.cs_slug = cs.replace('-', '') |
|
19 | c.cs_slug = cs.replace('-', '') | |
22 | sortables = ['name', 'description', 'last_change', 'tip', 'contact'] |
|
20 | sortables = ['name', 'description', 'last_change', 'tip', 'contact'] | |
23 |
|
21 | |||
24 | if cs and c.cs_slug in sortables: |
|
22 | if cs and c.cs_slug in sortables: | |
25 | sort_key = c.cs_slug + '_sort' |
|
23 | sort_key = c.cs_slug + '_sort' | |
26 | if cs.startswith('-'): |
|
24 | if cs.startswith('-'): | |
27 | c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), reverse=True) |
|
25 | c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), reverse=True) | |
28 | else: |
|
26 | else: | |
29 | c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), reverse=False) |
|
27 | c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), reverse=False) | |
30 |
|
28 | |||
31 | return render('/index.html') |
|
29 | return render('/index.html') |
General Comments 0
You need to be logged in to leave comments.
Login now