Show More
@@ -114,21 +114,26 b' class RepoSettingsPermissionsView(RepoAp' | |||
|
114 | 114 | private_flag = str2bool(self.request.POST.get('private')) |
|
115 | 115 | |
|
116 | 116 | try: |
|
117 | RepoModel().update( | |
|
118 | self.db_repo, **{'repo_private': private_flag, 'repo_name': self.db_repo_name}) | |
|
117 | repo = RepoModel().get(self.db_repo.repo_id) | |
|
118 | repo.private = private_flag | |
|
119 | Session().add(repo) | |
|
120 | RepoModel().grant_user_permission( | |
|
121 | repo=self.db_repo, user=User.DEFAULT_USER, perm='repository.none' | |
|
122 | ) | |
|
123 | ||
|
119 | 124 | Session().commit() |
|
120 | 125 | |
|
121 | 126 | h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name), |
|
122 | 127 | category='success') |
|
128 | # NOTE(dan): we change repo private mode we need to notify all USERS | |
|
129 | affected_user_ids = User.get_all_user_ids() | |
|
130 | PermissionModel().trigger_permission_flush(affected_user_ids) | |
|
131 | ||
|
123 | 132 | except Exception: |
|
124 | 133 | log.exception("Exception during update of repository") |
|
125 | 134 | h.flash(_('Error occurred during update of repository {}').format( |
|
126 | 135 | self.db_repo_name), category='error') |
|
127 | 136 | |
|
128 | # NOTE(dan): we change repo private mode we need to notify all USERS | |
|
129 | affected_user_ids = User.get_all_user_ids() | |
|
130 | PermissionModel().trigger_permission_flush(affected_user_ids) | |
|
131 | ||
|
132 | 137 | return { |
|
133 | 138 | 'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name), |
|
134 | 139 | 'private': private_flag |
@@ -59,7 +59,7 b'' | |||
|
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 | 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')}"> | |
|
62 | <span class="noselect tooltip btn btn-link btn-default" onclick="setPrivateRepo(this, false); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators. Default permissions wont apply')}"> | |
|
63 | 63 | ${_('un-set private mode')} |
|
64 | 64 | </span> |
|
65 | 65 | </td> |
@@ -115,7 +115,7 b'' | |||
|
115 | 115 | ${_('Remove')} |
|
116 | 116 | </span> |
|
117 | 117 | %elif _user.username == h.DEFAULT_USER: |
|
118 | <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')}"> | |
|
118 | <span class="noselect tooltip btn btn-link btn-default" onclick="setPrivateRepo(this, true); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators. Default permissions wont apply')}"> | |
|
119 | 119 | ${_('set private mode')} |
|
120 | 120 | </span> |
|
121 | 121 | %endif |
@@ -213,7 +213,14 b'' | |||
|
213 | 213 | }); |
|
214 | 214 | quick_repo_menu(); |
|
215 | 215 | |
|
216 | var setPrivateRepo = function (private) { | |
|
216 | var setPrivateRepo = function (elem, private) { | |
|
217 | var $elem = $(elem) | |
|
218 | if ($elem.hasClass('disabled')) { | |
|
219 | return | |
|
220 | } | |
|
221 | $elem.addClass('disabled'); | |
|
222 | $elem.css({"opacity": 0.3}) | |
|
223 | ||
|
217 | 224 | var postData = { |
|
218 | 225 | 'csrf_token': CSRF_TOKEN, |
|
219 | 226 | 'private': private |
General Comments 0
You need to be logged in to leave comments.
Login now