Mercurial > kallithea
annotate rhodecode/controllers/admin/repos.py @ 3668:a3c1de44991d beta
fix flash link to repos that are in groups
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 04 Apr 2013 14:36:30 +0200 |
parents | ec6354949623 |
children | 6843cabe9925 3563bb7b4b82 |
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 -*- |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
2 """ |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
3 rhodecode.controllers.admin.repos |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
5 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
6 Repositories controller for RhodeCode |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
7 |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
8 :created_on: Apr 7, 2010 |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # 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
|
14 # 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
|
15 # 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
|
16 # (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
|
17 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
18 # 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
|
19 # 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
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
21 # 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
|
22 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
248
diff
changeset
|
23 # 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
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
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 |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
30 |
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
|
31 from webob.exc import HTTPInternalServerError, HTTPForbidden |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
32 from pylons import request, session, tmpl_context as c, url |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
33 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
|
34 from pylons.i18n.translation import _ |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
35 from sqlalchemy.exc import IntegrityError |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
36 |
2664
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
37 import rhodecode |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
38 from rhodecode.lib import helpers as h |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ |
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
|
40 HasPermissionAnyDecorator, HasRepoPermissionAllDecorator, NotAnonymous,\ |
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
|
41 HasPermissionAny, HasReposGroupPermissionAny, 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
|
42 from rhodecode.lib.base import BaseRepoController, render |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1015
diff
changeset
|
43 from rhodecode.lib.utils import invalidate_cache, action_logger, repo_name_slug |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
44 from rhodecode.lib.helpers import get_token |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
45 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
|
46 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
|
47 RhodeCodeSetting, RepositoryField |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
48 from rhodecode.model.forms import RepoForm, RepoFieldForm, RepoPermsForm |
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
|
49 from rhodecode.model.scm import ScmModel, GroupList |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
604
diff
changeset
|
50 from rhodecode.model.repo import RepoModel |
2664
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
51 from rhodecode.lib.compat import json |
2935
20c0af65ac52
user lowernames of repos for better sorting
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
52 from sqlalchemy.sql.expression import func |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
53 from rhodecode.lib.exceptions import AttachedForksError |
824
ceb9f419b7fe
some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents:
821
diff
changeset
|
54 |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
55 log = logging.getLogger(__name__) |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
56 |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
57 |
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
|
58 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
|
59 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
60 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
|
61 # 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
|
62 # file has a resource setup: |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
63 # map.resource('repo', 'repos') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
64 |
235
fcab58c43ea1
Fixed access to repos and users.
Marcin Kuzminski <marcin@python-works.com>
parents:
220
diff
changeset
|
65 @LoginRequired() |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
66 def __before__(self): |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
67 c.admin_user = session.get('admin_user') |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
68 c.admin_username = session.get('admin_username') |
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
|
69 super(ReposController, self).__before__() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
70 |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
71 def __load_defaults(self): |
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
|
72 acl_groups = GroupList(RepoGroup.query().all(), |
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
|
73 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
|
74 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
|
75 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
|
76 |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
77 repo_model = RepoModel() |
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
78 c.users_array = repo_model.get_users_js() |
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
79 c.users_groups_array = repo_model.get_users_groups_js() |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
80 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
|
81 c.landing_revs_choices = choices |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
82 |
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
83 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
|
84 """ |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
85 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
|
86 |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
87 :param repo_name: |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
88 """ |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
89 self.__load_defaults() |
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
90 |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
91 c.repo_info = db_repo = Repository.get_by_repo_name(repo_name) |
1561
4d841e565237
added validation of params on settings table
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
92 repo = db_repo.scm_instance |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
93 |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
94 if c.repo_info is None: |
3110
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3089
diff
changeset
|
95 h.not_mapped_error(repo_name) |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
96 return redirect(url('repos')) |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
97 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
98 ##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
|
99 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
|
100 c.landing_revs_choices = choices |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
101 |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
102 c.default_user_id = User.get_by_username('default').user_id |
1594 | 103 c.in_public_journal = UserFollowing.query()\ |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
104 .filter(UserFollowing.user_id == c.default_user_id)\ |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
105 .filter(UserFollowing.follows_repository == c.repo_info).scalar() |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
106 |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
107 if c.repo_info.stats: |
1807
1635a21485d6
- fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents:
1755
diff
changeset
|
108 # this is on what revision we ended up so we add +1 for count |
1635a21485d6
- fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents:
1755
diff
changeset
|
109 last_rev = c.repo_info.stats.stat_on_revision + 1 |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
110 else: |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
111 last_rev = 0 |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
112 c.stats_revision = last_rev |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
113 |
1807
1635a21485d6
- fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents:
1755
diff
changeset
|
114 c.repo_last_rev = repo.count() if repo.revisions else 0 |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
115 |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
116 if last_rev == 0 or c.repo_last_rev == 0: |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
117 c.stats_percentage = 0 |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
118 else: |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
119 c.stats_percentage = '%.2f' % ((float((last_rev)) / |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
120 c.repo_last_rev) * 100) |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
121 |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
122 c.repo_fields = RepositoryField.query()\ |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
123 .filter(RepositoryField.repository == db_repo).all() |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
124 |
1594 | 125 defaults = RepoModel()._get_defaults(repo_name) |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1807
diff
changeset
|
126 |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
127 c.repos_list = [('', _('--REMOVE FORK--'))] |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
128 c.repos_list += [(x.repo_id, x.repo_name) for x in |
2629
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2603
diff
changeset
|
129 Repository.query().order_by(Repository.repo_name).all() |
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2603
diff
changeset
|
130 if x.repo_id != c.repo_info.repo_id] |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
131 |
2629
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2603
diff
changeset
|
132 defaults['id_fork_of'] = db_repo.fork.repo_id if db_repo.fork else '' |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
133 return defaults |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
134 |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
135 @HasPermissionAllDecorator('hg.admin') |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
136 def index(self, format='html'): |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
137 """GET /repos: All items in the collection""" |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
138 # url('repos') |
1344
eef7a1b953e8
Admin view will see repos_groups in main list
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
139 |
2664
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
140 c.repos_list = Repository.query()\ |
2935
20c0af65ac52
user lowernames of repos for better sorting
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
141 .order_by(func.lower(Repository.repo_name))\ |
2664
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
142 .all() |
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
143 |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
144 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
|
145 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
|
146 super_user_actions=True) |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
147 #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
|
148 c.data = json.dumps(repos_data) |
2664
c525d7e641a6
rewrote admin repos page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
149 |
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
|
150 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
|
151 |
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 @NotAnonymous() |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
153 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
|
154 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
155 POST /repos: Create a new item""" |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
156 # url('repos') |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
157 |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
158 self.__load_defaults() |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
159 form_result = {} |
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
|
160 try: |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
161 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
|
162 landing_revs=c.landing_revs_choices)()\ |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
163 .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
|
164 |
2660
98532710ad14
redirect to summary page after repo was created
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
165 new_repo = RepoModel().create(form_result, |
98532710ad14
redirect to summary page after repo was created
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
166 self.rhodecode_user.user_id) |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
167 if form_result['clone_uri']: |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
168 h.flash(_('Created repository %s from %s') \ |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
169 % (form_result['repo_name'], form_result['clone_uri']), |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
170 category='success') |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
171 else: |
3547
b7f489714639
linkify names on fork/create repos in tooltip messages
Marcin Kuzminski <marcin@python-works.com>
parents:
3524
diff
changeset
|
172 repo_url = h.link_to(form_result['repo_name'], |
3668
a3c1de44991d
fix flash link to repos that are in groups
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
173 h.url('summary_home', repo_name=form_result['repo_name_full'])) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
174 h.flash(h.literal(_('Created repository %s') % repo_url), |
3547
b7f489714639
linkify names on fork/create repos in tooltip messages
Marcin Kuzminski <marcin@python-works.com>
parents:
3524
diff
changeset
|
175 category='success') |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
176 |
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
177 if request.POST.get('user_created'): |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
178 # created by regular non admin user |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
179 action_logger(self.rhodecode_user, 'user_created_repo', |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2142
diff
changeset
|
180 form_result['repo_name_full'], self.ip_addr, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2142
diff
changeset
|
181 self.sa) |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
182 else: |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
183 action_logger(self.rhodecode_user, 'admin_created_repo', |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2142
diff
changeset
|
184 form_result['repo_name_full'], self.ip_addr, |
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
2142
diff
changeset
|
185 self.sa) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
186 Session().commit() |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 defaults=errors.value, |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
191 errors=errors.error_dict or {}, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
192 prefix_error=False, |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
193 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
|
194 |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
195 except Exception: |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
196 log.error(traceback.format_exc()) |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3641
diff
changeset
|
197 msg = _('Error creating repository %s') \ |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
198 % form_result.get('repo_name') |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
199 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
|
200 if c.rhodecode_user.is_admin: |
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
|
201 return redirect(url('repos')) |
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
|
202 return redirect(url('home')) |
2660
98532710ad14
redirect to summary page after repo was created
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
203 #redirect to our new repo ! |
98532710ad14
redirect to summary page after repo was created
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
204 return redirect(url('summary_home', repo_name=new_repo.repo_name)) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
205 |
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
|
206 @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
|
207 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
|
208 """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
|
209 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
|
210 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
|
211 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
|
212 #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
|
213 #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
|
214 _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
|
215 gr_name = _gr.group_name if _gr else None |
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
|
216 if not HasReposGroupPermissionAny('group.admin', 'group.write')(group_name=gr_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
|
217 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
|
218 |
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
|
219 acl_groups = GroupList(RepoGroup.query().all(), |
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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 |
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
|
225 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
|
226 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
227 ## apply the defaults from defaults page |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
232 return htmlfill.render( |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
233 render('admin/repos/repo_add.html'), |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
234 defaults=defaults, |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
235 errors={}, |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
236 prefix_error=False, |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
237 encoding="UTF-8" |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
238 ) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
239 |
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
|
240 @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
|
241 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
|
242 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
243 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
|
244 # 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
|
245 # <input type="hidden" name="_method" value="PUT" /> |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
246 # 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
|
247 # 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
|
248 # 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
|
249 # url('repo', repo_name=ID) |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
250 self.__load_defaults() |
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
|
251 repo_model = RepoModel() |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
252 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
|
253 #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
|
254 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
|
255 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
|
256 repo = Repository.get_by_repo_name(repo_name) |
af96fb19b53a
Pass in old groups data to CanWriteToGroup validator for later skipping group checks.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
257 _form = RepoForm(edit=True, old_data={'repo_name': repo_name, |
af96fb19b53a
Pass in old groups data to CanWriteToGroup validator for later skipping group checks.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
258 'repo_group': repo.group.get_dict() \ |
af96fb19b53a
Pass in old groups data to CanWriteToGroup validator for later skipping group checks.
Marcin Kuzminski <marcin@python-works.com>
parents:
3410
diff
changeset
|
259 if repo.group else {}}, |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
260 repo_groups=c.repo_groups_choices, |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
261 landing_revs=c.landing_revs_choices)() |
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
|
262 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
|
263 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
|
264 repo = repo_model.update(repo_name, **form_result) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
660
diff
changeset
|
265 invalidate_cache('get_repo_cached_%s' % repo_name) |
2570 | 266 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
|
267 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
|
268 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
|
269 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
|
270 changed_name, self.ip_addr, self.sa) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
271 Session().commit() |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
272 except formencode.Invalid, errors: |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
273 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
|
274 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
|
275 return htmlfill.render( |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
276 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
|
277 defaults=defaults, |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
278 errors=errors.error_dict or {}, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
279 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
|
280 encoding="UTF-8") |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
281 |
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
|
282 except Exception: |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
283 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
284 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
|
285 % repo_name, category='error') |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
323
diff
changeset
|
286 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
|
287 |
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
|
288 @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
|
289 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
|
290 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
291 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
|
292 # 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
|
293 # <input type="hidden" name="_method" value="DELETE" /> |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
294 # 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
|
295 # 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
|
296 # 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
|
297 # url('repo', repo_name=ID) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
298 |
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
|
299 repo_model = RepoModel() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
711
diff
changeset
|
300 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
|
301 if not repo: |
3110
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3089
diff
changeset
|
302 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
|
303 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
|
304 try: |
3391
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
305 _forks = repo.forks.count() |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
306 handle_forks = None |
3391
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
307 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
|
308 do = request.POST['forks'] |
f282c81ff532
implemented #689 Deleting Repositories with Forks Should Be Easier
Marcin Kuzminski <marcin@python-works.com>
parents:
3372
diff
changeset
|
309 if do == 'detach_forks': |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
310 handle_forks = 'detach' |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
311 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
|
312 elif do == 'delete_forks': |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
313 handle_forks = 'delete' |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
314 h.flash(_('Deleted %s forks') % _forks, category='success') |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
315 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
|
316 action_logger(self.rhodecode_user, 'admin_deleted_repo', |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
317 repo_name, self.ip_addr, self.sa) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
660
diff
changeset
|
318 invalidate_cache('get_repo_cached_%s' % repo_name) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3547
diff
changeset
|
319 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
|
320 Session().commit() |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
321 except AttachedForksError: |
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
322 h.flash(_('Cannot delete %s it still contains attached forks') |
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
323 % 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
|
324 |
3641
b44979649915
recursive forks detach
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
325 except Exception: |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
326 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
|
327 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
|
328 category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
329 |
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
|
330 return redirect(url('repos')) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
331 |
1869
682057a38cd3
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1828
diff
changeset
|
332 @HasRepoPermissionAllDecorator('repository.admin') |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
333 def set_repo_perm_member(self, repo_name): |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
334 form = RepoPermsForm()().to_python(request.POST) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
335 |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
336 perms_new = form['perms_new'] |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
337 perms_updates = form['perms_updates'] |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
338 cur_repo = repo_name |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
339 |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
340 # update permissions |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
341 for member, perm, member_type in perms_updates: |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
342 if member_type == 'user': |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
343 # this updates existing one |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
344 RepoModel().grant_user_permission( |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
345 repo=cur_repo, user=member, perm=perm |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
346 ) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
347 else: |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
348 RepoModel().grant_users_group_permission( |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
349 repo=cur_repo, group_name=member, perm=perm |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
350 ) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
351 # set new permissions |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
352 for member, perm, member_type in perms_new: |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
353 if member_type == 'user': |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
354 RepoModel().grant_user_permission( |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
355 repo=cur_repo, user=member, perm=perm |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
356 ) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
357 else: |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
358 RepoModel().grant_users_group_permission( |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
359 repo=cur_repo, group_name=member, perm=perm |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
360 ) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
361 #TODO: implement this |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
362 #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
|
363 # repo_name, self.ip_addr, self.sa) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
364 Session().commit() |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3641
diff
changeset
|
365 h.flash(_('Repository permissions updated'), category='success') |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
366 return redirect(url('edit_repo', repo_name=repo_name)) |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
367 |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
368 @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
|
369 def delete_perm_user(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
|
370 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
371 DELETE an existing repository permission user |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
372 |
604
5cc96df705b9
fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
373 :param 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
|
374 """ |
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
|
375 try: |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
376 RepoModel().revoke_user_permission(repo=repo_name, |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
377 user=request.POST['user_id']) |
3628
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
378 #TODO: implement this |
c734686b3cf2
moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
379 #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
|
380 # repo_name, self.ip_addr, self.sa) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
381 Session().commit() |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
382 except Exception: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
383 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
|
384 h.flash(_('An error occurred during deletion of repository user'), |
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
|
385 category='error') |
365
ec7b76d4bda4
Added initial query skipp when seting up the app.
Marcin Kuzminski <marcin@python-works.com>
parents:
357
diff
changeset
|
386 raise HTTPInternalServerError() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
387 |
1828
7531c69ebdfc
fixes issue when owner of a repo couldn't revoke permissions for users and groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
388 @HasRepoPermissionAllDecorator('repository.admin') |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
389 def delete_perm_users_group(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
|
390 """ |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
3391
diff
changeset
|
391 DELETE an existing repository permission user group |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
392 |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
393 :param 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
|
394 """ |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
395 |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
396 try: |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
397 RepoModel().revoke_users_group_permission( |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
398 repo=repo_name, group_name=request.POST['users_group_id'] |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
399 ) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
400 Session().commit() |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
401 except Exception: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
402 log.error(traceback.format_exc()) |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
403 h.flash(_('An error occurred during deletion of repository' |
3410
5f1850e4712a
"Users groups" is grammatically incorrect English - rename to "user groups"
Mads Kiilerich <madski@unity3d.com>
parents:
3391
diff
changeset
|
404 ' user groups'), |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
405 category='error') |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
406 raise HTTPInternalServerError() |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
407 |
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
|
408 @HasRepoPermissionAllDecorator('repository.admin') |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1012
diff
changeset
|
409 def repo_stats(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
|
410 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
411 DELETE an existing repository statistics |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
412 |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
413 :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
|
414 """ |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
415 |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
416 try: |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1869
diff
changeset
|
417 RepoModel().delete_stats(repo_name) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
418 Session().commit() |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
419 except Exception, e: |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
420 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
|
421 h.flash(_('An error occurred during deletion of repository stats'), |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
422 category='error') |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
423 return redirect(url('edit_repo', repo_name=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
|
424 |
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
|
425 @HasRepoPermissionAllDecorator('repository.admin') |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
426 def repo_cache(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
|
427 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
428 INVALIDATE existing repository cache |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
429 |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
430 :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
|
431 """ |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
432 |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
433 try: |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
434 ScmModel().mark_for_invalidation(repo_name) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
435 Session().commit() |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
436 except Exception, e: |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
437 log.error(traceback.format_exc()) |
711
cda88b3eb09c
fixed error for empty revisions on admin repo edit
Marcin Kuzminski <marcin@python-works.com>
parents:
708
diff
changeset
|
438 h.flash(_('An error occurred during cache invalidation'), |
708
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
439 category='error') |
b9bbc0d6e9f3
added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
440 return redirect(url('edit_repo', repo_name=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
|
441 |
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
|
442 @HasRepoPermissionAllDecorator('repository.admin') |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
443 def repo_locking(self, repo_name): |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
444 """ |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
445 Unlock repository when it is locked ! |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
446 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
447 :param repo_name: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
448 """ |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
449 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
450 try: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
451 repo = Repository.get_by_repo_name(repo_name) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
452 if request.POST.get('set_lock'): |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
453 Repository.lock(repo, c.rhodecode_user.user_id) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
454 elif request.POST.get('set_unlock'): |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
455 Repository.unlock(repo) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
456 except Exception, e: |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
457 log.error(traceback.format_exc()) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
458 h.flash(_('An error occurred during unlocking'), |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
459 category='error') |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
460 return redirect(url('edit_repo', repo_name=repo_name)) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2707
diff
changeset
|
461 |
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
|
462 @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
|
463 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
|
464 """ |
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
|
465 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
|
466 |
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
|
467 :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
|
468 """ |
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
|
469 |
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
|
470 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
|
471 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
|
472 |
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
|
473 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
|
474 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
|
475 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
|
476 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
|
477 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
|
478 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
|
479 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
|
480 |
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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 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
|
486 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
|
487 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
|
488 |
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
|
489 @HasRepoPermissionAllDecorator('repository.admin') |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
490 def repo_public_journal(self, repo_name): |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
491 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
492 Set's this repository to be visible in public journal, |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
493 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
|
494 |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
495 :param repo_name: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
496 """ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
497 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
498 cur_token = request.POST.get('auth_token') |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
499 token = get_token() |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
500 if cur_token == token: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
501 try: |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
502 repo_id = Repository.get_by_repo_name(repo_name).repo_id |
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
503 user_id = User.get_by_username('default').user_id |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
504 self.scm_model.toggle_following_repo(repo_id, user_id) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
505 h.flash(_('Updated repository visibility in public journal'), |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
506 category='success') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2660
diff
changeset
|
507 Session().commit() |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
508 except Exception: |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
509 h.flash(_('An error occurred during setting this' |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
510 ' repository in public journal'), |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
511 category='error') |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
512 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
513 else: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
514 h.flash(_('Token mismatch'), category='error') |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
515 return redirect(url('edit_repo', repo_name=repo_name)) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
516 |
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
|
517 @HasRepoPermissionAllDecorator('repository.admin') |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
518 def repo_pull(self, repo_name): |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
519 """ |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
520 Runs task to update given repository with remote changes, |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
521 ie. make pull on remote location |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1161
diff
changeset
|
522 |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
523 :param repo_name: |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
524 """ |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
525 try: |
1121
f3f847712f87
replaced all global calls to template context (rhodecode_user), into instance attributes
Marcin Kuzminski <marcin@python-works.com>
parents:
1114
diff
changeset
|
526 ScmModel().pull_changes(repo_name, self.rhodecode_user.username) |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
527 h.flash(_('Pulled from remote location'), category='success') |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
528 except Exception, e: |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
529 h.flash(_('An error occurred during pull from remote location'), |
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
530 category='error') |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1082
diff
changeset
|
531 |
1114
4de3fa6290a7
#109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
532 return redirect(url('edit_repo', repo_name=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
|
533 |
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
|
534 @HasRepoPermissionAllDecorator('repository.admin') |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
535 def repo_as_fork(self, repo_name): |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
536 """ |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
537 Mark given repository as a fork of another |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1807
diff
changeset
|
538 |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
539 :param repo_name: |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
540 """ |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
541 try: |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
542 fork_id = request.POST.get('id_fork_of') |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
543 repo = ScmModel().mark_as_fork(repo_name, fork_id, |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
544 self.rhodecode_user.username) |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
545 fork = repo.fork.repo_name if repo.fork else _('Nothing') |
2629
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2603
diff
changeset
|
546 Session().commit() |
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2603
diff
changeset
|
547 h.flash(_('Marked repo %s as fork of %s') % (repo_name, fork), |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
548 category='success') |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
549 except Exception, e: |
2629
d2901d906ef3
Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2603
diff
changeset
|
550 log.error(traceback.format_exc()) |
1755
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
551 h.flash(_('An error occurred during this operation'), |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
552 category='error') |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
553 |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
554 return redirect(url('edit_repo', repo_name=repo_name)) |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
555 |
1088ded6e602
implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents:
1752
diff
changeset
|
556 @HasPermissionAllDecorator('hg.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
|
557 def show(self, repo_name, format='html'): |
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
|
558 """GET /repos/repo_name: Show a specific item""" |
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
|
559 # url('repo', repo_name=ID) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
560 |
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
|
561 @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
|
562 def edit(self, repo_name, format='html'): |
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
|
563 """GET /repos/repo_name/edit: Form to edit an existing item""" |
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
|
564 # url('edit_repo', repo_name=ID) |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1106
diff
changeset
|
565 defaults = self.__load_data(repo_name) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
566 |
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
|
567 return htmlfill.render( |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
568 render('admin/repos/repo_edit.html'), |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
569 defaults=defaults, |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
570 encoding="UTF-8", |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
252
diff
changeset
|
571 force_defaults=False |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
572 ) |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
573 |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
574 @HasPermissionAllDecorator('hg.admin') |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
575 def create_repo_field(self, repo_name): |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
576 try: |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
577 form_result = RepoFieldForm()().to_python(dict(request.POST)) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
578 new_field = RepositoryField() |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
579 new_field.repository = Repository.get_by_repo_name(repo_name) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
580 new_field.field_key = form_result['new_field_key'] |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
581 new_field.field_type = form_result['new_field_type'] # python type |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
582 new_field.field_value = form_result['new_field_value'] # set initial blank value |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
583 new_field.field_desc = form_result['new_field_desc'] |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
584 new_field.field_label = form_result['new_field_label'] |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
585 Session().add(new_field) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
586 Session().commit() |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
587 |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
588 except Exception, e: |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
589 log.error(traceback.format_exc()) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
590 msg = _('An error occurred during creation of field') |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
591 if isinstance(e, formencode.Invalid): |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
592 msg += ". " + e.msg |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
593 h.flash(msg, category='error') |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
594 return redirect(url('edit_repo', repo_name=repo_name)) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
595 |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
596 @HasPermissionAllDecorator('hg.admin') |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
597 def delete_repo_field(self, repo_name, field_id): |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
598 field = RepositoryField.get_or_404(field_id) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
599 try: |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
600 Session().delete(field) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
601 Session().commit() |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
602 except Exception, e: |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
603 log.error(traceback.format_exc()) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
604 msg = _('An error occurred during removal of field') |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
605 h.flash(msg, category='error') |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3288
diff
changeset
|
606 return redirect(url('edit_repo', repo_name=repo_name)) |