##// END OF EJS Templates
repo-permissions: add set/un-set of private repository from permissions page....
dan -
r4189:021154b4 stable
parent child Browse files
Show More
@@ -28,6 +28,7 b' from rhodecode.lib import helpers as h'
28 28 from rhodecode.lib import audit_logger
29 29 from rhodecode.lib.auth import (
30 30 LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
31 from rhodecode.lib.utils2 import str2bool
31 32 from rhodecode.model.db import User
32 33 from rhodecode.model.forms import RepoPermsForm
33 34 from rhodecode.model.meta import Session
@@ -110,9 +111,11 b' class RepoSettingsPermissionsView(RepoAp'
110 111 _ = self.request.translate
111 112 self.load_default_context()
112 113
114 private_flag = str2bool(self.request.POST.get('private'))
115
113 116 try:
114 117 RepoModel().update(
115 self.db_repo, **{'repo_private': True, 'repo_name': self.db_repo_name})
118 self.db_repo, **{'repo_private': private_flag, 'repo_name': self.db_repo_name})
116 119 Session().commit()
117 120
118 121 h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
@@ -128,5 +131,5 b' class RepoSettingsPermissionsView(RepoAp'
128 131
129 132 return {
130 133 'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name),
131 'private': True
134 'private': private_flag
132 135 }
@@ -58,7 +58,11 b''
58 58 <td class="private_repo_msg">
59 59 ${base.gravatar(h.DEFAULT_USER_EMAIL, 16)}
60 60 ${h.DEFAULT_USER} - ${_('only users/user groups explicitly added here will have access')}</td>
61 <td></td>
61 <td class="td-action">
62 <span class="tooltip btn btn-link btn-default" onclick="setPrivateRepo(false); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators. Default permissions wont apply')}">
63 ${_('un-set private mode')}
64 </span>
65 </td>
62 66 <td class="quick_repo_menu">
63 67 % if c.rhodecode_user.is_admin:
64 68 <i class="icon-more"></i>
@@ -106,7 +110,7 b''
106 110 ${_('Remove')}
107 111 </span>
108 112 %elif _user.username == h.DEFAULT_USER:
109 <span class="tooltip btn btn-link btn-default" onclick="enablePrivateRepo(); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators.')}">
113 <span class="tooltip btn btn-link btn-default" onclick="setPrivateRepo(true); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators. Default permissions wont apply')}">
110 114 ${_('set private mode')}
111 115 </span>
112 116 %endif
@@ -204,9 +208,10 b''
204 208 });
205 209 quick_repo_menu();
206 210
207 var enablePrivateRepo = function () {
211 var setPrivateRepo = function (private) {
208 212 var postData = {
209 'csrf_token': CSRF_TOKEN
213 'csrf_token': CSRF_TOKEN,
214 'private': private
210 215 };
211 216
212 217 var success = function(o) {
General Comments 0
You need to be logged in to leave comments. Login now