Mercurial > kallithea
annotate rhodecode/controllers/settings.py @ 3503:7adeca7b99c2 beta
root.html: IE do not like extra ',' in maps
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 07 Mar 2013 15:23:36 +0100 |
parents | 72a91632b731 |
children | af96fb19b53a |
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 |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
7 |
861
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 |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
10 :copyright: (C) 2010-2012 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 """ |
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:
1121
diff
changeset
|
17 # |
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
|
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. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
22 # |
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
|
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/>. |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
25 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
26 import logging |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
27 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
|
28 import formencode |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
29 |
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 from formencode import htmlfill |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
31 |
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
|
32 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
|
33 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
|
34 from pylons.i18n.translation import _ |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
35 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
36 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
|
37 |
2833
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
38 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator,\ |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
39 HasRepoPermissionAnyDecorator |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1015
diff
changeset
|
40 from rhodecode.lib.base import BaseRepoController, render |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
41 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
|
42 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
43 from rhodecode.model.forms import RepoSettingsForm |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
44 from rhodecode.model.repo import RepoModel |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
45 from rhodecode.model.db import RepoGroup, Repository, RepositoryField |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
46 from rhodecode.model.meta import Session |
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:
3110
diff
changeset
|
47 from rhodecode.model.scm import ScmModel, GroupList |
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 |
1212 | 51 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1015
diff
changeset
|
52 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
|
53 |
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 @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
|
55 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
|
56 super(SettingsController, self).__before__() |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
57 |
1594 | 58 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:
3110
diff
changeset
|
59 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:
3110
diff
changeset
|
60 perm_set=['group.write', 'group.admin']) |
a9565b8b429b
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper
Marcin Kuzminski <marcin@python-works.com>
parents:
3110
diff
changeset
|
61 c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) |
1594 | 62 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
|
63 |
1594 | 64 repo_model = RepoModel() |
65 c.users_array = repo_model.get_users_js() | |
66 c.users_groups_array = repo_model.get_users_groups_js() | |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
67 choices, c.landing_revs = ScmModel().get_repo_landing_revs() |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
68 c.landing_revs_choices = choices |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
69 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
70 def __load_data(self, repo_name=None): |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
71 """ |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
72 Load defaults settings for edit, and update |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
73 |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
74 :param repo_name: |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
75 """ |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
76 self.__load_defaults() |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
77 |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
78 c.repo_info = db_repo = Repository.get_by_repo_name(repo_name) |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
79 |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
80 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
|
81 h.not_mapped_error(repo_name) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
82 return redirect(url('home')) |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
83 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
84 ##override defaults for exact repo info here git/hg etc |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
85 choices, c.landing_revs = ScmModel().get_repo_landing_revs(c.repo_info) |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
86 c.landing_revs_choices = choices |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
87 c.repo_fields = RepositoryField.query()\ |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
88 .filter(RepositoryField.repository == db_repo).all() |
1594 | 89 defaults = RepoModel()._get_defaults(repo_name) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
90 |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
91 return defaults |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
92 |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
93 @HasRepoPermissionAllDecorator('repository.admin') |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
94 def index(self, repo_name): |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
95 defaults = self.__load_data(repo_name) |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
96 |
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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 force_defaults=False |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
102 ) |
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
|
103 |
1054
32dbf759fa98
fixed #113 to high permission was required to fork a repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
104 @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
|
105 def update(self, repo_name): |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
106 self.__load_defaults() |
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
|
107 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
|
108 changed_name = repo_name |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
109 #override the choices with extracted revisions ! |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
110 choices, c.landing_revs = ScmModel().get_repo_landing_revs(repo_name) |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
111 c.landing_revs_choices = choices |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
112 |
1212 | 113 _form = RepoSettingsForm(edit=True, |
1594 | 114 old_data={'repo_name': repo_name}, |
2460
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
115 repo_groups=c.repo_groups_choices, |
12fa0c19c42f
validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents:
2375
diff
changeset
|
116 landing_revs=c.landing_revs_choices)() |
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
|
117 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
|
118 form_result = _form.to_python(dict(request.POST)) |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
119 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
|
120 invalidate_cache('get_repo_cached_%s' % repo_name) |
2570 | 121 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
|
122 category='success') |
1594 | 123 changed_name = form_result['repo_name_full'] |
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
|
124 action_logger(self.rhodecode_user, 'user_updated_repo', |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
125 changed_name, self.ip_addr, self.sa) |
2833
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
126 Session().commit() |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
127 except formencode.Invalid, errors: |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
128 defaults = self.__load_data(repo_name) |
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
129 defaults.update(errors.value) |
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
|
130 return htmlfill.render( |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
131 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
|
132 defaults=errors.value, |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
133 errors=errors.error_dict or {}, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
134 prefix_error=False, |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
135 encoding="UTF-8") |
3089
4cc9bb83ecb4
Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents:
3083
diff
changeset
|
136 |
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
|
137 except Exception: |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
138 log.error(traceback.format_exc()) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
660
diff
changeset
|
139 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
|
140 % repo_name, category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
141 |
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
|
142 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
|
143 |
1054
32dbf759fa98
fixed #113 to high permission was required to fork a repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
144 @HasRepoPermissionAllDecorator('repository.admin') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
145 def delete(self, repo_name): |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
146 """DELETE /repos/repo_name: Delete an existing item""" |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
147 # 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
|
148 # <input type="hidden" name="_method" value="DELETE" /> |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
149 # Or using helpers: |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
150 # 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
|
151 # method='delete') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
152 # 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
|
153 |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
154 repo_model = RepoModel() |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
718
diff
changeset
|
155 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
|
156 if not repo: |
3110
144128efc6ab
- #683 fixed difference between messages about not mapped repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3089
diff
changeset
|
157 h.not_mapped_error(repo_name) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
158 return redirect(url('home')) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
159 try: |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
160 action_logger(self.rhodecode_user, 'user_deleted_repo', |
2375
bc2d8c03c050
Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
161 repo_name, self.ip_addr, self.sa) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
162 repo_model.delete(repo) |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
660
diff
changeset
|
163 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
|
164 h.flash(_('deleted repository %s') % repo_name, category='success') |
2833
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
165 Session().commit() |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
166 except Exception: |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
167 log.error(traceback.format_exc()) |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
168 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
|
169 category='error') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
170 |
3083
98e8fd2d55b6
fixes issue #675 Don't Re-direct from "My Repos" page when deleting a repository
Marcin Kuzminski <marcin@python-works.com>
parents:
2907
diff
changeset
|
171 return redirect(url('admin_settings_my_account', anchor='my')) |
2833
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
172 |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
173 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin') |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
174 def toggle_locking(self, repo_name): |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
175 """ |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
176 Toggle locking of repository by simple GET call to url |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
177 |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
178 :param repo_name: |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
179 """ |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
180 |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
181 try: |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
182 repo = Repository.get_by_repo_name(repo_name) |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
183 |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
184 if repo.enable_locking: |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
185 if repo.locked[0]: |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
186 Repository.unlock(repo) |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
187 action = _('unlocked') |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
188 else: |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
189 Repository.lock(repo, c.rhodecode_user.user_id) |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
190 action = _('locked') |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
191 |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
192 h.flash(_('Repository has been %s') % action, |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
193 category='success') |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
194 except Exception, e: |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
195 log.error(traceback.format_exc()) |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
196 h.flash(_('An error occurred during unlocking'), |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
197 category='error') |
2f3cba7b6d16
Add quick toggle link for locking for users with write or admin permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
2570
diff
changeset
|
198 return redirect(url('summary_home', repo_name=repo_name)) |