Mercurial > public > src > rhodecode
comparison pylons_app/controllers/settings.py @ 578:a08f610e545e
Implemented server side forks
added ability to pass session to user/repo models
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 01 Oct 2010 00:16:09 +0200 |
parents | 87d80c84df09 |
children | 48be953851fc |
comparison
equal
deleted
inserted
replaced
577:3a567e329fb6 | 578:a08f610e545e |
---|---|
27 from pylons.controllers.util import redirect | 27 from pylons.controllers.util import redirect |
28 from pylons.i18n.translation import _ | 28 from pylons.i18n.translation import _ |
29 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAllDecorator | 29 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAllDecorator |
30 from pylons_app.lib.base import BaseController, render | 30 from pylons_app.lib.base import BaseController, render |
31 from pylons_app.lib.utils import invalidate_cache | 31 from pylons_app.lib.utils import invalidate_cache |
32 from pylons_app.model.forms import RepoSettingsForm | 32 from pylons_app.model.forms import RepoSettingsForm, RepoForkForm |
33 from pylons_app.model.repo_model import RepoModel | 33 from pylons_app.model.repo_model import RepoModel |
34 import formencode | 34 import formencode |
35 import logging | 35 import logging |
36 import pylons_app.lib.helpers as h | 36 import pylons_app.lib.helpers as h |
37 import traceback | 37 import traceback |
138 ' it was created or renamed from the filesystem' | 138 ' it was created or renamed from the filesystem' |
139 ' please run the application again' | 139 ' please run the application again' |
140 ' in order to rescan repositories') % repo_name, | 140 ' in order to rescan repositories') % repo_name, |
141 category='error') | 141 category='error') |
142 | 142 |
143 return redirect(url('hg_home')) | 143 return redirect(url('hg_home')) |
144 | |
144 return render('settings/repo_fork.html') | 145 return render('settings/repo_fork.html') |
146 | |
147 | |
148 | |
149 def fork_create(self, repo_name): | |
150 repo_model = RepoModel() | |
151 c.repo_info = repo_model.get(repo_name) | |
152 _form = RepoForkForm()() | |
153 form_result = {} | |
154 try: | |
155 form_result = _form.to_python(dict(request.POST)) | |
156 form_result.update({'repo_name':repo_name}) | |
157 repo_model.create_fork(form_result, c.hg_app_user) | |
158 h.flash(_('fork %s repository as %s task added') \ | |
159 % (repo_name, form_result['fork_name']), | |
160 category='success') | |
161 | |
162 except formencode.Invalid as errors: | |
163 c.new_repo = errors.value['fork_name'] | |
164 r = render('settings/repo_fork.html') | |
165 | |
166 return htmlfill.render( | |
167 r, | |
168 defaults=errors.value, | |
169 errors=errors.error_dict or {}, | |
170 prefix_error=False, | |
171 encoding="UTF-8") | |
172 return redirect(url('hg_home')) |