Show More
@@ -0,0 +1,13 b'' | |||||
|
1 | from rhodecode.tests import * | |||
|
2 | ||||
|
3 | class TestFollowersController(TestController): | |||
|
4 | ||||
|
5 | def test_index(self): | |||
|
6 | self.log_user() | |||
|
7 | repo_name = HG_REPO | |||
|
8 | response = self.app.get(url(controller='followers', | |||
|
9 | action='followers', | |||
|
10 | repo_name=repo_name)) | |||
|
11 | ||||
|
12 | self.assertTrue("""test_admin""" in response.body) | |||
|
13 | self.assertTrue("""Started following""" in response.body) |
@@ -0,0 +1,41 b'' | |||||
|
1 | from rhodecode.tests import * | |||
|
2 | ||||
|
3 | from rhodecode.model.db import Repository | |||
|
4 | ||||
|
5 | class TestForksController(TestController): | |||
|
6 | ||||
|
7 | def test_index(self): | |||
|
8 | self.log_user() | |||
|
9 | repo_name = HG_REPO | |||
|
10 | response = self.app.get(url(controller='forks', action='forks', | |||
|
11 | repo_name=repo_name)) | |||
|
12 | ||||
|
13 | self.assertTrue("""There are no forks yet""" in response.body) | |||
|
14 | ||||
|
15 | ||||
|
16 | def test_index_with_fork(self): | |||
|
17 | self.log_user() | |||
|
18 | ||||
|
19 | # create a fork | |||
|
20 | fork_name = HG_FORK | |||
|
21 | description = 'fork of vcs test' | |||
|
22 | repo_name = HG_REPO | |||
|
23 | response = self.app.post(url(controller='settings', | |||
|
24 | action='fork_create', | |||
|
25 | repo_name=repo_name), | |||
|
26 | {'fork_name':fork_name, | |||
|
27 | 'repo_type':'hg', | |||
|
28 | 'description':description, | |||
|
29 | 'private':'False'}) | |||
|
30 | ||||
|
31 | response = self.app.get(url(controller='forks', action='forks', | |||
|
32 | repo_name=repo_name)) | |||
|
33 | ||||
|
34 | ||||
|
35 | self.assertTrue("""<a href="/%s/summary">""" | |||
|
36 | """vcs_test_hg_fork</a>""" % fork_name | |||
|
37 | in response.body) | |||
|
38 | ||||
|
39 | #remove this fork | |||
|
40 | response = self.app.delete(url('repo', repo_name=fork_name)) | |||
|
41 |
@@ -1,57 +1,57 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.controllers.followers |
|
3 | rhodecode.controllers.followers | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | Followers controller for rhodecode |
|
6 | Followers controller for rhodecode | |
7 |
|
7 | |||
8 | :created_on: Apr 23, 2011 |
|
8 | :created_on: Apr 23, 2011 | |
9 | :author: marcink |
|
9 | :author: marcink | |
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | |
11 | :license: GPLv3, see COPYING for more details. |
|
11 | :license: GPLv3, see COPYING for more details. | |
12 | """ |
|
12 | """ | |
13 | # This program is free software: you can redistribute it and/or modify |
|
13 | # This program is free software: you can redistribute it and/or modify | |
14 | # it under the terms of the GNU General Public License as published by |
|
14 | # it under the terms of the GNU General Public License as published by | |
15 | # the Free Software Foundation, either version 3 of the License, or |
|
15 | # the Free Software Foundation, either version 3 of the License, or | |
16 | # (at your option) any later version. |
|
16 | # (at your option) any later version. | |
17 | # |
|
17 | # | |
18 | # This program is distributed in the hope that it will be useful, |
|
18 | # This program is distributed in the hope that it will be useful, | |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | # GNU General Public License for more details. |
|
21 | # GNU General Public License for more details. | |
22 | # |
|
22 | # | |
23 | # You should have received a copy of the GNU General Public License |
|
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 | import logging |
|
25 | import logging | |
26 |
|
26 | |||
27 | from pylons import tmpl_context as c, request |
|
27 | from pylons import tmpl_context as c, request | |
28 |
|
28 | |||
29 | from rhodecode.lib.helpers import Page |
|
29 | from rhodecode.lib.helpers import Page | |
30 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
30 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
31 | from rhodecode.lib.base import BaseRepoController, render |
|
31 | from rhodecode.lib.base import BaseRepoController, render | |
32 | from rhodecode.model.db import Repository, User, UserFollowing |
|
32 | from rhodecode.model.db import Repository, User, UserFollowing | |
33 |
|
33 | |||
34 | log = logging.getLogger(__name__) |
|
34 | log = logging.getLogger(__name__) | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | class FollowersController(BaseRepoController): |
|
37 | class FollowersController(BaseRepoController): | |
38 |
|
38 | |||
39 | @LoginRequired() |
|
39 | @LoginRequired() | |
40 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
40 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', | |
41 | 'repository.admin') |
|
41 | 'repository.admin') | |
42 | def __before__(self): |
|
42 | def __before__(self): | |
43 | super(FollowersController, self).__before__() |
|
43 | super(FollowersController, self).__before__() | |
44 |
|
44 | |||
45 | def followers(self, repo_name): |
|
45 | def followers(self, repo_name): | |
46 | p = int(request.params.get('page', 1)) |
|
46 | p = int(request.params.get('page', 1)) | |
47 |
repo_id = |
|
47 | repo_id = c.rhodecode_db_repo.repo_id | |
48 | d = UserFollowing.get_repo_followers(repo_id)\ |
|
48 | d = UserFollowing.get_repo_followers(repo_id)\ | |
49 | .order_by(UserFollowing.follows_from) |
|
49 | .order_by(UserFollowing.follows_from) | |
50 | c.followers_pager = Page(d, page=p, items_per_page=20) |
|
50 | c.followers_pager = Page(d, page=p, items_per_page=20) | |
51 |
|
51 | |||
52 | c.followers_data = render('/followers/followers_data.html') |
|
52 | c.followers_data = render('/followers/followers_data.html') | |
53 |
|
53 | |||
54 | if request.params.get('partial'): |
|
54 | if request.params.get('partial'): | |
55 | return c.followers_data |
|
55 | return c.followers_data | |
56 |
|
56 | |||
57 | return render('/followers/followers.html') |
|
57 | return render('/followers/followers.html') |
@@ -1,56 +1,56 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.controllers.forks |
|
3 | rhodecode.controllers.forks | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | forks controller for rhodecode |
|
6 | forks controller for rhodecode | |
7 |
|
7 | |||
8 | :created_on: Apr 23, 2011 |
|
8 | :created_on: Apr 23, 2011 | |
9 | :author: marcink |
|
9 | :author: marcink | |
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | |
11 | :license: GPLv3, see COPYING for more details. |
|
11 | :license: GPLv3, see COPYING for more details. | |
12 | """ |
|
12 | """ | |
13 | # This program is free software: you can redistribute it and/or modify |
|
13 | # This program is free software: you can redistribute it and/or modify | |
14 | # it under the terms of the GNU General Public License as published by |
|
14 | # it under the terms of the GNU General Public License as published by | |
15 | # the Free Software Foundation, either version 3 of the License, or |
|
15 | # the Free Software Foundation, either version 3 of the License, or | |
16 | # (at your option) any later version. |
|
16 | # (at your option) any later version. | |
17 | # |
|
17 | # | |
18 | # This program is distributed in the hope that it will be useful, |
|
18 | # This program is distributed in the hope that it will be useful, | |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | # GNU General Public License for more details. |
|
21 | # GNU General Public License for more details. | |
22 | # |
|
22 | # | |
23 | # You should have received a copy of the GNU General Public License |
|
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 | import logging |
|
25 | import logging | |
26 |
|
26 | |||
27 | from pylons import tmpl_context as c, request |
|
27 | from pylons import tmpl_context as c, request | |
28 |
|
28 | |||
29 | from rhodecode.lib.helpers import Page |
|
29 | from rhodecode.lib.helpers import Page | |
30 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
30 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
31 | from rhodecode.lib.base import BaseRepoController, render |
|
31 | from rhodecode.lib.base import BaseRepoController, render | |
32 | from rhodecode.model.db import Repository, User, UserFollowing |
|
32 | from rhodecode.model.db import Repository, User, UserFollowing | |
33 |
|
33 | |||
34 | log = logging.getLogger(__name__) |
|
34 | log = logging.getLogger(__name__) | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | class ForksController(BaseRepoController): |
|
37 | class ForksController(BaseRepoController): | |
38 |
|
38 | |||
39 | @LoginRequired() |
|
39 | @LoginRequired() | |
40 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
40 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', | |
41 | 'repository.admin') |
|
41 | 'repository.admin') | |
42 | def __before__(self): |
|
42 | def __before__(self): | |
43 | super(ForksController, self).__before__() |
|
43 | super(ForksController, self).__before__() | |
44 |
|
44 | |||
45 | def forks(self, repo_name): |
|
45 | def forks(self, repo_name): | |
46 | p = int(request.params.get('page', 1)) |
|
46 | p = int(request.params.get('page', 1)) | |
47 |
repo_id = |
|
47 | repo_id = c.rhodecode_db_repo.repo_id | |
48 | d = Repository.get_repo_forks(repo_id) |
|
48 | d = Repository.get_repo_forks(repo_id) | |
49 | c.forks_pager = Page(d, page=p, items_per_page=20) |
|
49 | c.forks_pager = Page(d, page=p, items_per_page=20) | |
50 |
|
50 | |||
51 | c.forks_data = render('/forks/forks_data.html') |
|
51 | c.forks_data = render('/forks/forks_data.html') | |
52 |
|
52 | |||
53 | if request.params.get('partial'): |
|
53 | if request.params.get('partial'): | |
54 | return c.forks_data |
|
54 | return c.forks_data | |
55 |
|
55 | |||
56 | return render('/forks/forks.html') |
|
56 | return render('/forks/forks.html') |
General Comments 0
You need to be logged in to leave comments.
Login now