Mercurial > kallithea
annotate rhodecode/controllers/followers.py @ 2501:044c31d67ccc beta
make get_action always return action
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 21 Jun 2012 17:51:01 +0200 |
parents | 89efedac4e6c |
children | 6b176c679896 |
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 """ |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.controllers.followers |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 Followers controller for rhodecode |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: Apr 23, 2011 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
10 :copyright: (C) 2011-2012 Marcin Kuzminski <marcin@python-works.com> |
1279
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # 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
|
14 # 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
|
15 # 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
|
16 # (at your option) any later version. |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # 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
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # 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
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 import logging |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 from pylons import tmpl_context as c, request |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 from rhodecode.lib.helpers import Page |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 from rhodecode.lib.base import BaseRepoController, render |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 from rhodecode.model.db import Repository, User, UserFollowing |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 log = logging.getLogger(__name__) |
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 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 class FollowersController(BaseRepoController): |
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 @LoginRequired() |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 'repository.admin') |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 def __before__(self): |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 super(FollowersController, self).__before__() |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 def followers(self, repo_name): |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 p = int(request.params.get('page', 1)) |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
1301
diff
changeset
|
47 repo_id = c.rhodecode_db_repo.repo_id |
1279
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 d = UserFollowing.get_repo_followers(repo_id)\ |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 .order_by(UserFollowing.follows_from) |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 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
|
51 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 c.followers_data = render('/followers/followers_data.html') |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 |
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
|
54 if request.environ.get('HTTP_X_PARTIAL_XHR'): |
1279
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 return c.followers_data |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 |
cb216757a62d
#179 Added followers page
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 return render('/followers/followers.html') |