##// 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 from rhodecode.lib import audit_logger
28 from rhodecode.lib import audit_logger
29 from rhodecode.lib.auth import (
29 from rhodecode.lib.auth import (
30 LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
30 LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
31 from rhodecode.lib.utils2 import str2bool
31 from rhodecode.model.db import User
32 from rhodecode.model.db import User
32 from rhodecode.model.forms import RepoPermsForm
33 from rhodecode.model.forms import RepoPermsForm
33 from rhodecode.model.meta import Session
34 from rhodecode.model.meta import Session
@@ -110,9 +111,11 b' class RepoSettingsPermissionsView(RepoAp'
110 _ = self.request.translate
111 _ = self.request.translate
111 self.load_default_context()
112 self.load_default_context()
112
113
114 private_flag = str2bool(self.request.POST.get('private'))
115
113 try:
116 try:
114 RepoModel().update(
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 Session().commit()
119 Session().commit()
117
120
118 h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
121 h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
@@ -128,5 +131,5 b' class RepoSettingsPermissionsView(RepoAp'
128
131
129 return {
132 return {
130 'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name),
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 <td class="private_repo_msg">
58 <td class="private_repo_msg">
59 ${base.gravatar(h.DEFAULT_USER_EMAIL, 16)}
59 ${base.gravatar(h.DEFAULT_USER_EMAIL, 16)}
60 ${h.DEFAULT_USER} - ${_('only users/user groups explicitly added here will have access')}</td>
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 <td class="quick_repo_menu">
66 <td class="quick_repo_menu">
63 % if c.rhodecode_user.is_admin:
67 % if c.rhodecode_user.is_admin:
64 <i class="icon-more"></i>
68 <i class="icon-more"></i>
@@ -106,7 +110,7 b''
106 ${_('Remove')}
110 ${_('Remove')}
107 </span>
111 </span>
108 %elif _user.username == h.DEFAULT_USER:
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 ${_('set private mode')}
114 ${_('set private mode')}
111 </span>
115 </span>
112 %endif
116 %endif
@@ -204,9 +208,10 b''
204 });
208 });
205 quick_repo_menu();
209 quick_repo_menu();
206
210
207 var enablePrivateRepo = function () {
211 var setPrivateRepo = function (private) {
208 var postData = {
212 var postData = {
209 'csrf_token': CSRF_TOKEN
213 'csrf_token': CSRF_TOKEN,
214 'private': private
210 };
215 };
211
216
212 var success = function(o) {
217 var success = function(o) {
General Comments 0
You need to be logged in to leave comments. Login now