annotate rhodecode/controllers/followers.py @ 4186:7e5f8c12a3fc kallithea-2.2.5-rebrand

First step in two-part process to rename directories to kallithea. This first step is to change all references in the files where they refer to the old directory name.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:04:28 -0400
parents ffd45b185016
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1279
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 # This program is free software: you can redistribute it and/or modify
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 # it under the terms of the GNU General Public License as published by
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 # the Free Software Foundation, either version 3 of the License, or
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 # (at your option) any later version.
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 #
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # This program is distributed in the hope that it will be useful,
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 # GNU General Public License for more details.
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 #
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # You should have received a copy of the GNU General Public License
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
14 """
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
15 kallithea.controllers.followers
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
17
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
18 Followers controller for rhodecode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
20 :created_on: Apr 23, 2011
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
21 :author: marcink
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
22 :copyright: (c) 2013 RhodeCode GmbH.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
23 :license: GPLv3, see LICENSE for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
24 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
25
1279
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 import logging
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 from pylons import tmpl_context as c, request
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
30 from kallithea.lib.helpers import Page
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
31 from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
32 from kallithea.lib.base import BaseRepoController, render
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
33 from kallithea.model.db import Repository, User, UserFollowing
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
34 from kallithea.lib.utils2 import safe_int
1279
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 log = logging.getLogger(__name__)
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 class FollowersController(BaseRepoController):
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3745
diff changeset
41 def __before__(self):
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3745
diff changeset
42 super(FollowersController, self).__before__()
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 3745
diff changeset
43
1279
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 @LoginRequired()
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 'repository.admin')
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 def followers(self, repo_name):
3745
7efc8dcc0dc4 usage of request.GET is now more consistent
Marcin Kuzminski <marcin@python-works.com>
parents: 2845
diff changeset
48 p = safe_int(request.GET.get('page', 1), 1)
1375
f9559677c953 added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents: 1301
diff changeset
49 repo_id = c.rhodecode_db_repo.repo_id
1279
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 d = UserFollowing.get_repo_followers(repo_id)\
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 .order_by(UserFollowing.follows_from)
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 c.followers_pager = Page(d, page=p, items_per_page=20)
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 c.followers_data = render('/followers/followers_data.html')
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55
1421
c6b811f11c94 Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents: 1375
diff changeset
56 if request.environ.get('HTTP_X_PARTIAL_XHR'):
1279
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 return c.followers_data
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58
cb216757a62d #179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 return render('/followers/followers.html')