hg.py
29 lines
| 1.0 KiB
| text/x-python
|
PythonLexer
Marcin Kuzminski
|
r0 | #!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||||
r135 | import logging | |||
r93 | from operator import itemgetter | |||
r135 | from pylons import tmpl_context as c, request, config | |||
Marcin Kuzminski
|
r76 | from pylons_app.lib.base import BaseController, render | ||
r191 | from pylons_app.lib.auth import LoginRequired | |||
Marcin Kuzminski
|
r10 | log = logging.getLogger(__name__) | ||
Marcin Kuzminski
|
r0 | |||
class HgController(BaseController): | ||||
Marcin Kuzminski
|
r21 | |||
r191 | @LoginRequired() | |||
Marcin Kuzminski
|
r21 | def __before__(self): | ||
r191 | super(HgController, self).__before__() | |||
Marcin Kuzminski
|
r82 | |||
Marcin Kuzminski
|
r55 | def index(self): | ||
Marcin Kuzminski
|
r57 | c.current_sort = request.GET.get('sort', 'name') | ||
cs = c.current_sort | ||||
c.cs_slug = cs.replace('-', '') | ||||
sortables = ['name', 'description', 'last_change', 'tip', 'contact'] | ||||
if cs and c.cs_slug in sortables: | ||||
sort_key = c.cs_slug + '_sort' | ||||
if cs.startswith('-'): | ||||
r169 | c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), reverse=True) | |||
Marcin Kuzminski
|
r57 | else: | ||
r169 | c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), reverse=False) | |||
Marcin Kuzminski
|
r57 | |||
Marcin Kuzminski
|
r55 | return render('/index.html') | ||