Mercurial > kallithea
annotate rhodecode/controllers/admin/repos.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:03:13 -0400 |
parents | 5293d4bbb1ea |
children | 7e5f8c12a3fc |
rev | line source |
---|---|
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
1 # -*- coding: utf-8 -*- |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
2 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
3 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
4 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
5 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
6 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
10 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
11 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
12 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
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.admin.repos |
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 Repositories 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 7, 2010 |
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 """ |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
25 |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
26 import logging |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
27 import traceback |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
28 import formencode |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
299
diff
changeset
|
29 from formencode import htmlfill |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
30 from webob.exc import HTTPInternalServerError, HTTPForbidden, HTTPNotFound |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
31 from pylons import request, tmpl_context as c, url |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
32 from pylons.controllers.util import redirect |
248
fb7f066126cc
Added support for repository located in subdirectories.
Marcin Kuzminski <marcin@python-works.com>
parents:
247
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 sqlalchemy.sql.expression import func |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
35 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
36 from rhodecode.lib import helpers as h |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
37 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
38 HasRepoPermissionAllDecorator, NotAnonymous,HasPermissionAny, \ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
39 HasRepoGroupPermissionAny, HasRepoPermissionAnyDecorator |
3288
6cdf2cd9d9d8
repo edit: it is a repo thing more than an admin thing - show it that way in ui and url
Mads Kiilerich <madski@unity3d.com>
parents:
3245
diff
changeset
|
40 from rhodecode.lib.base import BaseRepoController, render |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
41 from rhodecode.lib.utils import action_logger, repo_name_slug, jsonify |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
42 from rhodecode.lib.helpers import get_token |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
43 from rhodecode.lib.vcs import RepositoryError |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
44 from rhodecode.model.meta import Session |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2935
diff
changeset
|
45 from rhodecode.model.db import User, Repository, UserFollowing, RepoGroup,\ |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
46 RhodeCodeSetting, RepositoryField |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
47 from rhodecode.model.forms import RepoForm, RepoFieldForm, RepoPermsForm |
3864
1aefa8d864e4
Do read only checks on attach as fork of repo list.
Marcin Kuzminski <marcin@python-works.com>
parents:
3863
diff
changeset
|
48 from rhodecode.model.scm import ScmModel, RepoGroupList, RepoList |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
49 from rhodecode.model.repo import RepoModel |
2664
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
50 from rhodecode.lib.compat import json |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
51 from rhodecode.lib.exceptions import AttachedForksError |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
52 from rhodecode.lib.utils2 import safe_int |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
53 |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
54 log = logging.getLogger(__name__) |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
55 |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
56 |
3288
6cdf2cd9d9d8
repo edit: it is a repo thing more than an admin thing - show it that way in ui and url
Mads Kiilerich <madski@unity3d.com>
parents:
3245
diff
changeset
|
57 class ReposController(BaseRepoController): |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
58 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
59 REST Controller styled on the Atom Publishing Protocol""" |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
60 # To properly map this controller, ensure your config/routing.py |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
61 # file has a resource setup: |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
62 # map.resource('repo', 'repos') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
63 |
235
fcab58c43ea1
Fixed access to repos and users.
Marcin Kuzminski <marcin@python-works.com>
parents:
220
diff
changeset
|
64 @LoginRequired() |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
65 def __before__(self): |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
66 super(ReposController, self).__before__() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
67 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
68 def _load_repo(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
69 repo_obj = Repository.get_by_repo_name(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
70 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
71 if repo_obj is None: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
72 h.not_mapped_error(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
73 return redirect(url('repos')) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
74 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
75 return repo_obj |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
76 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
77 def __load_defaults(self, repo=None): |
3714
7e3d89d9d3a2
- Manage Userโs Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
78 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:
3233
diff
changeset
|
79 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:
3233
diff
changeset
|
80 c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) |
1547
fbc762ae3496
unified generation of repo groups choices
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
81 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
82 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
83 # in case someone no longer have a group.write access to a repository |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
84 # pre fill the list with this entry, we don't care if this is the same |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
85 # but it will allow saving repo data properly. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
86 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
87 repo_group = None |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
88 if repo: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
89 repo_group = repo.group |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
90 if repo_group and unicode(repo_group.group_id) not in c.repo_groups_choices: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
91 c.repo_groups_choices.append(unicode(repo_group.group_id)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
92 c.repo_groups.append(RepoGroup._generate_choice(repo_group)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
93 |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
94 choices, c.landing_revs = ScmModel().get_repo_landing_revs() |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
95 c.landing_revs_choices = choices |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
96 |
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
97 def __load_data(self, repo_name=None): |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
98 """ |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
99 Load defaults settings for edit, and update |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
100 |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
101 :param repo_name: |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
102 """ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
103 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
104 self.__load_defaults(c.repo_info) |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
105 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
106 ##override defaults for exact repo info here git/hg etc |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
107 choices, c.landing_revs = ScmModel().get_repo_landing_revs(c.repo_info) |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
108 c.landing_revs_choices = choices |
1594 | 109 defaults = RepoModel()._get_defaults(repo_name) |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1807
diff
changeset
|
110 |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
111 return defaults |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
112 |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
113 def index(self, format='html'): |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
114 """GET /repos: All items in the collection""" |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
115 # url('repos') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
116 _list = Repository.query()\ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
117 .order_by(func.lower(Repository.repo_name))\ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
118 .all() |
1344
eef7a1b953e8
Admin view will see repos_groups in main list
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
119 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
120 c.repos_list = RepoList(_list, perm_set=['repository.admin']) |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
121 repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list, |
3245
8f3cc21d83e6
fixes issue #739 Delete/Edit repositories should only point to admin links if the user is an super admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
122 admin=True, |
8f3cc21d83e6
fixes issue #739 Delete/Edit repositories should only point to admin links if the user is an super admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
123 super_user_actions=True) |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
124 #json used to render the grid |
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
125 c.data = json.dumps(repos_data) |
2664
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
126 |
127
20dc7a5eb748
Html changes and cleanups, made folders for html templates, implemented tags and branches pages
Marcin Kuzminski <marcin@python-works.com>
parents:
101
diff
changeset
|
127 return render('admin/repos/repos.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
128 |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3315
diff
changeset
|
129 @NotAnonymous() |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
130 def create(self): |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
131 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
132 POST /repos: Create a new item""" |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
133 # url('repos') |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
134 |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
135 self.__load_defaults() |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
136 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
|
137 task_id = None |
215
70f645fa97cc
Moved repo creation to admin/repos, as part of crud controller. Now repo creation is based on a form, which can be auto filled with data from 404 page. Fixed the error controller to properly give the repo name.
Marcin Kuzminski <marcin@python-works.com>
parents:
191
diff
changeset
|
138 try: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
139 # CanWriteToGroup validators checks permissions of this POST |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
140 form_result = RepoForm(repo_groups=c.repo_groups_choices, |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
141 landing_revs=c.landing_revs_choices)()\ |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
142 .to_python(dict(request.POST)) |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3315
diff
changeset
|
143 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
144 # create is done sometimes async on celery, db transaction |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
145 # management is handled there. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
146 task = RepoModel().create(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
|
147 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
|
148 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
|
149 task_id = task.task_id |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
150 except formencode.Invalid, errors: |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
151 return htmlfill.render( |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3315
diff
changeset
|
152 render('admin/repos/repo_add.html'), |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
153 defaults=errors.value, |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
154 errors=errors.error_dict or {}, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
155 prefix_error=False, |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
156 encoding="UTF-8") |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
157 |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
158 except Exception: |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
159 log.error(traceback.format_exc()) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
160 msg = (_('Error creating repository %s') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
161 % form_result.get('repo_name')) |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
162 h.flash(msg, category='error') |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3315
diff
changeset
|
163 return redirect(url('home')) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
164 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
165 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
|
166 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
|
167 task_id=task_id)) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
168 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
169 @NotAnonymous() |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
170 def create_repository(self): |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
171 """GET /_admin/create_repository: Form to create a new item""" |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
172 new_repo = request.GET.get('repo', '') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
173 parent_group = request.GET.get('parent_group') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
174 if not HasPermissionAny('hg.admin', 'hg.create.repository')(): |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
175 #you're not super admin nor have global create permissions, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
176 #but maybe you have at least write permission to a parent group ? |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
177 _gr = RepoGroup.get(parent_group) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
178 gr_name = _gr.group_name if _gr else None |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
179 # create repositories with write permission on group is set to true |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
180 create_on_write = HasPermissionAny('hg.create.write_on_repogroup.true')() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
181 group_admin = HasRepoGroupPermissionAny('group.admin')(group_name=gr_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
182 group_write = HasRepoGroupPermissionAny('group.write')(group_name=gr_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
183 if not (group_admin or (group_write and create_on_write)): |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
184 raise HTTPForbidden |
3233
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
185 |
3714
7e3d89d9d3a2
- Manage Userโs Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
186 acl_groups = RepoGroupList(RepoGroup.query().all(), |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
187 perm_set=['group.write', 'group.admin']) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
188 c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
189 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
190 choices, c.landing_revs = ScmModel().get_repo_landing_revs() |
3233
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
191 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
192 c.new_repo = repo_name_slug(new_repo) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
193 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
194 ## apply the defaults from defaults page |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
195 defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True) |
3233
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
196 if parent_group: |
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
197 defaults.update({'repo_group': parent_group}) |
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
198 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
199 return htmlfill.render( |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
200 render('admin/repos/repo_add.html'), |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
201 defaults=defaults, |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
202 errors={}, |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
203 prefix_error=False, |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
204 encoding="UTF-8" |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
205 ) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
206 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
207 @LoginRequired() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
208 @NotAnonymous() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
209 def repo_creating(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
210 c.repo = repo_name |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
211 c.task_id = request.GET.get('task_id') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
212 if not c.repo: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
213 raise HTTPNotFound() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
214 return render('admin/repos/repo_creating.html') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
215 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
216 @LoginRequired() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
217 @NotAnonymous() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
218 @jsonify |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
219 def repo_check(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
220 c.repo = repo_name |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
221 task_id = request.GET.get('task_id') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
222 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
223 if task_id and task_id not in ['None']: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
224 from rhodecode import CELERY_ON |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
225 from celery.result import AsyncResult |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
226 if CELERY_ON: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
227 task = AsyncResult(task_id) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
228 if task.failed(): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
229 raise HTTPInternalServerError(task.traceback) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
230 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
231 repo = Repository.get_by_repo_name(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
232 if repo and repo.repo_state == Repository.STATE_CREATED: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
233 if repo.clone_uri: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
234 clone_uri = repo.clone_uri_hidden |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
235 h.flash(_('Created repository %s from %s') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
236 % (repo.repo_name, clone_uri), category='success') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
237 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
238 repo_url = h.link_to(repo.repo_name, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
239 h.url('summary_home', |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
240 repo_name=repo.repo_name)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
241 fork = repo.fork |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
242 if fork: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
243 fork_name = fork.repo_name |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
244 h.flash(h.literal(_('Forked repository %s as %s') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
245 % (fork_name, repo_url)), category='success') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
246 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
247 h.flash(h.literal(_('Created repository %s') % repo_url), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
248 category='success') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
249 return {'result': True} |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
250 return {'result': False} |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
251 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
252 @HasRepoPermissionAllDecorator('repository.admin') |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
253 def update(self, repo_name): |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
254 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
255 PUT /repos/repo_name: Update an existing item""" |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
256 # Forms posted to this method should contain a hidden field: |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
257 # <input type="hidden" name="_method" value="PUT" /> |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
258 # Or using helpers: |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
259 # h.form(url('repo', repo_name=ID), |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
260 # method='put') |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
261 # url('repo', repo_name=ID) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
262 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
263 c.active = 'settings' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
264 c.repo_fields = RepositoryField.query()\ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
265 .filter(RepositoryField.repository == c.repo_info).all() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
266 self.__load_defaults(c.repo_info) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
267 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
268 repo_model = RepoModel() |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
269 changed_name = repo_name |
2603
370ed7829168
Readme renderer now uses landing_rev parameter to render the readme based on
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
270 #override the choices with extracted revisions ! |
370ed7829168
Readme renderer now uses landing_rev parameter to render the readme based on
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
271 choices, c.landing_revs = ScmModel().get_repo_landing_revs(repo_name) |
370ed7829168
Readme renderer now uses landing_rev parameter to render the readme based on
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
272 c.landing_revs_choices = choices |
3524
af96fb19b53a
Pass in old groups data to CanWriteToGroup validator for later skipping group checks.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
273 repo = Repository.get_by_repo_name(repo_name) |
3863
794e6eaad4aa
fix required repo_type param on repo edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
274 old_data = { |
794e6eaad4aa
fix required repo_type param on repo edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
275 'repo_name': repo_name, |
794e6eaad4aa
fix required repo_type param on repo edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
276 'repo_group': repo.group.get_dict() if repo.group else {}, |
794e6eaad4aa
fix required repo_type param on repo edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
277 'repo_type': repo.repo_type, |
794e6eaad4aa
fix required repo_type param on repo edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
278 } |
794e6eaad4aa
fix required repo_type param on repo edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
279 _form = RepoForm(edit=True, old_data=old_data, |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
280 repo_groups=c.repo_groups_choices, |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
281 landing_revs=c.landing_revs_choices)() |
3863
794e6eaad4aa
fix required repo_type param on repo edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3826
diff
changeset
|
282 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
283 try: |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
284 form_result = _form.to_python(dict(request.POST)) |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
285 repo = repo_model.update(repo_name, **form_result) |
3693
6843cabe9925
removed duplicated logic of how we invalidate caches for repos
Marcin Kuzminski <marcin@python-works.com>
parents:
3668
diff
changeset
|
286 ScmModel().mark_for_invalidation(repo_name) |
2570 | 287 h.flash(_('Repository %s updated successfully') % repo_name, |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
299
diff
changeset
|
288 category='success') |
1539
bd604cf75c5a
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
289 changed_name = repo.repo_name |
660
df61378032f3
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
290 action_logger(self.rhodecode_user, 'admin_updated_repo', |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2142
diff
changeset
|
291 changed_name, self.ip_addr, self.sa) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
292 Session().commit() |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
293 except formencode.Invalid, errors: |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
294 defaults = self.__load_data(repo_name) |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
295 defaults.update(errors.value) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
296 return htmlfill.render( |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
297 render('admin/repos/repo_edit.html'), |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
298 defaults=defaults, |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
299 errors=errors.error_dict or {}, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
300 prefix_error=False, |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
301 encoding="UTF-8") |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
302 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
303 except Exception: |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
304 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
305 h.flash(_('Error occurred during update of repository %s') \ |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
306 % repo_name, category='error') |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
307 return redirect(url('edit_repo', repo_name=changed_name)) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
308 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
309 @HasRepoPermissionAllDecorator('repository.admin') |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
310 def delete(self, repo_name): |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
311 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
312 DELETE /repos/repo_name: Delete an existing item""" |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
313 # Forms posted to this method should contain a hidden field: |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
314 # <input type="hidden" name="_method" value="DELETE" /> |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
315 # Or using helpers: |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
316 # h.form(url('repo', repo_name=ID), |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
317 # method='delete') |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
318 # url('repo', repo_name=ID) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
319 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
320 repo_model = RepoModel() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
711
diff
changeset
|
321 repo = repo_model.get_by_repo_name(repo_name) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
322 if not repo: |
3110
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3089
diff
changeset
|
323 h.not_mapped_error(repo_name) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
324 return redirect(url('repos')) |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
325 try: |
3391
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
326 _forks = repo.forks.count() |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
327 handle_forks = None |
3391
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
328 if _forks and request.POST.get('forks'): |
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
329 do = request.POST['forks'] |
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
330 if do == 'detach_forks': |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
331 handle_forks = 'detach' |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
332 h.flash(_('Detached %s forks') % _forks, category='success') |
3391
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
333 elif do == 'delete_forks': |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
334 handle_forks = 'delete' |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
335 h.flash(_('Deleted %s forks') % _forks, category='success') |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
336 repo_model.delete(repo, forks=handle_forks) |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
337 action_logger(self.rhodecode_user, 'admin_deleted_repo', |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
338 repo_name, self.ip_addr, self.sa) |
3693
6843cabe9925
removed duplicated logic of how we invalidate caches for repos
Marcin Kuzminski <marcin@python-works.com>
parents:
3668
diff
changeset
|
339 ScmModel().mark_for_invalidation(repo_name) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
340 h.flash(_('Deleted repository %s') % repo_name, category='success') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
341 Session().commit() |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
342 except AttachedForksError: |
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
343 h.flash(_('Cannot delete %s it still contains attached forks') |
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
344 % repo_name, category='warning') |
1361
87ca17540603
fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
345 |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
346 except Exception: |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
347 log.error(traceback.format_exc()) |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
832
diff
changeset
|
348 h.flash(_('An error occurred during deletion of %s') % repo_name, |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
349 category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
350 |
58
8fb1abd4178a
Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents:
52
diff
changeset
|
351 return redirect(url('repos')) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
352 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
353 @HasPermissionAllDecorator('hg.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
354 def show(self, repo_name, format='html'): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
355 """GET /repos/repo_name: Show a specific item""" |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
356 # url('repo', repo_name=ID) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
357 |
1869
682057a38cd3
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1828
diff
changeset
|
358 @HasRepoPermissionAllDecorator('repository.admin') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
359 def edit(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
360 """GET /repo_name/settings: Form to edit an existing item""" |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
361 # url('edit_repo', repo_name=ID) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
362 defaults = self.__load_data(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
363 if 'clone_uri' in defaults: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
364 del defaults['clone_uri'] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
365 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
366 c.repo_fields = RepositoryField.query()\ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
367 .filter(RepositoryField.repository == c.repo_info).all() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
368 c.active = 'settings' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
369 return htmlfill.render( |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
370 render('admin/repos/repo_edit.html'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
371 defaults=defaults, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
372 encoding="UTF-8", |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
373 force_defaults=False) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
374 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
375 @HasRepoPermissionAllDecorator('repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
376 def edit_permissions(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
377 """GET /repo_name/settings: Form to edit an existing item""" |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
378 # url('edit_repo', repo_name=ID) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
379 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
380 repo_model = RepoModel() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
381 c.users_array = repo_model.get_users_js() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
382 c.user_groups_array = repo_model.get_user_groups_js() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
383 c.active = 'permissions' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
384 defaults = RepoModel()._get_defaults(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
385 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
386 return htmlfill.render( |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
387 render('admin/repos/repo_edit.html'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
388 defaults=defaults, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
389 encoding="UTF-8", |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
390 force_defaults=False) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
391 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
392 def edit_permissions_update(self, repo_name): |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
393 form = RepoPermsForm()().to_python(request.POST) |
3714
7e3d89d9d3a2
- Manage Userโs Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
394 RepoModel()._update_permissions(repo_name, form['perms_new'], |
7e3d89d9d3a2
- Manage Userโs Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3712
diff
changeset
|
395 form['perms_updates']) |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
396 #TODO: implement this |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
397 #action_logger(self.rhodecode_user, 'admin_changed_repo_permissions', |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
398 # repo_name, self.ip_addr, self.sa) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
399 Session().commit() |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3641
diff
changeset
|
400 h.flash(_('Repository permissions updated'), category='success') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
401 return redirect(url('edit_repo_perms', repo_name=repo_name)) |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
402 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
403 def edit_permissions_revoke(self, repo_name): |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
404 try: |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
405 obj_type = request.POST.get('obj_type') |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
406 obj_id = None |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
407 if obj_type == 'user': |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
408 obj_id = safe_int(request.POST.get('user_id')) |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
409 elif obj_type == 'user_group': |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
410 obj_id = safe_int(request.POST.get('user_group_id')) |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
411 |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
412 if obj_type == 'user': |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
413 RepoModel().revoke_user_permission(repo=repo_name, user=obj_id) |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
414 elif obj_type == 'user_group': |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
415 RepoModel().revoke_user_group_permission( |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
416 repo=repo_name, group_name=obj_id |
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
417 ) |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
418 #TODO: implement this |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
419 #action_logger(self.rhodecode_user, 'admin_revoked_repo_permissions', |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
420 # repo_name, self.ip_addr, self.sa) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
421 Session().commit() |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
422 except Exception: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
423 log.error(traceback.format_exc()) |
3715
25dbbdae3ed9
consistent handling of grant/revoke of permissions widgets
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
424 h.flash(_('An error occurred during revoking of permission'), |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
425 category='error') |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
426 raise HTTPInternalServerError() |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
427 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
428 @HasRepoPermissionAllDecorator('repository.admin') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
429 def edit_fields(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
430 """GET /repo_name/settings: Form to edit an existing item""" |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
431 # url('edit_repo', repo_name=ID) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
432 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
433 c.repo_fields = RepositoryField.query()\ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
434 .filter(RepositoryField.repository == c.repo_info).all() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
435 c.active = 'fields' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
436 if request.POST: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
437 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
438 return redirect(url('repo_edit_fields')) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
439 return render('admin/repos/repo_edit.html') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
440 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
441 @HasRepoPermissionAllDecorator('repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
442 def create_repo_field(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
443 try: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
444 form_result = RepoFieldForm()().to_python(dict(request.POST)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
445 new_field = RepositoryField() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
446 new_field.repository = Repository.get_by_repo_name(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
447 new_field.field_key = form_result['new_field_key'] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
448 new_field.field_type = form_result['new_field_type'] # python type |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
449 new_field.field_value = form_result['new_field_value'] # set initial blank value |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
450 new_field.field_desc = form_result['new_field_desc'] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
451 new_field.field_label = form_result['new_field_label'] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
452 Session().add(new_field) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
453 Session().commit() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
454 except Exception, e: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
455 log.error(traceback.format_exc()) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
456 msg = _('An error occurred during creation of field') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
457 if isinstance(e, formencode.Invalid): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
458 msg += ". " + e.msg |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
459 h.flash(msg, category='error') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
460 return redirect(url('edit_repo_fields', repo_name=repo_name)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
461 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
462 @HasRepoPermissionAllDecorator('repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
463 def delete_repo_field(self, repo_name, field_id): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
464 field = RepositoryField.get_or_404(field_id) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
465 try: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
466 Session().delete(field) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
467 Session().commit() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
468 except Exception, e: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
469 log.error(traceback.format_exc()) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
470 msg = _('An error occurred during removal of field') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
471 h.flash(msg, category='error') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
472 return redirect(url('edit_repo_fields', repo_name=repo_name)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
473 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
474 @HasRepoPermissionAllDecorator('repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
475 def edit_advanced(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
476 """GET /repo_name/settings: Form to edit an existing item""" |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
477 # url('edit_repo', repo_name=ID) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
478 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
479 c.default_user_id = User.get_default_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
|
480 c.in_public_journal = UserFollowing.query()\ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
481 .filter(UserFollowing.user_id == c.default_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
|
482 .filter(UserFollowing.follows_repository == c.repo_info).scalar() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
483 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
484 _repos = Repository.query().order_by(Repository.repo_name).all() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
485 read_access_repos = RepoList(_repos) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
486 c.repos_list = [(None, _('-- Not a fork --'))] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
487 c.repos_list += [(x.repo_id, x.repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
488 for x in read_access_repos |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
489 if x.repo_id != c.repo_info.repo_id] |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
490 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
491 defaults = { |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
492 'id_fork_of': c.repo_info.fork.repo_id if c.repo_info.fork else '' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
493 } |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
494 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
495 c.active = 'advanced' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
496 if request.POST: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
497 return redirect(url('repo_edit_advanced')) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
498 return htmlfill.render( |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
499 render('admin/repos/repo_edit.html'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
500 defaults=defaults, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
501 encoding="UTF-8", |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
502 force_defaults=False) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
503 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
504 @HasRepoPermissionAllDecorator('repository.admin') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
505 def edit_advanced_journal(self, repo_name): |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
506 """ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
507 Set's this repository to be visible in public journal, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
508 in other words assing default user to follow this repo |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
509 |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
510 :param repo_name: |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
511 """ |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
512 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
513 cur_token = request.POST.get('auth_token') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
514 token = get_token() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
515 if cur_token == token: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
516 try: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
517 repo_id = Repository.get_by_repo_name(repo_name).repo_id |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
518 user_id = User.get_default_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
|
519 self.scm_model.toggle_following_repo(repo_id, 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
|
520 h.flash(_('Updated repository visibility in public journal'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
521 category='success') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
522 Session().commit() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
523 except Exception: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
524 h.flash(_('An error occurred during setting this' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
525 ' repository in public journal'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
526 category='error') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
527 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
528 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
529 h.flash(_('Token mismatch'), category='error') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
530 return redirect(url('edit_repo_advanced', repo_name=repo_name)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
531 |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
532 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
533 @HasRepoPermissionAllDecorator('repository.admin') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
534 def edit_advanced_fork(self, repo_name): |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
535 """ |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
536 Mark given repository as a fork of another |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
537 |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
538 :param repo_name: |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
539 """ |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
540 try: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
541 fork_id = request.POST.get('id_fork_of') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
542 repo = ScmModel().mark_as_fork(repo_name, fork_id, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
543 self.rhodecode_user.username) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
544 fork = repo.fork.repo_name if repo.fork else _('Nothing') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
545 Session().commit() |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
546 h.flash(_('Marked repo %s as fork of %s') % (repo_name, fork), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
547 category='success') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
548 except RepositoryError, e: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
549 log.error(traceback.format_exc()) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
550 h.flash(str(e), category='error') |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
551 except Exception, e: |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
552 log.error(traceback.format_exc()) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
553 h.flash(_('An error occurred during this operation'), |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
554 category='error') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
555 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
556 return redirect(url('edit_repo_advanced', repo_name=repo_name)) |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
557 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
558 @HasRepoPermissionAllDecorator('repository.admin') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
559 def edit_advanced_locking(self, repo_name): |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
560 """ |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
561 Unlock repository when it is locked ! |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
562 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
563 :param repo_name: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
564 """ |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
565 try: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
566 repo = Repository.get_by_repo_name(repo_name) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
567 if request.POST.get('set_lock'): |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
568 Repository.lock(repo, c.rhodecode_user.user_id) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
569 h.flash(_('Locked repository'), category='success') |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
570 elif request.POST.get('set_unlock'): |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
571 Repository.unlock(repo) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
572 h.flash(_('Unlocked repository'), category='success') |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
573 except Exception, e: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
574 log.error(traceback.format_exc()) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
575 h.flash(_('An error occurred during unlocking'), |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
576 category='error') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
577 return redirect(url('edit_repo_advanced', repo_name=repo_name)) |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
578 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
579 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
580 def toggle_locking(self, repo_name): |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
581 """ |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
582 Toggle locking of repository by simple GET call to url |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
583 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
584 :param repo_name: |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
585 """ |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
586 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
587 try: |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
588 repo = Repository.get_by_repo_name(repo_name) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
589 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
590 if repo.enable_locking: |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
591 if repo.locked[0]: |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
592 Repository.unlock(repo) |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3641
diff
changeset
|
593 action = _('Unlocked') |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
594 else: |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
595 Repository.lock(repo, c.rhodecode_user.user_id) |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3641
diff
changeset
|
596 action = _('Locked') |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
597 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
598 h.flash(_('Repository has been %s') % action, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
599 category='success') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
600 except Exception, e: |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
601 log.error(traceback.format_exc()) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
602 h.flash(_('An error occurred during unlocking'), |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
603 category='error') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
604 return redirect(url('summary_home', repo_name=repo_name)) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
605 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
606 @HasRepoPermissionAllDecorator('repository.admin') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
607 def edit_caches(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
608 """GET /repo_name/settings: Form to edit an existing item""" |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
609 # url('edit_repo', repo_name=ID) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
610 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
611 c.active = 'caches' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
612 if request.POST: |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
613 try: |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
614 ScmModel().mark_for_invalidation(repo_name, delete=True) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
615 Session().commit() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
616 h.flash(_('Cache invalidation successful'), |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
617 category='success') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
618 except Exception, e: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
619 log.error(traceback.format_exc()) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
620 h.flash(_('An error occurred during cache invalidation'), |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
621 category='error') |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
622 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
623 return redirect(url('edit_repo_caches', repo_name=c.repo_name)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
624 return render('admin/repos/repo_edit.html') |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
625 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
626 @HasRepoPermissionAllDecorator('repository.admin') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
627 def edit_remote(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
628 """GET /repo_name/settings: Form to edit an existing item""" |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
629 # url('edit_repo', repo_name=ID) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
630 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
631 c.active = 'remote' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
632 if request.POST: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
633 try: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
634 ScmModel().pull_changes(repo_name, self.rhodecode_user.username) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
635 h.flash(_('Pulled from remote location'), category='success') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
636 except Exception, e: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
637 log.error(traceback.format_exc()) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
638 h.flash(_('An error occurred during pull from remote location'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
639 category='error') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
640 return redirect(url('edit_repo_remote', repo_name=c.repo_name)) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
641 return render('admin/repos/repo_edit.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
642 |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3628
diff
changeset
|
643 @HasRepoPermissionAllDecorator('repository.admin') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
644 def edit_statistics(self, repo_name): |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
645 """GET /repo_name/settings: Form to edit an existing item""" |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
298
diff
changeset
|
646 # url('edit_repo', repo_name=ID) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
647 c.repo_info = self._load_repo(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
648 repo = c.repo_info.scm_instance |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
649 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
650 if c.repo_info.stats: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
651 # this is on what revision we ended up so we add +1 for count |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
652 last_rev = c.repo_info.stats.stat_on_revision + 1 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
653 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
654 last_rev = 0 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
655 c.stats_revision = last_rev |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
656 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
657 c.repo_last_rev = repo.count() if repo.revisions else 0 |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
658 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
659 if last_rev == 0 or c.repo_last_rev == 0: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
660 c.stats_percentage = 0 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
661 else: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
662 c.stats_percentage = '%.2f' % ((float((last_rev)) / c.repo_last_rev) * 100) |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
663 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
664 c.active = 'statistics' |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
665 if request.POST: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
666 try: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
667 RepoModel().delete_stats(repo_name) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
668 Session().commit() |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
669 except Exception, e: |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
670 log.error(traceback.format_exc()) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
671 h.flash(_('An error occurred during deletion of repository stats'), |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
672 category='error') |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
673 return redirect(url('edit_repo_statistics', repo_name=c.repo_name)) |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
674 |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
675 return render('admin/repos/repo_edit.html') |