comparison rhodecode/controllers/home.py @ 636:ffd07396d315 beta

Fixes for raw_id, needed for git Renamed hg controller to home css html changes
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 26 Oct 2010 03:20:32 +0200
parents rhodecode/controllers/hg.py@7e536d1af60d
children 7486da5f0628
comparison
equal deleted inserted replaced
635:fd63782c4426 636:ffd07396d315
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # hg controller for pylons
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
9 # of the License or (at your opinion) any later version of the license.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
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
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 """
21 Created on February 18, 2010
22 hg controller for pylons
23 @author: marcink
24 """
25 from operator import itemgetter
26 from pylons import tmpl_context as c, request
27 from rhodecode.lib.auth import LoginRequired
28 from rhodecode.lib.base import BaseController, render
29 from rhodecode.model.hg import HgModel
30 import logging
31 log = logging.getLogger(__name__)
32
33 class HomeController(BaseController):
34
35 @LoginRequired()
36 def __before__(self):
37 super(HomeController, self).__before__()
38
39 def index(self):
40 sortables = ['name', 'description', 'last_change', 'tip', 'contact']
41 current_sort = request.GET.get('sort', 'name')
42 current_sort_slug = current_sort.replace('-', '')
43
44 if current_sort_slug not in sortables:
45 c.sort_by = 'name'
46 current_sort_slug = c.sort_by
47 else:
48 c.sort_by = current_sort
49 c.sort_slug = current_sort_slug
50 cached_repo_list = HgModel().get_repos()
51
52 sort_key = current_sort_slug + '_sort'
53 if c.sort_by.startswith('-'):
54 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=True)
55 else:
56 c.repos_list = sorted(cached_repo_list, key=itemgetter(sort_key), reverse=False)
57
58 return render('/index.html')