Mercurial > kallithea
annotate rhodecode/controllers/forks.py @ 4157:bc296381fb6c rhodecode-2.2.5-gpl
rhodecode.js: remove unused stuff
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 02 Jul 2014 19:03:25 -0400 |
parents | ffd45b185016 |
children | 7e5f8c12a3fc |
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 # 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
|
3 # 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
|
4 # 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
|
5 # (at your option) any later version. |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 # |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 # 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
|
8 # 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
|
9 # 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
|
10 # GNU General Public License for more details. |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 # |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 # 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
|
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:
3960
diff
changeset
|
14 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
15 rhodecode.controllers.forks |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
17 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
18 forks controller for rhodecode |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
19 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
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:
3960
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:
3960
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:
3960
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:
3960
diff
changeset
|
24 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
25 |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import logging |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
27 import formencode |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
28 import traceback |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
29 from formencode import htmlfill |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
31 from pylons import tmpl_context as c, request, url |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
32 from pylons.controllers.util import redirect |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
33 from pylons.i18n.translation import _ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
34 from webob.exc import HTTPNotFound, HTTPInternalServerError |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
35 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
36 import rhodecode.lib.helpers as h |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 from rhodecode.lib.helpers import Page |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
39 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator, \ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
40 NotAnonymous, HasRepoPermissionAny, HasPermissionAnyDecorator |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 from rhodecode.lib.base import BaseRepoController, render |
3571
6c88624c719b
fork: 'Update after clone' only makes sense if the update hook will maintain it
Mads Kiilerich <madski@unity3d.com>
parents:
3566
diff
changeset
|
42 from rhodecode.model.db import Repository, RepoGroup, UserFollowing, User,\ |
6c88624c719b
fork: 'Update after clone' only makes sense if the update hook will maintain it
Mads Kiilerich <madski@unity3d.com>
parents:
3566
diff
changeset
|
43 RhodeCodeUi |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
44 from rhodecode.model.repo import RepoModel |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
45 from rhodecode.model.forms import RepoForkForm |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3571
diff
changeset
|
46 from rhodecode.model.scm import ScmModel, RepoGroupList |
2845
6b176c679896
failsafe the GET `page` argument
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
47 from rhodecode.lib.utils2 import safe_int |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
48 from rhodecode.lib.utils import jsonify |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 log = logging.getLogger(__name__) |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 |
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 class ForksController(BaseRepoController): |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 def __before__(self): |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 super(ForksController, self).__before__() |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
58 def __load_defaults(self): |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3571
diff
changeset
|
59 acl_groups = RepoGroupList(RepoGroup.query().all(), |
3239
a9565b8b429b
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper
Marcin Kuzminski <marcin@python-works.com>
parents:
3236
diff
changeset
|
60 perm_set=['group.write', 'group.admin']) |
a9565b8b429b
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper
Marcin Kuzminski <marcin@python-works.com>
parents:
3236
diff
changeset
|
61 c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
62 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
2485
133209bf300c
added landing revision into fork create form
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
63 choices, c.landing_revs = ScmModel().get_repo_landing_revs() |
133209bf300c
added landing revision into fork create form
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
64 c.landing_revs_choices = choices |
3743
490e95264d7f
can update context var needs to be defined in __load_defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
3734
diff
changeset
|
65 c.can_update = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE).ui_active |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
66 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
67 def __load_data(self, repo_name=None): |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
68 """ |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
69 Load defaults settings for edit, and update |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
70 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
71 :param repo_name: |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
72 """ |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
73 self.__load_defaults() |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
74 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
75 c.repo_info = db_repo = Repository.get_by_repo_name(repo_name) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
76 repo = db_repo.scm_instance |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
77 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
78 if c.repo_info is None: |
3110
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
79 h.not_mapped_error(repo_name) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
80 return redirect(url('repos')) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
81 |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
82 c.default_user_id = User.get_default_user().user_id |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
83 c.in_public_journal = UserFollowing.query()\ |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
84 .filter(UserFollowing.user_id == c.default_user_id)\ |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
85 .filter(UserFollowing.follows_repository == c.repo_info).scalar() |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
86 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
87 if c.repo_info.stats: |
1807
1635a21485d6
- fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
88 last_rev = c.repo_info.stats.stat_on_revision+1 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
89 else: |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
90 last_rev = 0 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
91 c.stats_revision = last_rev |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
92 |
1807
1635a21485d6
- fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
93 c.repo_last_rev = repo.count() if repo.revisions else 0 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
94 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
95 if last_rev == 0 or c.repo_last_rev == 0: |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
96 c.stats_percentage = 0 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
97 else: |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
98 c.stats_percentage = '%.2f' % ((float((last_rev)) / |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
99 c.repo_last_rev) * 100) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
100 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
101 defaults = RepoModel()._get_defaults(repo_name) |
3236 | 102 # alter the description to indicate a fork |
103 defaults['description'] = ('fork of repository: %s \n%s' | |
104 % (defaults['repo_name'], | |
105 defaults['description'])) | |
3010
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2845
diff
changeset
|
106 # add suffix to fork |
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2845
diff
changeset
|
107 defaults['repo_name'] = '%s-fork' % defaults['repo_name'] |
3236 | 108 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
109 return defaults |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
110 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
111 @LoginRequired() |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
112 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
113 'repository.admin') |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
114 def forks(self, repo_name): |
3748
9d743ca9cede
usage of request.GET is now more consistent
Marcin Kuzminski <marcin@python-works.com>
parents:
3743
diff
changeset
|
115 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
|
116 repo_id = c.rhodecode_db_repo.repo_id |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
117 d = [] |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
118 for r in Repository.get_repo_forks(repo_id): |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
119 if not HasRepoPermissionAny( |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
120 'repository.read', 'repository.write', 'repository.admin' |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
121 )(r.repo_name, 'get forks check'): |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
122 continue |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
123 d.append(r) |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 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
|
125 |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
126 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
|
127 |
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
|
128 if request.environ.get('HTTP_X_PARTIAL_XHR'): |
1301
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 return c.forks_data |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 |
7e75af301842
Added simple forks page, resolves issue #179
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 return render('/forks/forks.html') |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
132 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
133 @LoginRequired() |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
134 @NotAnonymous() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2652
diff
changeset
|
135 @HasPermissionAnyDecorator('hg.admin', 'hg.fork.repository') |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
136 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
137 'repository.admin') |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
138 def fork(self, repo_name): |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
139 c.repo_info = Repository.get_by_repo_name(repo_name) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
140 if not c.repo_info: |
3110
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
141 h.not_mapped_error(repo_name) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
142 return redirect(url('home')) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
143 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
144 defaults = self.__load_data(repo_name) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
145 |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
146 return htmlfill.render( |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
147 render('forks/fork.html'), |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
148 defaults=defaults, |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
149 encoding="UTF-8", |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
150 force_defaults=False |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
151 ) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
152 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
3748
diff
changeset
|
153 @LoginRequired() |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
154 @NotAnonymous() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2652
diff
changeset
|
155 @HasPermissionAnyDecorator('hg.admin', 'hg.fork.repository') |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
156 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
157 'repository.admin') |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
158 def fork_create(self, repo_name): |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
159 self.__load_defaults() |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
160 c.repo_info = Repository.get_by_repo_name(repo_name) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
161 _form = RepoForkForm(old_data={'repo_type': c.repo_info.repo_type}, |
2485
133209bf300c
added landing revision into fork create form
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
162 repo_groups=c.repo_groups_choices, |
133209bf300c
added landing revision into fork create form
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
163 landing_revs=c.landing_revs_choices)() |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
164 form_result = {} |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
165 task_id = None |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
166 try: |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
167 form_result = _form.to_python(dict(request.POST)) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
168 |
3571
6c88624c719b
fork: 'Update after clone' only makes sense if the update hook will maintain it
Mads Kiilerich <madski@unity3d.com>
parents:
3566
diff
changeset
|
169 # an approximation that is better than nothing |
6c88624c719b
fork: 'Update after clone' only makes sense if the update hook will maintain it
Mads Kiilerich <madski@unity3d.com>
parents:
3566
diff
changeset
|
170 if not RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE).ui_active: |
6c88624c719b
fork: 'Update after clone' only makes sense if the update hook will maintain it
Mads Kiilerich <madski@unity3d.com>
parents:
3566
diff
changeset
|
171 form_result['update_after_clone'] = False |
6c88624c719b
fork: 'Update after clone' only makes sense if the update hook will maintain it
Mads Kiilerich <madski@unity3d.com>
parents:
3566
diff
changeset
|
172 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
173 # create fork is done sometimes async on celery, db transaction |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
174 # management is handled there. |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
175 task = RepoModel().create_fork(form_result, self.rhodecode_user.user_id) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
176 from celery.result import BaseAsyncResult |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
177 if isinstance(task, BaseAsyncResult): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
178 task_id = task.task_id |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
179 except formencode.Invalid, errors: |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
180 c.new_repo = errors.value['repo_name'] |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
181 return htmlfill.render( |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
182 render('forks/fork.html'), |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
183 defaults=errors.value, |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
184 errors=errors.error_dict or {}, |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
185 prefix_error=False, |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
186 encoding="UTF-8") |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
187 except Exception: |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
188 log.error(traceback.format_exc()) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
189 h.flash(_('An error occurred during repository forking %s') % |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
190 repo_name, category='error') |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
191 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
192 return redirect(h.url('repo_creating_home', |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
193 repo_name=form_result['repo_name_full'], |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
194 task_id=task_id)) |