Mercurial > kallithea
annotate rhodecode/controllers/settings.py @ 561:5f3b967d9d10
fixed reindexing, and made some optimizations to reuse repo instances from repo scann list.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 09 Oct 2010 01:11:44 +0200 |
parents | b75b77ef649d |
children | ba7e24cd4786 |
rev | line source |
---|---|
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
|
1 #!/usr/bin/env python |
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
|
2 # 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
|
3 # settings controller for pylons |
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
|
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
5 # |
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
|
6 # 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
|
7 # 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
|
8 # 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
|
9 # 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
|
10 # |
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
|
11 # 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
|
12 # 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
|
13 # 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
|
14 # 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
|
15 # |
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 # 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
|
17 # 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
|
18 # 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
|
19 # MA 02110-1301, USA. |
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
|
20 """ |
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
|
21 Created on June 30, 2010 |
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
|
22 settings controller for pylons |
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
|
23 @author: marcink |
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
|
24 """ |
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
|
25 from formencode import htmlfill |
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 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
|
27 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
|
28 from pylons.i18n.translation import _ |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
29 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
30 from rhodecode.lib.base import BaseController, render |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
31 from rhodecode.lib.utils import invalidate_cache, action_logger |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
32 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
33 from rhodecode.model.repo_model import RepoModel |
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 import formencode |
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 import logging |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
36 import rhodecode.lib.helpers as h |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
37 import traceback |
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
|
38 |
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
|
39 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
|
40 |
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
|
41 class SettingsController(BaseController): |
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
|
42 |
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
|
43 @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
|
44 @HasRepoPermissionAllDecorator('repository.admin') |
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
|
45 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
|
46 super(SettingsController, self).__before__() |
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
|
47 |
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
|
48 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
|
49 repo_model = RepoModel() |
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 c.repo_info = repo = repo_model.get(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
|
51 if not repo: |
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 h.flash(_('%s repository is not mapped to db perhaps' |
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 ' it was created or renamed from the filesystem' |
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 ' 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
|
55 ' 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
|
56 category='error') |
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
|
57 |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
58 return redirect(url('hg_home')) |
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
|
59 defaults = c.repo_info.__dict__ |
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
|
60 defaults.update({'user':c.repo_info.user.username}) |
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 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
|
62 |
399
f5c1eec9f376
rename repo2perm into repo_to_perm
Marcin Kuzminski <marcin@python-works.com>
parents:
367
diff
changeset
|
63 for p in c.repo_info.repo_to_perm: |
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 defaults.update({'perm_%s' % p.user.username: |
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 p.permission.permission_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 |
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
|
67 return htmlfill.render( |
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
|
68 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
|
69 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
|
70 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
|
71 force_defaults=False |
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
|
72 ) |
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
|
73 |
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
|
74 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
|
75 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
|
76 changed_name = repo_name |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
77 _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
|
78 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
|
79 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
|
80 repo_model.update(repo_name, form_result) |
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
|
81 invalidate_cache('cached_repo_list') |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
82 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
|
83 category='success') |
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
|
84 changed_name = form_result['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
|
85 except formencode.Invalid as errors: |
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
|
86 c.repo_info = repo_model.get(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
|
87 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
|
88 errors.value.update({'user':c.repo_info.user.username}) |
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
|
89 return htmlfill.render( |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
90 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
|
91 defaults=errors.value, |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
92 errors=errors.error_dict or {}, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
93 prefix_error=False, |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
94 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
|
95 except Exception: |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
96 log.error(traceback.format_exc()) |
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
|
97 h.flash(_('error occured 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
|
98 % repo_name, category='error') |
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 |
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
|
100 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
|
101 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
102 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
103 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
104 def delete(self, repo_name): |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
105 """DELETE /repos/repo_name: Delete an existing item""" |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
106 # 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
|
107 # <input type="hidden" name="_method" value="DELETE" /> |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
108 # Or using helpers: |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
109 # 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
|
110 # method='delete') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
111 # url('repo_settings_delete', repo_name=ID) |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
112 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
113 repo_model = RepoModel() |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
114 repo = repo_model.get(repo_name) |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
115 if not repo: |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
116 h.flash(_('%s repository is not mapped to db perhaps' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
117 ' it was moved or renamed from the filesystem' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
118 ' please run the application again' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
119 ' in order to rescan repositories') % repo_name, |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
120 category='error') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
121 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
122 return redirect(url('hg_home')) |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
123 try: |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
124 action_logger(self.rhodecode_user, 'user_deleted_repo', |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
125 repo_name, '', self.sa) |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
126 repo_model.delete(repo) |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
127 invalidate_cache('cached_repo_list') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
128 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
|
129 except Exception: |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
130 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
|
131 category='error') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
132 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
133 return redirect(url('hg_home')) |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
134 |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
135 def fork(self, repo_name): |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
136 repo_model = RepoModel() |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
137 c.repo_info = repo = repo_model.get(repo_name) |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
138 if not repo: |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
139 h.flash(_('%s repository is not mapped to db perhaps' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
140 ' it was created or renamed from the filesystem' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
141 ' please run the application again' |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
142 ' in order to rescan repositories') % repo_name, |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
143 category='error') |
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
144 |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
145 return redirect(url('hg_home')) |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
146 |
525
87d80c84df09
added search in specific repository
Marcin Kuzminski <marcin@python-works.com>
parents:
399
diff
changeset
|
147 return render('settings/repo_fork.html') |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
148 |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
149 |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
150 |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
151 def fork_create(self, repo_name): |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
152 repo_model = RepoModel() |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
153 c.repo_info = repo_model.get(repo_name) |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
154 _form = RepoForkForm()() |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
155 form_result = {} |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
156 try: |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
157 form_result = _form.to_python(dict(request.POST)) |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
158 form_result.update({'repo_name':repo_name}) |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
159 repo_model.create_fork(form_result, c.rhodecode_user) |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
160 h.flash(_('fork %s repository as %s task added') \ |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
161 % (repo_name, form_result['fork_name']), |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
162 category='success') |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
163 action_logger(self.rhodecode_user, 'user_forked_repo', |
537
48be953851fc
extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
164 repo_name, '', self.sa) |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
165 except formencode.Invalid as errors: |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
166 c.new_repo = errors.value['fork_name'] |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
167 r = render('settings/repo_fork.html') |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
168 |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
169 return htmlfill.render( |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
170 r, |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
171 defaults=errors.value, |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
172 errors=errors.error_dict or {}, |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
173 prefix_error=False, |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
174 encoding="UTF-8") |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
525
diff
changeset
|
175 return redirect(url('hg_home')) |