Mercurial > kallithea
annotate rhodecode/controllers/settings.py @ 1173:f2b5279a5c77 beta
Added tag v1.1.7 for changeset 2ab211e0aecd
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 23 Mar 2011 20:56:05 +0100 |
parents | f3f847712f87 |
children | 6832ef664673 |
rev | line source |
---|---|
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
1 # -*- coding: utf-8 -*- |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
2 """ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
3 rhodecode.controllers.settings |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
5 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
6 Settings controller for rhodecode |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
7 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
8 :created_on: Jun 30, 2010 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
9 :author: marcink |
902
07a6e8c65526
fixed copyright year to 2011
Marcin Kuzminski <marcin@python-works.com>
parents:
861
diff
changeset
|
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
12 """ |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # This program is free software; you can redistribute it and/or |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # modify it under the terms of the GNU General Public License |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # as published by the Free Software Foundation; version 2 |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # of the License or (at your opinion) any later version of the license. |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # along with this program; if not, write to the Free Software |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 # MA 02110-1301, USA. |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
27 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
28 import logging |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
29 import traceback |
1067
717ccea6df18
fixed some very strange issue with htmlfill import - don't know why but this needs to be imported as separate module
Marcin Kuzminski <marcin@python-works.com>
parents:
1060
diff
changeset
|
30 import formencode |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
31 |
1067
717ccea6df18
fixed some very strange issue with htmlfill import - don't know why but this needs to be imported as separate module
Marcin Kuzminski <marcin@python-works.com>
parents:
1060
diff
changeset
|
32 from formencode import htmlfill |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
33 |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 from pylons import tmpl_context as c, request, url |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 from pylons.controllers.util import redirect |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 from pylons.i18n.translation import _ |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
37 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
38 import rhodecode.lib.helpers as h |
1056
520d27f40b51
#113 removed anonymous access from forking, added system messages in login box.
Marcin Kuzminski <marcin@python-works.com>
parents:
1054
diff
changeset
|
39 |
520d27f40b51
#113 removed anonymous access from forking, added system messages in login box.
Marcin Kuzminski <marcin@python-works.com>
parents:
1054
diff
changeset
|
40 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator, \ |
1060
97ed582ea86e
permission fixes for forking
Marcin Kuzminski <marcin@python-works.com>
parents:
1056
diff
changeset
|
41 HasRepoPermissionAnyDecorator, NotAnonymous |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1015
diff
changeset
|
42 from rhodecode.lib.base import BaseRepoController, render |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
43 from rhodecode.lib.utils import invalidate_cache, action_logger |
1056
520d27f40b51
#113 removed anonymous access from forking, added system messages in login box.
Marcin Kuzminski <marcin@python-works.com>
parents:
1054
diff
changeset
|
44 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
45 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
46 from rhodecode.model.repo import RepoModel |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
47 from rhodecode.model.db import User |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
48 |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 log = logging.getLogger(__name__) |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1015
diff
changeset
|
51 class SettingsController(BaseRepoController): |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 @LoginRequired() |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 def __before__(self): |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 super(SettingsController, self).__before__() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
56 |
1054
32dbf759fa98
fixed #113 to high permission was required to fork a repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
57 @HasRepoPermissionAllDecorator('repository.admin') |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 def index(self, repo_name): |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 repo_model = RepoModel() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
60 c.repo_info = repo = repo_model.get_by_repo_name(repo_name) |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 if not repo: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
62 h.flash(_('%s repository is not mapped to db perhaps' |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
832
diff
changeset
|
63 ' it was created or renamed from the file system' |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 ' please run the application again' |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 ' in order to rescan repositories') % repo_name, |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
67 |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
68 return redirect(url('home')) |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
69 |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 c.users_array = repo_model.get_users_js() |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
71 c.users_groups_array = repo_model.get_users_groups_js() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
72 |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
73 defaults = c.repo_info.get_dict() |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
74 |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
75 #fill owner |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
76 if c.repo_info.user: |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
77 defaults.update({'user':c.repo_info.user.username}) |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
78 else: |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
79 replacement_user = self.sa.query(User)\ |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
80 .filter(User.admin == True).first().username |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
81 defaults.update({'user':replacement_user}) |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
82 |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
83 #fill repository users |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
84 for p in c.repo_info.repo_to_perm: |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
85 defaults.update({'u_perm_%s' % p.user.username: |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
86 p.permission.permission_name}) |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
87 |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
88 #fill repository groups |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
89 for p in c.repo_info.users_group_to_perm: |
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
90 defaults.update({'g_perm_%s' % p.users_group.users_group_name: |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 p.permission.permission_name}) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
92 |
1067
717ccea6df18
fixed some very strange issue with htmlfill import - don't know why but this needs to be imported as separate module
Marcin Kuzminski <marcin@python-works.com>
parents:
1060
diff
changeset
|
93 return htmlfill.render( |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
94 render('settings/repo_settings.html'), |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 defaults=defaults, |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
96 encoding="UTF-8", |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 force_defaults=False |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
98 ) |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 |
1054
32dbf759fa98
fixed #113 to high permission was required to fork a repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
100 @HasRepoPermissionAllDecorator('repository.admin') |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 def update(self, repo_name): |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 repo_model = RepoModel() |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
103 changed_name = repo_name |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
104 _form = RepoSettingsForm(edit=True, old_data={'repo_name':repo_name})() |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
105 try: |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
106 form_result = _form.to_python(dict(request.POST)) |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
107 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
|
108 invalidate_cache('get_repo_cached_%s' % repo_name) |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
109 h.flash(_('Repository %s updated successfully' % repo_name), |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 category='success') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
111 changed_name = form_result['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:
659
diff
changeset
|
112 action_logger(self.rhodecode_user, 'user_updated_repo', |
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:
659
diff
changeset
|
113 changed_name, '', self.sa) |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
114 except formencode.Invalid, errors: |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
115 c.repo_info = repo_model.get_by_repo_name(repo_name) |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 c.users_array = repo_model.get_users_js() |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
117 errors.value.update({'user':c.repo_info.user.username}) |
1067
717ccea6df18
fixed some very strange issue with htmlfill import - don't know why but this needs to be imported as separate module
Marcin Kuzminski <marcin@python-works.com>
parents:
1060
diff
changeset
|
118 return htmlfill.render( |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
119 render('settings/repo_settings.html'), |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
120 defaults=errors.value, |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
121 errors=errors.error_dict or {}, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
122 prefix_error=False, |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
123 encoding="UTF-8") |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 except Exception: |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
125 log.error(traceback.format_exc()) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
660
diff
changeset
|
126 h.flash(_('error occurred during update of repository %s') \ |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
127 % repo_name, category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
128 |
367
a26f48ad7a8a
fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
129 return redirect(url('repo_settings_home', repo_name=changed_name)) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
130 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
131 |
1054
32dbf759fa98
fixed #113 to high permission was required to fork a repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
132 @HasRepoPermissionAllDecorator('repository.admin') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
133 def delete(self, repo_name): |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
134 """DELETE /repos/repo_name: Delete an existing item""" |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
135 # Forms posted to this method should contain a hidden field: |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
136 # <input type="hidden" name="_method" value="DELETE" /> |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
137 # Or using helpers: |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
138 # h.form(url('repo_settings_delete', repo_name=ID), |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
139 # method='delete') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
140 # url('repo_settings_delete', repo_name=ID) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
141 |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
142 repo_model = RepoModel() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
143 repo = repo_model.get_by_repo_name(repo_name) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
144 if not repo: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
145 h.flash(_('%s repository is not mapped to db perhaps' |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
146 ' it was moved or renamed from the filesystem' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
147 ' please run the application again' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
148 ' in order to rescan repositories') % repo_name, |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
149 category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
150 |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
151 return redirect(url('home')) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
152 try: |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
153 action_logger(self.rhodecode_user, 'user_deleted_repo', |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
154 repo_name, '', self.sa) |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
155 repo_model.delete(repo) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
660
diff
changeset
|
156 invalidate_cache('get_repo_cached_%s' % repo_name) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
157 h.flash(_('deleted repository %s') % repo_name, category='success') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
158 except Exception: |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
159 h.flash(_('An error occurred during deletion of %s') % repo_name, |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
160 category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
161 |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
162 return redirect(url('home')) |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
163 |
1056
520d27f40b51
#113 removed anonymous access from forking, added system messages in login box.
Marcin Kuzminski <marcin@python-works.com>
parents:
1054
diff
changeset
|
164 @NotAnonymous() |
1060
97ed582ea86e
permission fixes for forking
Marcin Kuzminski <marcin@python-works.com>
parents:
1056
diff
changeset
|
165 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
97ed582ea86e
permission fixes for forking
Marcin Kuzminski <marcin@python-works.com>
parents:
1056
diff
changeset
|
166 'repository.admin') |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
167 def fork(self, repo_name): |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
168 repo_model = RepoModel() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
169 c.repo_info = repo = repo_model.get_by_repo_name(repo_name) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
170 if not repo: |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
171 h.flash(_('%s repository is not mapped to db perhaps' |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
832
diff
changeset
|
172 ' it was created or renamed from the file system' |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
173 ' please run the application again' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
174 ' in order to rescan repositories') % repo_name, |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
175 category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
176 |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
177 return redirect(url('home')) |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
178 |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
179 return render('settings/repo_fork.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
180 |
1056
520d27f40b51
#113 removed anonymous access from forking, added system messages in login box.
Marcin Kuzminski <marcin@python-works.com>
parents:
1054
diff
changeset
|
181 @NotAnonymous() |
1060
97ed582ea86e
permission fixes for forking
Marcin Kuzminski <marcin@python-works.com>
parents:
1056
diff
changeset
|
182 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
97ed582ea86e
permission fixes for forking
Marcin Kuzminski <marcin@python-works.com>
parents:
1056
diff
changeset
|
183 'repository.admin') |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
184 def fork_create(self, repo_name): |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
185 repo_model = RepoModel() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
186 c.repo_info = repo_model.get_by_repo_name(repo_name) |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
187 _form = RepoForkForm(old_data={'repo_type':c.repo_info.repo_type})() |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
188 form_result = {} |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
189 try: |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
190 form_result = _form.to_python(dict(request.POST)) |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
191 form_result.update({'repo_name':repo_name}) |
1121
f3f847712f87
replaced all global calls to template context (rhodecode_user), into instance attributes
Marcin Kuzminski <marcin@python-works.com>
parents:
1067
diff
changeset
|
192 repo_model.create_fork(form_result, self.rhodecode_user) |
718
7df3855bf6c7
Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
193 h.flash(_('forked %s repository as %s') \ |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
194 % (repo_name, form_result['fork_name']), |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
195 category='success') |
718
7df3855bf6c7
Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
196 action_logger(self.rhodecode_user, |
7df3855bf6c7
Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
197 'user_forked_repo:%s' % form_result['fork_name'], |
7df3855bf6c7
Added fork name to journal
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
198 repo_name, '', self.sa) |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
199 except formencode.Invalid, errors: |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
200 c.new_repo = errors.value['fork_name'] |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
201 r = render('settings/repo_fork.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
202 |
1067
717ccea6df18
fixed some very strange issue with htmlfill import - don't know why but this needs to be imported as separate module
Marcin Kuzminski <marcin@python-works.com>
parents:
1060
diff
changeset
|
203 return htmlfill.render( |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
204 r, |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
205 defaults=errors.value, |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
206 errors=errors.error_dict or {}, |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
207 prefix_error=False, |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
208 encoding="UTF-8") |
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
209 return redirect(url('home')) |