annotate rhodecode/controllers/forks.py @ 1301:7e75af301842 beta

Added simple forks page, resolves issue #179
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 02 May 2011 13:02:58 +0200
parents
children f9559677c953
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1301
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 """
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 rhodecode.controllers.forks
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 forks controller for rhodecode
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 :created_on: Apr 23, 2011
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :author: marcink
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 :license: GPLv3, see COPYING for more details.
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 """
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # This program is free software: you can redistribute it and/or modify
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # it under the terms of the GNU General Public License as published by
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 # the Free Software Foundation, either version 3 of the License, or
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # (at your option) any later version.
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 #
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # This program is distributed in the hope that it will be useful,
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 # GNU General Public License for more details.
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 #
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 # You should have received a copy of the GNU General Public License
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 import logging
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 from pylons import tmpl_context as c, request
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 from rhodecode.lib.helpers import Page
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 from rhodecode.lib.base import BaseRepoController, render
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 from rhodecode.model.db import Repository, User, UserFollowing
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 log = logging.getLogger(__name__)
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 class ForksController(BaseRepoController):
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 @LoginRequired()
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 'repository.admin')
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 def __before__(self):
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 super(ForksController, self).__before__()
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 def forks(self, repo_name):
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 p = int(request.params.get('page', 1))
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 repo_id = Repository.by_repo_name(repo_name).repo_id
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 d = Repository.get_repo_forks(repo_id)
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 c.forks_pager = Page(d, page=p, items_per_page=20)
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 c.forks_data = render('/forks/forks_data.html')
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 if request.params.get('partial'):
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 return c.forks_data
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55
7e75af301842 Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 return render('/forks/forks.html')