Mercurial > kallithea
comparison rhodecode/controllers/settings.py @ 1045:3fc9183e05dd beta
another major codes rewrite:
- created BaseRepo controller for all repo specific controller, and added common data propagation
- removed obosete codes, and made optimizations, removed to often calls to RepoModel
- fixed found bugs in files controller that generated unhandled 500 errors
- cache issues
- removed repo_branches global template values
- journal fixes
- main repo list is fully dict now it's less resource heavy that way
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 15 Feb 2011 01:36:07 +0100 |
parents | 65129c332d37 |
children | 32dbf759fa98 |
comparison
equal
deleted
inserted
replaced
1044:f3402cb92fdf | 1045:3fc9183e05dd |
---|---|
27 | 27 |
28 import logging | 28 import logging |
29 import traceback | 29 import traceback |
30 | 30 |
31 import formencode | 31 import formencode |
32 from formencode import htmlfill | |
33 | 32 |
34 from pylons import tmpl_context as c, request, url | 33 from pylons import tmpl_context as c, request, url |
35 from pylons.controllers.util import redirect | 34 from pylons.controllers.util import redirect |
36 from pylons.i18n.translation import _ | 35 from pylons.i18n.translation import _ |
37 | 36 |
38 import rhodecode.lib.helpers as h | 37 import rhodecode.lib.helpers as h |
39 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator | 38 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator |
40 from rhodecode.lib.base import BaseController, render | 39 from rhodecode.lib.base import BaseRepoController, render |
41 from rhodecode.lib.utils import invalidate_cache, action_logger | 40 from rhodecode.lib.utils import invalidate_cache, action_logger |
42 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm | 41 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm |
43 from rhodecode.model.repo import RepoModel | 42 from rhodecode.model.repo import RepoModel |
44 from rhodecode.model.db import User | 43 from rhodecode.model.db import User |
45 | 44 |
46 log = logging.getLogger(__name__) | 45 log = logging.getLogger(__name__) |
47 | 46 |
48 class SettingsController(BaseController): | 47 class SettingsController(BaseRepoController): |
49 | 48 |
50 @LoginRequired() | 49 @LoginRequired() |
51 @HasRepoPermissionAllDecorator('repository.admin') | 50 @HasRepoPermissionAllDecorator('repository.admin') |
52 def __before__(self): | 51 def __before__(self): |
53 super(SettingsController, self).__before__() | 52 super(SettingsController, self).__before__() |
85 #fill repository groups | 84 #fill repository groups |
86 for p in c.repo_info.users_group_to_perm: | 85 for p in c.repo_info.users_group_to_perm: |
87 defaults.update({'g_perm_%s' % p.users_group.users_group_name: | 86 defaults.update({'g_perm_%s' % p.users_group.users_group_name: |
88 p.permission.permission_name}) | 87 p.permission.permission_name}) |
89 | 88 |
90 return htmlfill.render( | 89 return formencode.htmlfill.render( |
91 render('settings/repo_settings.html'), | 90 render('settings/repo_settings.html'), |
92 defaults=defaults, | 91 defaults=defaults, |
93 encoding="UTF-8", | 92 encoding="UTF-8", |
94 force_defaults=False | 93 force_defaults=False |
95 ) | 94 ) |
109 changed_name, '', self.sa) | 108 changed_name, '', self.sa) |
110 except formencode.Invalid, errors: | 109 except formencode.Invalid, errors: |
111 c.repo_info = repo_model.get_by_repo_name(repo_name) | 110 c.repo_info = repo_model.get_by_repo_name(repo_name) |
112 c.users_array = repo_model.get_users_js() | 111 c.users_array = repo_model.get_users_js() |
113 errors.value.update({'user':c.repo_info.user.username}) | 112 errors.value.update({'user':c.repo_info.user.username}) |
114 return htmlfill.render( | 113 return formencode.htmlfill.render( |
115 render('settings/repo_settings.html'), | 114 render('settings/repo_settings.html'), |
116 defaults=errors.value, | 115 defaults=errors.value, |
117 errors=errors.error_dict or {}, | 116 errors=errors.error_dict or {}, |
118 prefix_error=False, | 117 prefix_error=False, |
119 encoding="UTF-8") | 118 encoding="UTF-8") |
190 repo_name, '', self.sa) | 189 repo_name, '', self.sa) |
191 except formencode.Invalid, errors: | 190 except formencode.Invalid, errors: |
192 c.new_repo = errors.value['fork_name'] | 191 c.new_repo = errors.value['fork_name'] |
193 r = render('settings/repo_fork.html') | 192 r = render('settings/repo_fork.html') |
194 | 193 |
195 return htmlfill.render( | 194 return formencode.htmlfill.render( |
196 r, | 195 r, |
197 defaults=errors.value, | 196 defaults=errors.value, |
198 errors=errors.error_dict or {}, | 197 errors=errors.error_dict or {}, |
199 prefix_error=False, | 198 prefix_error=False, |
200 encoding="UTF-8") | 199 encoding="UTF-8") |