Show More
@@ -141,6 +141,7 b' def make_map(config):' | |||||
141 | m.connect('repo_locking', "/repo_locking/{repo_name:.*?}", |
|
141 | m.connect('repo_locking', "/repo_locking/{repo_name:.*?}", | |
142 | action="repo_locking", conditions=dict(method=["PUT"], |
|
142 | action="repo_locking", conditions=dict(method=["PUT"], | |
143 | function=check_repo)) |
|
143 | function=check_repo)) | |
|
144 | ||||
144 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
145 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
145 | controller='admin/repos_groups') as m: |
|
146 | controller='admin/repos_groups') as m: | |
146 | m.connect("repos_groups", "/repos_groups", |
|
147 | m.connect("repos_groups", "/repos_groups", | |
@@ -561,6 +562,10 b' def make_map(config):' | |||||
561 | controller='settings', action='index', |
|
562 | controller='settings', action='index', | |
562 | conditions=dict(function=check_repo)) |
|
563 | conditions=dict(function=check_repo)) | |
563 |
|
564 | |||
|
565 | rmap.connect('toggle_locking', "/{repo_name:.*?}/locking_toggle", | |||
|
566 | controller='settings', action="toggle_locking", | |||
|
567 | conditions=dict(method=["GET"], function=check_repo)) | |||
|
568 | ||||
564 | rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork', |
|
569 | rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork', | |
565 | controller='forks', action='fork_create', |
|
570 | controller='forks', action='fork_create', | |
566 | conditions=dict(function=check_repo, method=["POST"])) |
|
571 | conditions=dict(function=check_repo, method=["POST"])) |
@@ -35,13 +35,14 b' from pylons.i18n.translation import _' | |||||
35 |
|
35 | |||
36 | import rhodecode.lib.helpers as h |
|
36 | import rhodecode.lib.helpers as h | |
37 |
|
37 | |||
38 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator |
|
38 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator,\ | |
|
39 | HasRepoPermissionAnyDecorator | |||
39 | from rhodecode.lib.base import BaseRepoController, render |
|
40 | from rhodecode.lib.base import BaseRepoController, render | |
40 | from rhodecode.lib.utils import invalidate_cache, action_logger |
|
41 | from rhodecode.lib.utils import invalidate_cache, action_logger | |
41 |
|
42 | |||
42 | from rhodecode.model.forms import RepoSettingsForm |
|
43 | from rhodecode.model.forms import RepoSettingsForm | |
43 | from rhodecode.model.repo import RepoModel |
|
44 | from rhodecode.model.repo import RepoModel | |
44 | from rhodecode.model.db import RepoGroup |
|
45 | from rhodecode.model.db import RepoGroup, Repository | |
45 | from rhodecode.model.meta import Session |
|
46 | from rhodecode.model.meta import Session | |
46 | from rhodecode.model.scm import ScmModel |
|
47 | from rhodecode.model.scm import ScmModel | |
47 |
|
48 | |||
@@ -109,7 +110,7 b' class SettingsController(BaseRepoControl' | |||||
109 | changed_name = form_result['repo_name_full'] |
|
110 | changed_name = form_result['repo_name_full'] | |
110 | action_logger(self.rhodecode_user, 'user_updated_repo', |
|
111 | action_logger(self.rhodecode_user, 'user_updated_repo', | |
111 | changed_name, self.ip_addr, self.sa) |
|
112 | changed_name, self.ip_addr, self.sa) | |
112 | Session.commit() |
|
113 | Session().commit() | |
113 | except formencode.Invalid, errors: |
|
114 | except formencode.Invalid, errors: | |
114 | c.repo_info = repo_model.get_by_repo_name(repo_name) |
|
115 | c.repo_info = repo_model.get_by_repo_name(repo_name) | |
115 | c.users_array = repo_model.get_users_js() |
|
116 | c.users_array = repo_model.get_users_js() | |
@@ -153,10 +154,38 b' class SettingsController(BaseRepoControl' | |||||
153 | repo_model.delete(repo) |
|
154 | repo_model.delete(repo) | |
154 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
155 | invalidate_cache('get_repo_cached_%s' % repo_name) | |
155 | h.flash(_('deleted repository %s') % repo_name, category='success') |
|
156 | h.flash(_('deleted repository %s') % repo_name, category='success') | |
156 | Session.commit() |
|
157 | Session().commit() | |
157 | except Exception: |
|
158 | except Exception: | |
158 | log.error(traceback.format_exc()) |
|
159 | log.error(traceback.format_exc()) | |
159 | h.flash(_('An error occurred during deletion of %s') % repo_name, |
|
160 | h.flash(_('An error occurred during deletion of %s') % repo_name, | |
160 | category='error') |
|
161 | category='error') | |
161 |
|
162 | |||
162 | return redirect(url('home')) |
|
163 | return redirect(url('home')) | |
|
164 | ||||
|
165 | @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin') | |||
|
166 | def toggle_locking(self, repo_name): | |||
|
167 | """ | |||
|
168 | Toggle locking of repository by simple GET call to url | |||
|
169 | ||||
|
170 | :param repo_name: | |||
|
171 | """ | |||
|
172 | ||||
|
173 | try: | |||
|
174 | repo = Repository.get_by_repo_name(repo_name) | |||
|
175 | ||||
|
176 | if repo.enable_locking: | |||
|
177 | if repo.locked[0]: | |||
|
178 | Repository.unlock(repo) | |||
|
179 | action = _('unlocked') | |||
|
180 | else: | |||
|
181 | Repository.lock(repo, c.rhodecode_user.user_id) | |||
|
182 | action = _('locked') | |||
|
183 | ||||
|
184 | h.flash(_('Repository has been %s') % action, | |||
|
185 | category='success') | |||
|
186 | except Exception, e: | |||
|
187 | log.error(traceback.format_exc()) | |||
|
188 | h.flash(_('An error occurred during unlocking'), | |||
|
189 | category='error') | |||
|
190 | return redirect(url('summary_home', repo_name=repo_name)) | |||
|
191 |
@@ -658,6 +658,24 b' div:hover > a.permalink {' | |||||
658 | padding: 12px 9px 7px 24px; |
|
658 | padding: 12px 9px 7px 24px; | |
659 | } |
|
659 | } | |
660 |
|
660 | |||
|
661 | #header #header-inner #quick li ul li a.locking_add,#header #header-inner #quick li ul li a.locking_add:hover | |||
|
662 | { | |||
|
663 | background: #FFF url("../images/icons/lock_add.png") no-repeat 4px | |||
|
664 | 9px; | |||
|
665 | width: 167px; | |||
|
666 | margin: 0; | |||
|
667 | padding: 12px 9px 7px 24px; | |||
|
668 | } | |||
|
669 | ||||
|
670 | #header #header-inner #quick li ul li a.locking_del,#header #header-inner #quick li ul li a.locking_del:hover | |||
|
671 | { | |||
|
672 | background: #FFF url("../images/icons/lock_delete.png") no-repeat 4px | |||
|
673 | 9px; | |||
|
674 | width: 167px; | |||
|
675 | margin: 0; | |||
|
676 | padding: 12px 9px 7px 24px; | |||
|
677 | } | |||
|
678 | ||||
661 | #header #header-inner #quick li ul li a.pull_request,#header #header-inner #quick li ul li a.pull_request:hover |
|
679 | #header #header-inner #quick li ul li a.pull_request,#header #header-inner #quick li ul li a.pull_request:hover | |
662 | { |
|
680 | { | |
663 | background: #FFF url("../images/icons/arrow_join.png") no-repeat 4px |
|
681 | background: #FFF url("../images/icons/arrow_join.png") no-repeat 4px |
@@ -206,12 +206,21 b'' | |||||
206 | <li>${h.link_to(_('settings'),h.url('repo_settings_home',repo_name=c.repo_name),class_='settings')}</li> |
|
206 | <li>${h.link_to(_('settings'),h.url('repo_settings_home',repo_name=c.repo_name),class_='settings')}</li> | |
207 | %endif |
|
207 | %endif | |
208 | %endif |
|
208 | %endif | |
|
209 | ||||
209 | <li>${h.link_to(_('fork'),h.url('repo_fork_home',repo_name=c.repo_name),class_='fork')}</li> |
|
210 | <li>${h.link_to(_('fork'),h.url('repo_fork_home',repo_name=c.repo_name),class_='fork')}</li> | |
210 | %if h.is_hg(c.rhodecode_repo): |
|
211 | %if h.is_hg(c.rhodecode_repo): | |
211 | <li>${h.link_to(_('Open new pull request'),h.url('pullrequest_home',repo_name=c.repo_name),class_='pull_request')}</li> |
|
212 | <li>${h.link_to(_('Open new pull request'),h.url('pullrequest_home',repo_name=c.repo_name),class_='pull_request')}</li> | |
212 | %endif |
|
213 | %endif | |
213 | <li>${h.link_to(_('search'),h.url('search_repo',search_repo=c.repo_name),class_='search')}</li> |
|
214 | <li>${h.link_to(_('search'),h.url('search_repo',search_repo=c.repo_name),class_='search')}</li> | |
214 |
|
215 | |||
|
216 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking: | |||
|
217 | %if c.rhodecode_db_repo.locked[0]: | |||
|
218 | <li>${h.link_to(_('unlock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_del')}</li> | |||
|
219 | %else: | |||
|
220 | <li>${h.link_to(_('lock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_add')}</li> | |||
|
221 | %endif | |||
|
222 | %endif | |||
|
223 | ||||
215 | % if h.HasPermissionAll('hg.admin')('access admin main page'): |
|
224 | % if h.HasPermissionAll('hg.admin')('access admin main page'): | |
216 | <li> |
|
225 | <li> | |
217 | ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')} |
|
226 | ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')} | |
@@ -227,7 +236,7 b'' | |||||
227 | <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li> |
|
236 | <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li> | |
228 | </ul> |
|
237 | </ul> | |
229 | </%def> |
|
238 | </%def> | |
230 |
|
239 | ## ADMIN MENU | ||
231 | ${admin_menu()} |
|
240 | ${admin_menu()} | |
232 | </li> |
|
241 | </li> | |
233 | % endif |
|
242 | % endif |
General Comments 0
You need to be logged in to leave comments.
Login now