annotate kallithea/controllers/followers.py @ 4208:ad38f9f93b3b kallithea-2.2.5-rebrand

Correct licensing information in individual files. The top-level license file is now LICENSE.md. Also, in various places where there should have been joint copyright holders listed, a single copyright holder was listed. It does not appear easy to add a link to a large list of copyright holders in these places, so it simply refers to the fact that various authors hold copyright. In future, if an easy method is discovered to link to a list from those places, we should do so. Finally, text is added to LICENSE.md to point to where the full list of copyright holders is, and that Kallithea as a whole is GPLv3'd.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 21 May 2014 16:59:37 -0400
parents 9581233e9275
children 1948ede028ef
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.
4208
ad38f9f93b3b Correct licensing information in individual files.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4195
diff changeset
23 :license: GPLv3, see LICENSE.md for more details.
4116
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)
4195
9581233e9275 Rename rhodecode_db_repo to db_repo - it stores db repo abstractions
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4187
diff changeset
49 repo_id = c.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')