Show More
@@ -1,132 +1,135 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2011-2019 RhodeCode GmbH |
|
3 | # Copyright (C) 2011-2019 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import logging |
|
21 | import logging | |
22 |
|
22 | |||
23 | from pyramid.httpexceptions import HTTPFound |
|
23 | from pyramid.httpexceptions import HTTPFound | |
24 | from pyramid.view import view_config |
|
24 | from pyramid.view import view_config | |
25 |
|
25 | |||
26 | from rhodecode.apps._base import RepoAppView |
|
26 | from rhodecode.apps._base import RepoAppView | |
27 | from rhodecode.lib import helpers as h |
|
27 | 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 | |
34 | from rhodecode.model.permission import PermissionModel |
|
35 | from rhodecode.model.permission import PermissionModel | |
35 | from rhodecode.model.repo import RepoModel |
|
36 | from rhodecode.model.repo import RepoModel | |
36 |
|
37 | |||
37 | log = logging.getLogger(__name__) |
|
38 | log = logging.getLogger(__name__) | |
38 |
|
39 | |||
39 |
|
40 | |||
40 | class RepoSettingsPermissionsView(RepoAppView): |
|
41 | class RepoSettingsPermissionsView(RepoAppView): | |
41 |
|
42 | |||
42 | def load_default_context(self): |
|
43 | def load_default_context(self): | |
43 | c = self._get_local_tmpl_context() |
|
44 | c = self._get_local_tmpl_context() | |
44 | return c |
|
45 | return c | |
45 |
|
46 | |||
46 | @LoginRequired() |
|
47 | @LoginRequired() | |
47 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
48 | @HasRepoPermissionAnyDecorator('repository.admin') | |
48 | @view_config( |
|
49 | @view_config( | |
49 | route_name='edit_repo_perms', request_method='GET', |
|
50 | route_name='edit_repo_perms', request_method='GET', | |
50 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
51 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
51 | def edit_permissions(self): |
|
52 | def edit_permissions(self): | |
52 | _ = self.request.translate |
|
53 | _ = self.request.translate | |
53 | c = self.load_default_context() |
|
54 | c = self.load_default_context() | |
54 | c.active = 'permissions' |
|
55 | c.active = 'permissions' | |
55 | if self.request.GET.get('branch_permissions'): |
|
56 | if self.request.GET.get('branch_permissions'): | |
56 | h.flash(_('Explicitly add user or user group with write+ ' |
|
57 | h.flash(_('Explicitly add user or user group with write+ ' | |
57 | 'permission to modify their branch permissions.'), |
|
58 | 'permission to modify their branch permissions.'), | |
58 | category='notice') |
|
59 | category='notice') | |
59 | return self._get_template_context(c) |
|
60 | return self._get_template_context(c) | |
60 |
|
61 | |||
61 | @LoginRequired() |
|
62 | @LoginRequired() | |
62 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
63 | @HasRepoPermissionAnyDecorator('repository.admin') | |
63 | @CSRFRequired() |
|
64 | @CSRFRequired() | |
64 | @view_config( |
|
65 | @view_config( | |
65 | route_name='edit_repo_perms', request_method='POST', |
|
66 | route_name='edit_repo_perms', request_method='POST', | |
66 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
67 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
67 | def edit_permissions_update(self): |
|
68 | def edit_permissions_update(self): | |
68 | _ = self.request.translate |
|
69 | _ = self.request.translate | |
69 | c = self.load_default_context() |
|
70 | c = self.load_default_context() | |
70 | c.active = 'permissions' |
|
71 | c.active = 'permissions' | |
71 | data = self.request.POST |
|
72 | data = self.request.POST | |
72 | # store private flag outside of HTML to verify if we can modify |
|
73 | # store private flag outside of HTML to verify if we can modify | |
73 | # default user permissions, prevents submission of FAKE post data |
|
74 | # default user permissions, prevents submission of FAKE post data | |
74 | # into the form for private repos |
|
75 | # into the form for private repos | |
75 | data['repo_private'] = self.db_repo.private |
|
76 | data['repo_private'] = self.db_repo.private | |
76 | form = RepoPermsForm(self.request.translate)().to_python(data) |
|
77 | form = RepoPermsForm(self.request.translate)().to_python(data) | |
77 | changes = RepoModel().update_permissions( |
|
78 | changes = RepoModel().update_permissions( | |
78 | self.db_repo_name, form['perm_additions'], form['perm_updates'], |
|
79 | self.db_repo_name, form['perm_additions'], form['perm_updates'], | |
79 | form['perm_deletions']) |
|
80 | form['perm_deletions']) | |
80 |
|
81 | |||
81 | action_data = { |
|
82 | action_data = { | |
82 | 'added': changes['added'], |
|
83 | 'added': changes['added'], | |
83 | 'updated': changes['updated'], |
|
84 | 'updated': changes['updated'], | |
84 | 'deleted': changes['deleted'], |
|
85 | 'deleted': changes['deleted'], | |
85 | } |
|
86 | } | |
86 | audit_logger.store_web( |
|
87 | audit_logger.store_web( | |
87 | 'repo.edit.permissions', action_data=action_data, |
|
88 | 'repo.edit.permissions', action_data=action_data, | |
88 | user=self._rhodecode_user, repo=self.db_repo) |
|
89 | user=self._rhodecode_user, repo=self.db_repo) | |
89 |
|
90 | |||
90 | Session().commit() |
|
91 | Session().commit() | |
91 | h.flash(_('Repository access permissions updated'), category='success') |
|
92 | h.flash(_('Repository access permissions updated'), category='success') | |
92 |
|
93 | |||
93 | affected_user_ids = None |
|
94 | affected_user_ids = None | |
94 | if changes.get('default_user_changed', False): |
|
95 | if changes.get('default_user_changed', False): | |
95 | # if we change the default user, we need to flush everyone permissions |
|
96 | # if we change the default user, we need to flush everyone permissions | |
96 | affected_user_ids = [x.user_id for x in User.get_all()] |
|
97 | affected_user_ids = [x.user_id for x in User.get_all()] | |
97 | PermissionModel().flush_user_permission_caches( |
|
98 | PermissionModel().flush_user_permission_caches( | |
98 | changes, affected_user_ids=affected_user_ids) |
|
99 | changes, affected_user_ids=affected_user_ids) | |
99 |
|
100 | |||
100 | raise HTTPFound( |
|
101 | raise HTTPFound( | |
101 | h.route_path('edit_repo_perms', repo_name=self.db_repo_name)) |
|
102 | h.route_path('edit_repo_perms', repo_name=self.db_repo_name)) | |
102 |
|
103 | |||
103 | @LoginRequired() |
|
104 | @LoginRequired() | |
104 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
105 | @HasRepoPermissionAnyDecorator('repository.admin') | |
105 | @CSRFRequired() |
|
106 | @CSRFRequired() | |
106 | @view_config( |
|
107 | @view_config( | |
107 | route_name='edit_repo_perms_set_private', request_method='POST', |
|
108 | route_name='edit_repo_perms_set_private', request_method='POST', | |
108 | renderer='json_ext') |
|
109 | renderer='json_ext') | |
109 | def edit_permissions_set_private_repo(self): |
|
110 | def edit_permissions_set_private_repo(self): | |
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': |
|
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), | |
119 | category='success') |
|
122 | category='success') | |
120 | except Exception: |
|
123 | except Exception: | |
121 | log.exception("Exception during update of repository") |
|
124 | log.exception("Exception during update of repository") | |
122 | h.flash(_('Error occurred during update of repository {}').format( |
|
125 | h.flash(_('Error occurred during update of repository {}').format( | |
123 | self.db_repo_name), category='error') |
|
126 | self.db_repo_name), category='error') | |
124 |
|
127 | |||
125 | # NOTE(dan): we change repo private mode we need to notify all USERS |
|
128 | # NOTE(dan): we change repo private mode we need to notify all USERS | |
126 | affected_user_ids = [x.user_id for x in User.get_all()] |
|
129 | affected_user_ids = [x.user_id for x in User.get_all()] | |
127 | PermissionModel().trigger_permission_flush(affected_user_ids) |
|
130 | PermissionModel().trigger_permission_flush(affected_user_ids) | |
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': |
|
134 | 'private': private_flag | |
132 | } |
|
135 | } |
@@ -1,222 +1,227 b'' | |||||
1 | <%namespace name="base" file="/base/base.mako"/> |
|
1 | <%namespace name="base" file="/base/base.mako"/> | |
2 |
|
2 | |||
3 | <div class="panel panel-default"> |
|
3 | <div class="panel panel-default"> | |
4 | <div class="panel-heading"> |
|
4 | <div class="panel-heading"> | |
5 | <h3 class="panel-title">${_('Repository Access Permissions')}</h3> |
|
5 | <h3 class="panel-title">${_('Repository Access Permissions')}</h3> | |
6 | </div> |
|
6 | </div> | |
7 | <div class="panel-body"> |
|
7 | <div class="panel-body"> | |
8 | ${h.secure_form(h.route_path('edit_repo_perms', repo_name=c.repo_name), request=request)} |
|
8 | ${h.secure_form(h.route_path('edit_repo_perms', repo_name=c.repo_name), request=request)} | |
9 | <table id="permissions_manage" class="rctable permissions"> |
|
9 | <table id="permissions_manage" class="rctable permissions"> | |
10 | <tr> |
|
10 | <tr> | |
11 | <th class="td-radio">${_('None')}</th> |
|
11 | <th class="td-radio">${_('None')}</th> | |
12 | <th class="td-radio">${_('Read')}</th> |
|
12 | <th class="td-radio">${_('Read')}</th> | |
13 | <th class="td-radio">${_('Write')}</th> |
|
13 | <th class="td-radio">${_('Write')}</th> | |
14 | <th class="td-radio">${_('Admin')}</th> |
|
14 | <th class="td-radio">${_('Admin')}</th> | |
15 | <th class="td-owner">${_('User/User Group')}</th> |
|
15 | <th class="td-owner">${_('User/User Group')}</th> | |
16 | <th class="td-action"></th> |
|
16 | <th class="td-action"></th> | |
17 | <th class="td-action"></th> |
|
17 | <th class="td-action"></th> | |
18 | </tr> |
|
18 | </tr> | |
19 | ## USERS |
|
19 | ## USERS | |
20 | %for _user in c.rhodecode_db_repo.permissions(): |
|
20 | %for _user in c.rhodecode_db_repo.permissions(): | |
21 | %if getattr(_user, 'admin_row', None) or getattr(_user, 'owner_row', None): |
|
21 | %if getattr(_user, 'admin_row', None) or getattr(_user, 'owner_row', None): | |
22 | <tr class="perm_admin_row"> |
|
22 | <tr class="perm_admin_row"> | |
23 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.none', disabled="disabled")}</td> |
|
23 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.none', disabled="disabled")}</td> | |
24 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.read', disabled="disabled")}</td> |
|
24 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.read', disabled="disabled")}</td> | |
25 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.write', disabled="disabled")}</td> |
|
25 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.write', disabled="disabled")}</td> | |
26 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.admin', 'repository.admin', disabled="disabled")}</td> |
|
26 | <td class="td-radio">${h.radio('admin_perm_%s' % _user.user_id,'repository.admin', 'repository.admin', disabled="disabled")}</td> | |
27 | <td class="td-user"> |
|
27 | <td class="td-user"> | |
28 | ${base.gravatar(_user.email, 16, user=_user, tooltip=True)} |
|
28 | ${base.gravatar(_user.email, 16, user=_user, tooltip=True)} | |
29 | ${h.link_to_user(_user.username)} |
|
29 | ${h.link_to_user(_user.username)} | |
30 | %if getattr(_user, 'admin_row', None): |
|
30 | %if getattr(_user, 'admin_row', None): | |
31 | (${_('super-admin')}) |
|
31 | (${_('super-admin')}) | |
32 | %endif |
|
32 | %endif | |
33 | %if getattr(_user, 'owner_row', None): |
|
33 | %if getattr(_user, 'owner_row', None): | |
34 | (${_('owner')}) |
|
34 | (${_('owner')}) | |
35 | %endif |
|
35 | %endif | |
36 | </td> |
|
36 | </td> | |
37 | <td></td> |
|
37 | <td></td> | |
38 | <td class="quick_repo_menu"> |
|
38 | <td class="quick_repo_menu"> | |
39 | % if c.rhodecode_user.is_admin: |
|
39 | % if c.rhodecode_user.is_admin: | |
40 | <i class="icon-more"></i> |
|
40 | <i class="icon-more"></i> | |
41 | <div class="menu_items_container" style="display: none;"> |
|
41 | <div class="menu_items_container" style="display: none;"> | |
42 | <ul class="menu_items"> |
|
42 | <ul class="menu_items"> | |
43 | <li> |
|
43 | <li> | |
44 | ${h.link_to('show permissions', h.route_path('edit_user_perms_summary', user_id=_user.user_id, _anchor='repositories-permissions'))} |
|
44 | ${h.link_to('show permissions', h.route_path('edit_user_perms_summary', user_id=_user.user_id, _anchor='repositories-permissions'))} | |
45 | </li> |
|
45 | </li> | |
46 | </ul> |
|
46 | </ul> | |
47 | </div> |
|
47 | </div> | |
48 | % endif |
|
48 | % endif | |
49 | </td> |
|
49 | </td> | |
50 | </tr> |
|
50 | </tr> | |
51 | %elif _user.username == h.DEFAULT_USER and c.rhodecode_db_repo.private: |
|
51 | %elif _user.username == h.DEFAULT_USER and c.rhodecode_db_repo.private: | |
52 | <tr> |
|
52 | <tr> | |
53 | <td colspan="4"> |
|
53 | <td colspan="4"> | |
54 | <span class="private_repo_msg"> |
|
54 | <span class="private_repo_msg"> | |
55 | <strong title="${h.tooltip(_user.permission)}">${_('private repository')}</strong> |
|
55 | <strong title="${h.tooltip(_user.permission)}">${_('private repository')}</strong> | |
56 | </span> |
|
56 | </span> | |
57 | </td> |
|
57 | </td> | |
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 |
|
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> | |
65 | <div class="menu_items_container" style="display: none;"> |
|
69 | <div class="menu_items_container" style="display: none;"> | |
66 | <ul class="menu_items"> |
|
70 | <ul class="menu_items"> | |
67 | <li> |
|
71 | <li> | |
68 | ${h.link_to('show permissions', h.route_path('admin_permissions_overview', _anchor='repositories-permissions'))} |
|
72 | ${h.link_to('show permissions', h.route_path('admin_permissions_overview', _anchor='repositories-permissions'))} | |
69 | </li> |
|
73 | </li> | |
70 | </ul> |
|
74 | </ul> | |
71 | </div> |
|
75 | </div> | |
72 | % endif |
|
76 | % endif | |
73 | </td> |
|
77 | </td> | |
74 | </tr> |
|
78 | </tr> | |
75 | %else: |
|
79 | %else: | |
76 | <% used_by_n_rules = len(getattr(_user, 'branch_rules', None) or []) %> |
|
80 | <% used_by_n_rules = len(getattr(_user, 'branch_rules', None) or []) %> | |
77 | <tr> |
|
81 | <tr> | |
78 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.none', checked=_user.permission=='repository.none', disabled="disabled" if (used_by_n_rules and _user.username != h.DEFAULT_USER) else None)}</td> |
|
82 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.none', checked=_user.permission=='repository.none', disabled="disabled" if (used_by_n_rules and _user.username != h.DEFAULT_USER) else None)}</td> | |
79 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.read', checked=_user.permission=='repository.read', disabled="disabled" if (used_by_n_rules and _user.username != h.DEFAULT_USER) else None)}</td> |
|
83 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.read', checked=_user.permission=='repository.read', disabled="disabled" if (used_by_n_rules and _user.username != h.DEFAULT_USER) else None)}</td> | |
80 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.write', checked=_user.permission=='repository.write')}</td> |
|
84 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.write', checked=_user.permission=='repository.write')}</td> | |
81 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.admin', checked=_user.permission=='repository.admin')}</td> |
|
85 | <td class="td-radio">${h.radio('u_perm_%s' % _user.user_id,'repository.admin', checked=_user.permission=='repository.admin')}</td> | |
82 | <td class="td-user"> |
|
86 | <td class="td-user"> | |
83 | ${base.gravatar(_user.email, 16, user=_user, tooltip=True)} |
|
87 | ${base.gravatar(_user.email, 16, user=_user, tooltip=True)} | |
84 | <span class="user"> |
|
88 | <span class="user"> | |
85 | % if _user.username == h.DEFAULT_USER: |
|
89 | % if _user.username == h.DEFAULT_USER: | |
86 | ${h.DEFAULT_USER} <span class="user-perm-help-text"> - ${_('permission for all other users')}</span> |
|
90 | ${h.DEFAULT_USER} <span class="user-perm-help-text"> - ${_('permission for all other users')}</span> | |
87 | % else: |
|
91 | % else: | |
88 | ${h.link_to_user(_user.username)} |
|
92 | ${h.link_to_user(_user.username)} | |
89 | %if getattr(_user, 'duplicate_perm', None): |
|
93 | %if getattr(_user, 'duplicate_perm', None): | |
90 | (${_('inactive duplicate')}) |
|
94 | (${_('inactive duplicate')}) | |
91 | %endif |
|
95 | %endif | |
92 | %if getattr(_user, 'branch_rules', None): |
|
96 | %if getattr(_user, 'branch_rules', None): | |
93 | % if used_by_n_rules == 1: |
|
97 | % if used_by_n_rules == 1: | |
94 | (${_('used by {} branch rule, requires write+ permissions').format(used_by_n_rules)}) |
|
98 | (${_('used by {} branch rule, requires write+ permissions').format(used_by_n_rules)}) | |
95 | % else: |
|
99 | % else: | |
96 | (${_('used by {} branch rules, requires write+ permissions').format(used_by_n_rules)}) |
|
100 | (${_('used by {} branch rules, requires write+ permissions').format(used_by_n_rules)}) | |
97 | % endif |
|
101 | % endif | |
98 | %endif |
|
102 | %endif | |
99 | % endif |
|
103 | % endif | |
100 | </span> |
|
104 | </span> | |
101 | </td> |
|
105 | </td> | |
102 | <td class="td-action"> |
|
106 | <td class="td-action"> | |
103 | %if _user.username != h.DEFAULT_USER and getattr(_user, 'branch_rules', None) is None: |
|
107 | %if _user.username != h.DEFAULT_USER and getattr(_user, 'branch_rules', None) is None: | |
104 | <span class="btn btn-link btn-danger revoke_perm" |
|
108 | <span class="btn btn-link btn-danger revoke_perm" | |
105 | member="${_user.user_id}" member_type="user"> |
|
109 | member="${_user.user_id}" member_type="user"> | |
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=" |
|
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 | |
113 | </td> |
|
117 | </td> | |
114 | <td class="quick_repo_menu"> |
|
118 | <td class="quick_repo_menu"> | |
115 | % if c.rhodecode_user.is_admin: |
|
119 | % if c.rhodecode_user.is_admin: | |
116 | <i class="icon-more"></i> |
|
120 | <i class="icon-more"></i> | |
117 | <div class="menu_items_container" style="display: none;"> |
|
121 | <div class="menu_items_container" style="display: none;"> | |
118 | <ul class="menu_items"> |
|
122 | <ul class="menu_items"> | |
119 | <li> |
|
123 | <li> | |
120 | % if _user.username == h.DEFAULT_USER: |
|
124 | % if _user.username == h.DEFAULT_USER: | |
121 | ${h.link_to('show permissions', h.route_path('admin_permissions_overview', _anchor='repositories-permissions'))} |
|
125 | ${h.link_to('show permissions', h.route_path('admin_permissions_overview', _anchor='repositories-permissions'))} | |
122 | % else: |
|
126 | % else: | |
123 | ${h.link_to('show permissions', h.route_path('edit_user_perms_summary', user_id=_user.user_id, _anchor='repositories-permissions'))} |
|
127 | ${h.link_to('show permissions', h.route_path('edit_user_perms_summary', user_id=_user.user_id, _anchor='repositories-permissions'))} | |
124 | % endif |
|
128 | % endif | |
125 | </li> |
|
129 | </li> | |
126 | </ul> |
|
130 | </ul> | |
127 | </div> |
|
131 | </div> | |
128 | % endif |
|
132 | % endif | |
129 | </td> |
|
133 | </td> | |
130 | </tr> |
|
134 | </tr> | |
131 | %endif |
|
135 | %endif | |
132 | %endfor |
|
136 | %endfor | |
133 |
|
137 | |||
134 | ## USER GROUPS |
|
138 | ## USER GROUPS | |
135 | %for _user_group in c.rhodecode_db_repo.permission_user_groups(with_members=True): |
|
139 | %for _user_group in c.rhodecode_db_repo.permission_user_groups(with_members=True): | |
136 | <tr> |
|
140 | <tr> | |
137 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.none', checked=_user_group.permission=='repository.none')}</td> |
|
141 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.none', checked=_user_group.permission=='repository.none')}</td> | |
138 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.read', checked=_user_group.permission=='repository.read')}</td> |
|
142 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.read', checked=_user_group.permission=='repository.read')}</td> | |
139 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.write', checked=_user_group.permission=='repository.write')}</td> |
|
143 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.write', checked=_user_group.permission=='repository.write')}</td> | |
140 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.admin', checked=_user_group.permission=='repository.admin')}</td> |
|
144 | <td class="td-radio">${h.radio('g_perm_%s' % _user_group.users_group_id,'repository.admin', checked=_user_group.permission=='repository.admin')}</td> | |
141 | <td class="td-componentname"> |
|
145 | <td class="td-componentname"> | |
142 | ${base.user_group_icon(_user_group, tooltip=True)} |
|
146 | ${base.user_group_icon(_user_group, tooltip=True)} | |
143 | %if c.is_super_admin: |
|
147 | %if c.is_super_admin: | |
144 | <a href="${h.route_path('edit_user_group',user_group_id=_user_group.users_group_id)}"> |
|
148 | <a href="${h.route_path('edit_user_group',user_group_id=_user_group.users_group_id)}"> | |
145 | ${_user_group.users_group_name} |
|
149 | ${_user_group.users_group_name} | |
146 | </a> |
|
150 | </a> | |
147 | %else: |
|
151 | %else: | |
148 | ${h.link_to_group(_user_group.users_group_name)} |
|
152 | ${h.link_to_group(_user_group.users_group_name)} | |
149 | %endif |
|
153 | %endif | |
150 | (${_('members')}: ${len(_user_group.members)}) |
|
154 | (${_('members')}: ${len(_user_group.members)}) | |
151 | </td> |
|
155 | </td> | |
152 | <td class="td-action"> |
|
156 | <td class="td-action"> | |
153 | <span class="btn btn-link btn-danger revoke_perm" |
|
157 | <span class="btn btn-link btn-danger revoke_perm" | |
154 | member="${_user_group.users_group_id}" member_type="user_group"> |
|
158 | member="${_user_group.users_group_id}" member_type="user_group"> | |
155 | ${_('Remove')} |
|
159 | ${_('Remove')} | |
156 | </span> |
|
160 | </span> | |
157 | </td> |
|
161 | </td> | |
158 | <td class="quick_repo_menu"> |
|
162 | <td class="quick_repo_menu"> | |
159 | % if c.rhodecode_user.is_admin: |
|
163 | % if c.rhodecode_user.is_admin: | |
160 | <i class="icon-more"></i> |
|
164 | <i class="icon-more"></i> | |
161 | <div class="menu_items_container" style="display: none;"> |
|
165 | <div class="menu_items_container" style="display: none;"> | |
162 | <ul class="menu_items"> |
|
166 | <ul class="menu_items"> | |
163 | <li> |
|
167 | <li> | |
164 | ${h.link_to('show permissions', h.route_path('edit_user_group_perms_summary', user_group_id=_user_group.users_group_id, _anchor='repositories-permissions'))} |
|
168 | ${h.link_to('show permissions', h.route_path('edit_user_group_perms_summary', user_group_id=_user_group.users_group_id, _anchor='repositories-permissions'))} | |
165 | </li> |
|
169 | </li> | |
166 | </ul> |
|
170 | </ul> | |
167 | </div> |
|
171 | </div> | |
168 | % endif |
|
172 | % endif | |
169 | </td> |
|
173 | </td> | |
170 | </tr> |
|
174 | </tr> | |
171 | %endfor |
|
175 | %endfor | |
172 | <tr class="new_members" id="add_perm_input"></tr> |
|
176 | <tr class="new_members" id="add_perm_input"></tr> | |
173 |
|
177 | |||
174 | <tr> |
|
178 | <tr> | |
175 | <td></td> |
|
179 | <td></td> | |
176 | <td></td> |
|
180 | <td></td> | |
177 | <td></td> |
|
181 | <td></td> | |
178 | <td></td> |
|
182 | <td></td> | |
179 | <td></td> |
|
183 | <td></td> | |
180 | <td> |
|
184 | <td> | |
181 | <span id="add_perm" class="link"> |
|
185 | <span id="add_perm" class="link"> | |
182 | ${_('Add user/user group')} |
|
186 | ${_('Add user/user group')} | |
183 | </span> |
|
187 | </span> | |
184 | </td> |
|
188 | </td> | |
185 | <td></td> |
|
189 | <td></td> | |
186 | </tr> |
|
190 | </tr> | |
187 |
|
191 | |||
188 | </table> |
|
192 | </table> | |
189 |
|
193 | |||
190 | <div class="buttons"> |
|
194 | <div class="buttons"> | |
191 | ${h.submit('save',_('Save'),class_="btn btn-primary")} |
|
195 | ${h.submit('save',_('Save'),class_="btn btn-primary")} | |
192 | ${h.reset('reset',_('Reset'),class_="btn btn-danger")} |
|
196 | ${h.reset('reset',_('Reset'),class_="btn btn-danger")} | |
193 | </div> |
|
197 | </div> | |
194 | ${h.end_form()} |
|
198 | ${h.end_form()} | |
195 | </div> |
|
199 | </div> | |
196 | </div> |
|
200 | </div> | |
197 |
|
201 | |||
198 | <script type="text/javascript"> |
|
202 | <script type="text/javascript"> | |
199 | $('#add_perm').on('click', function(e){ |
|
203 | $('#add_perm').on('click', function(e){ | |
200 | addNewPermInput($(this), 'repository'); |
|
204 | addNewPermInput($(this), 'repository'); | |
201 | }); |
|
205 | }); | |
202 | $('.revoke_perm').on('click', function(e){ |
|
206 | $('.revoke_perm').on('click', function(e){ | |
203 | markRevokePermInput($(this), 'repository'); |
|
207 | markRevokePermInput($(this), 'repository'); | |
204 | }); |
|
208 | }); | |
205 | quick_repo_menu(); |
|
209 | quick_repo_menu(); | |
206 |
|
210 | |||
207 |
var |
|
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) { | |
213 | var defaultUrl = pyroutes.url('edit_repo_perms', {"repo_name": templateContext.repo_name}); |
|
218 | var defaultUrl = pyroutes.url('edit_repo_perms', {"repo_name": templateContext.repo_name}); | |
214 | window.location = o.redirect_url || defaultUrl; |
|
219 | window.location = o.redirect_url || defaultUrl; | |
215 | }; |
|
220 | }; | |
216 |
|
221 | |||
217 | ajaxPOST( |
|
222 | ajaxPOST( | |
218 | pyroutes.url('edit_repo_perms_set_private', {"repo_name": templateContext.repo_name}), |
|
223 | pyroutes.url('edit_repo_perms_set_private', {"repo_name": templateContext.repo_name}), | |
219 | postData, |
|
224 | postData, | |
220 | success); |
|
225 | success); | |
221 | } |
|
226 | } | |
222 | </script> |
|
227 | </script> |
General Comments 0
You need to be logged in to leave comments.
Login now