##// END OF EJS Templates
permissions-summary: skip branch permission entries that are leaking private repository names, and fix counters.
ergo -
r2991:6b51e9a4 default
parent child Browse files
Show More
@@ -1,353 +1,372 b''
1 ## snippet for displaying permissions overview for users
1 ## snippet for displaying permissions overview for users
2 ## usage:
2 ## usage:
3 ## <%namespace name="p" file="/base/perms_summary.mako"/>
3 ## <%namespace name="p" file="/base/perms_summary.mako"/>
4 ## ${p.perms_summary(c.perm_user.permissions)}
4 ## ${p.perms_summary(c.perm_user.permissions)}
5
5
6 <%def name="perms_summary(permissions, show_all=False, actions=True, side_link=None)">
6 <%def name="perms_summary(permissions, show_all=False, actions=True, side_link=None)">
7 <% section_to_label = {
7 <% section_to_label = {
8 'global': 'Global Permissions',
8 'global': 'Global Permissions',
9 'repository_branches': 'Repository Branch Rules',
9 'repository_branches': 'Repository Branch Rules',
10 'repositories': 'Repository Permissions',
10 'repositories': 'Repository Permissions',
11 'user_groups': 'User Group Permissions',
11 'user_groups': 'User Group Permissions',
12 'repositories_groups': 'Repository Group Permissions',
12 'repositories_groups': 'Repository Group Permissions',
13 } %>
13 } %>
14
14 <div id="perms" class="table fields">
15 <div id="perms" class="table fields">
15 %for section in sorted(permissions.keys(), key=lambda item: {'global': 0, 'repository_branches': 1}.get(item, 1000)):
16 %for section in sorted(permissions.keys(), key=lambda item: {'global': 0, 'repository_branches': 1}.get(item, 1000)):
17 <% total_counter = 0 %>
18
16 <div class="panel panel-default">
19 <div class="panel panel-default">
17 <div class="panel-heading" id="${section.replace("_","-")}-permissions">
20 <div class="panel-heading" id="${section.replace("_","-")}-permissions">
18 <h3 class="panel-title">${section_to_label.get(section, section)} - ${len(permissions[section])}
21 <h3 class="panel-title">${section_to_label.get(section, section)} - <span id="total_count_${section}"></span>
19 <a class="permalink" href="#${section.replace("_","-")}-permissions"> ΒΆ</a>
22 <a class="permalink" href="#${section.replace("_","-")}-permissions"> ΒΆ</a>
20 </h3>
23 </h3>
21 % if side_link:
24 % if side_link:
22 <div class="pull-right">
25 <div class="pull-right">
23 <a href="${side_link}">${_('in JSON format')}</a>
26 <a href="${side_link}">${_('in JSON format')}</a>
24 </div>
27 </div>
25 % endif
28 % endif
26 </div>
29 </div>
27 <div class="panel-body">
30 <div class="panel-body">
28 <div class="perms_section_head field">
31 <div class="perms_section_head field">
29 <div class="radios">
32 <div class="radios">
30 % if section == 'repository_branches':
33 % if section == 'repository_branches':
31 <span class="permissions_boxes">
34 <span class="permissions_boxes">
32 <span class="desc">${_('show')}: </span>
35 <span class="desc">${_('show')}: </span>
33 ${h.checkbox('perms_filter_none_%s' % section, 'none', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='none')} <label for="${'perms_filter_none_{}'.format(section)}"><span class="perm_tag none">${_('none')}</span></label>
36 ${h.checkbox('perms_filter_none_%s' % section, 'none', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='none')} <label for="${'perms_filter_none_{}'.format(section)}"><span class="perm_tag none">${_('none')}</span></label>
34 ${h.checkbox('perms_filter_merge_%s' % section, 'merge', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='merge')} <label for="${'perms_filter_merge_{}'.format(section)}"><span class="perm_tag merge">${_('merge')}</span></label>
37 ${h.checkbox('perms_filter_merge_%s' % section, 'merge', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='merge')} <label for="${'perms_filter_merge_{}'.format(section)}"><span class="perm_tag merge">${_('merge')}</span></label>
35 ${h.checkbox('perms_filter_push_%s' % section, 'push', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='push')} <label for="${'perms_filter_push_{}'.format(section)}"> <span class="perm_tag push">${_('push')}</span></label>
38 ${h.checkbox('perms_filter_push_%s' % section, 'push', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='push')} <label for="${'perms_filter_push_{}'.format(section)}"> <span class="perm_tag push">${_('push')}</span></label>
36 ${h.checkbox('perms_filter_push_force_%s' % section, 'push_force', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='push_force')} <label for="${'perms_filter_push_force_{}'.format(section)}"><span class="perm_tag push_force">${_('push force')}</span></label>
39 ${h.checkbox('perms_filter_push_force_%s' % section, 'push_force', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='push_force')} <label for="${'perms_filter_push_force_{}'.format(section)}"><span class="perm_tag push_force">${_('push force')}</span></label>
37 </span>
40 </span>
38 % elif section != 'global':
41 % elif section != 'global':
39 <span class="permissions_boxes">
42 <span class="permissions_boxes">
40 <span class="desc">${_('show')}: </span>
43 <span class="desc">${_('show')}: </span>
41 ${h.checkbox('perms_filter_none_%s' % section, 'none', '', class_='perm_filter filter_%s' % section, section=section, perm_type='none')} <label for="${'perms_filter_none_{}'.format(section)}"><span class="perm_tag none">${_('none')}</span></label>
44 ${h.checkbox('perms_filter_none_%s' % section, 'none', '', class_='perm_filter filter_%s' % section, section=section, perm_type='none')} <label for="${'perms_filter_none_{}'.format(section)}"><span class="perm_tag none">${_('none')}</span></label>
42 ${h.checkbox('perms_filter_read_%s' % section, 'read', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='read')} <label for="${'perms_filter_read_{}'.format(section)}"><span class="perm_tag read">${_('read')}</span></label>
45 ${h.checkbox('perms_filter_read_%s' % section, 'read', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='read')} <label for="${'perms_filter_read_{}'.format(section)}"><span class="perm_tag read">${_('read')}</span></label>
43 ${h.checkbox('perms_filter_write_%s' % section, 'write', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='write')} <label for="${'perms_filter_write_{}'.format(section)}"> <span class="perm_tag write">${_('write')}</span></label>
46 ${h.checkbox('perms_filter_write_%s' % section, 'write', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='write')} <label for="${'perms_filter_write_{}'.format(section)}"> <span class="perm_tag write">${_('write')}</span></label>
44 ${h.checkbox('perms_filter_admin_%s' % section, 'admin', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='admin')} <label for="${'perms_filter_admin_{}'.format(section)}"><span class="perm_tag admin">${_('admin')}</span></label>
47 ${h.checkbox('perms_filter_admin_%s' % section, 'admin', 'checked', class_='perm_filter filter_%s' % section, section=section, perm_type='admin')} <label for="${'perms_filter_admin_{}'.format(section)}"><span class="perm_tag admin">${_('admin')}</span></label>
45 </span>
48 </span>
46 % endif
49 % endif
47
50
48 </div>
51 </div>
49 </div>
52 </div>
50 <div class="field">
53 <div class="field">
51 %if not permissions[section]:
54 %if not permissions[section]:
52 <p class="empty_data help-block">${_('No permissions defined')}</p>
55 <p class="empty_data help-block">${_('No permissions defined')}</p>
53 %else:
56 %else:
54 <div id='tbl_list_wrap_${section}'>
57 <div id='tbl_list_wrap_${section}'>
55 <table id="tbl_list_${section}" class="rctable">
58 <table id="tbl_list_${section}" class="rctable">
56 ## global permission box
59 ## global permission box
57 %if section == 'global':
60 %if section == 'global':
58 <thead>
61 <thead>
59 <tr>
62 <tr>
60 <th colspan="2" class="left">${_('Permission')}</th>
63 <th colspan="2" class="left">${_('Permission')}</th>
61 %if actions:
64 %if actions:
62 <th colspan="2">${_('Edit Permission')}</th>
65 <th colspan="2">${_('Edit Permission')}</th>
63 %endif
66 %endif
64 </thead>
67 </thead>
65 <tbody>
68 <tbody>
66
69
67 <%
70 <%
68 def get_section_perms(prefix, opts):
71 def get_section_perms(prefix, opts):
69 _selected = []
72 _selected = []
70 for op in opts:
73 for op in opts:
71 if op.startswith(prefix) and not op.startswith('hg.create.write_on_repogroup'):
74 if op.startswith(prefix) and not op.startswith('hg.create.write_on_repogroup'):
72 _selected.append(op)
75 _selected.append(op)
73 admin = 'hg.admin' in opts
76 admin = 'hg.admin' in opts
74 _selected_vals = [x.partition(prefix)[-1] for x in _selected]
77 _selected_vals = [x.partition(prefix)[-1] for x in _selected]
75 return admin, _selected_vals, _selected
78 return admin, _selected_vals, _selected
76 %>
79 %>
77
80
78 <%def name="glob(lbl, val, val_lbl=None, edit_url=None, edit_global_url=None)">
81 <%def name="glob(lbl, val, val_lbl=None, edit_url=None, edit_global_url=None)">
79 <tr>
82 <tr>
80 <td class="td-tags">
83 <td class="td-tags">
81 ${lbl}
84 ${lbl}
82 </td>
85 </td>
83 <td class="td-tags">
86 <td class="td-tags">
84 %if val[0]:
87 %if val[0]:
85 %if not val_lbl:
88 %if not val_lbl:
86 ## super admin case
89 ## super admin case
87 True
90 True
88 %else:
91 %else:
89 <span class="perm_tag admin">${val_lbl}.admin</span>
92 <span class="perm_tag admin">${val_lbl}.admin</span>
90 %endif
93 %endif
91 %else:
94 %else:
92 %if not val_lbl:
95 %if not val_lbl:
93 ${{'false': False,
96 ${{'false': False,
94 'true': True,
97 'true': True,
95 'none': False,
98 'none': False,
96 'repository': True}.get(val[1][0] if 0 < len(val[1]) else 'false')}
99 'repository': True}.get(val[1][0] if 0 < len(val[1]) else 'false')}
97 %else:
100 %else:
98 <span class="perm_tag ${val[1][0]}">${val_lbl}.${val[1][0]}</span>
101 <span class="perm_tag ${val[1][0]}">${val_lbl}.${val[1][0]}</span>
99 %endif
102 %endif
100 %endif
103 %endif
101 </td>
104 </td>
102 %if actions:
105 %if actions:
103
106
104 % if edit_url or edit_global_url:
107 % if edit_url or edit_global_url:
105
108
106 <td class="td-action">
109 <td class="td-action">
107 % if edit_url:
110 % if edit_url:
108 <a href="${edit_url}">${_('edit')}</a>
111 <a href="${edit_url}">${_('edit')}</a>
109 % else:
112 % else:
110 -
113 -
111 % endif
114 % endif
112 </td>
115 </td>
113
116
114 <td class="td-action">
117 <td class="td-action">
115 % if edit_global_url:
118 % if edit_global_url:
116 <a href="${edit_global_url}">${_('edit global')}</a>
119 <a href="${edit_global_url}">${_('edit global')}</a>
117 % else:
120 % else:
118 -
121 -
119 % endif
122 % endif
120 </td>
123 </td>
121
124
122 % else:
125 % else:
123 <td class="td-action"></td>
126 <td class="td-action"></td>
124 <td class="td-action">
127 <td class="td-action">
125 <a href="${h.route_path('admin_permissions_global')}">${_('edit global')}</a>
128 <a href="${h.route_path('admin_permissions_global')}">${_('edit global')}</a>
126 <td class="td-action">
129 <td class="td-action">
127 % endif
130 % endif
128
131
129 %endif
132 %endif
130 </tr>
133 </tr>
131 </%def>
134 </%def>
132
135
133 ${glob(_('Repository default permission'), get_section_perms('repository.', permissions[section]), 'repository',
136 ${glob(_('Repository default permission'), get_section_perms('repository.', permissions[section]), 'repository',
134 edit_url=None, edit_global_url=h.route_path('admin_permissions_object'))}
137 edit_url=None, edit_global_url=h.route_path('admin_permissions_object'))}
135
138
136 ${glob(_('Repository group default permission'), get_section_perms('group.', permissions[section]), 'group',
139 ${glob(_('Repository group default permission'), get_section_perms('group.', permissions[section]), 'group',
137 edit_url=None, edit_global_url=h.route_path('admin_permissions_object'))}
140 edit_url=None, edit_global_url=h.route_path('admin_permissions_object'))}
138
141
139 ${glob(_('User group default permission'), get_section_perms('usergroup.', permissions[section]), 'usergroup',
142 ${glob(_('User group default permission'), get_section_perms('usergroup.', permissions[section]), 'usergroup',
140 edit_url=None, edit_global_url=h.route_path('admin_permissions_object'))}
143 edit_url=None, edit_global_url=h.route_path('admin_permissions_object'))}
141
144
142 ${glob(_('Super admin'), get_section_perms('hg.admin', permissions[section]),
145 ${glob(_('Super admin'), get_section_perms('hg.admin', permissions[section]),
143 edit_url=h.route_path('user_edit', user_id=c.user.user_id, _anchor='admin'), edit_global_url=None)}
146 edit_url=h.route_path('user_edit', user_id=c.user.user_id, _anchor='admin'), edit_global_url=None)}
144
147
145 ${glob(_('Inherit permissions'), get_section_perms('hg.inherit_default_perms.', permissions[section]),
148 ${glob(_('Inherit permissions'), get_section_perms('hg.inherit_default_perms.', permissions[section]),
146 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=None)}
149 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=None)}
147
150
148 ${glob(_('Create repositories'), get_section_perms('hg.create.', permissions[section]),
151 ${glob(_('Create repositories'), get_section_perms('hg.create.', permissions[section]),
149 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
152 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
150
153
151 ${glob(_('Fork repositories'), get_section_perms('hg.fork.', permissions[section]),
154 ${glob(_('Fork repositories'), get_section_perms('hg.fork.', permissions[section]),
152 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
155 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
153
156
154 ${glob(_('Create repository groups'), get_section_perms('hg.repogroup.create.', permissions[section]),
157 ${glob(_('Create repository groups'), get_section_perms('hg.repogroup.create.', permissions[section]),
155 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
158 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
156
159
157 ${glob(_('Create user groups'), get_section_perms('hg.usergroup.create.', permissions[section]),
160 ${glob(_('Create user groups'), get_section_perms('hg.usergroup.create.', permissions[section]),
158 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
161 edit_url=h.route_path('user_edit_global_perms', user_id=c.user.user_id), edit_global_url=h.route_path('admin_permissions_object'))}
159
162
160 </tbody>
163 </tbody>
161 ## Branch perms
164 ## Branch perms
162 %elif section == 'repository_branches':
165 %elif section == 'repository_branches':
163 <thead>
166 <thead>
164 <tr>
167 <tr>
165 <th>${_('Name')}</th>
168 <th>${_('Name')}</th>
166 <th>${_('Pattern')}</th>
169 <th>${_('Pattern')}</th>
167 <th>${_('Permission')}</th>
170 <th>${_('Permission')}</th>
168 %if actions:
171 %if actions:
169 <th>${_('Edit Branch Permission')}</th>
172 <th>${_('Edit Branch Permission')}</th>
170 %endif
173 %endif
171 </thead>
174 </thead>
172 <tbody class="section_${section}">
175 <tbody class="section_${section}">
173 <%
176 <%
174 def name_sorter(permissions):
177 def name_sorter(permissions):
175 def custom_sorter(item):
178 def custom_sorter(item):
176 return item[0]
179 return item[0]
177 return sorted(permissions, key=custom_sorter)
180 return sorted(permissions, key=custom_sorter)
178
181
179 def branch_sorter(permissions):
182 def branch_sorter(permissions):
180 def custom_sorter(item):
183 def custom_sorter(item):
181 ## none, merge, push, push_force
184 ## none, merge, push, push_force
182 section = item[1].split('.')[-1]
185 section = item[1].split('.')[-1]
183 section_importance = {'none': u'0',
186 section_importance = {'none': u'0',
184 'merge': u'1',
187 'merge': u'1',
185 'push': u'2',
188 'push': u'2',
186 'push_force': u'3'}.get(section)
189 'push_force': u'3'}.get(section)
187 ## sort by importance + name
190 ## sort by importance + name
188 return section_importance + item[0]
191 return section_importance + item[0]
189 return sorted(permissions, key=custom_sorter)
192 return sorted(permissions, key=custom_sorter)
190 %>
193 %>
191 %for k, section_perms in name_sorter(permissions[section].items()):
194 %for k, section_perms in name_sorter(permissions[section].items()):
195 ## for display purposes, for non super-admins we need to check if shown
196 ## repository is actually accessible for user
197 <% repo_perm = permissions['repositories'][k] %>
198 % if repo_perm == 'repository.none' and not c.rhodecode_user.is_admin:
199 ## skip this entry
200 <% continue %>
201 % endif
202
203 <% total_counter +=1 %>
192 % for pattern, perm in branch_sorter(section_perms.items()):
204 % for pattern, perm in branch_sorter(section_perms.items()):
193 <tr class="perm_row ${'{}_{}'.format(section, perm.split('.')[-1])}">
205 <tr class="perm_row ${'{}_{}'.format(section, perm.split('.')[-1])}">
194 <td class="td-name">
206 <td class="td-name">
195 <a href="${h.route_path('repo_summary',repo_name=k)}">${k}</a>
207 <a href="${h.route_path('repo_summary',repo_name=k)}">${k}</a>
196 </td>
208 </td>
197 <td>${pattern}</td>
209 <td>${pattern}</td>
198 <td class="td-tags">
210 <td class="td-tags">
199 ## TODO: calculate origin somehow
211 ## TODO: calculate origin somehow
200 ## % for i, ((_pat, perm), origin) in enumerate((permissions[section].perm_origin_stack[k])):
212 ## % for i, ((_pat, perm), origin) in enumerate((permissions[section].perm_origin_stack[k])):
201
213
202 <div>
214 <div>
203 <% i = 0 %>
215 <% i = 0 %>
204 <% origin = 'unknown' %>
216 <% origin = 'unknown' %>
205 <% _css_class = i > 0 and 'perm_overriden' or '' %>
217 <% _css_class = i > 0 and 'perm_overriden' or '' %>
206
218
207 <span class="${_css_class} perm_tag ${perm.split('.')[-1]}">
219 <span class="${_css_class} perm_tag ${perm.split('.')[-1]}">
208 ${perm}
220 ${perm}
209 ##(${origin})
221 ##(${origin})
210 </span>
222 </span>
211 </div>
223 </div>
212 ## % endfor
224 ## % endfor
213 </td>
225 </td>
214 %if actions:
226 %if actions:
215 <td class="td-action">
227 <td class="td-action">
216 <a href="${h.route_path('edit_repo_perms_branch',repo_name=k)}">${_('edit')}</a>
228 <a href="${h.route_path('edit_repo_perms_branch',repo_name=k)}">${_('edit')}</a>
217 </td>
229 </td>
218 %endif
230 %endif
219 </tr>
231 </tr>
220 % endfor
232 % endfor
221 %endfor
233 %endfor
222 </tbody>
234 </tbody>
223
235
224 ## Repos/Repo Groups/users groups perms
236 ## Repos/Repo Groups/users groups perms
225 %else:
237 %else:
226
238
227 ## none/read/write/admin permissions on groups/repos etc
239 ## none/read/write/admin permissions on groups/repos etc
228 <thead>
240 <thead>
229 <tr>
241 <tr>
230 <th>${_('Name')}</th>
242 <th>${_('Name')}</th>
231 <th>${_('Permission')}</th>
243 <th>${_('Permission')}</th>
232 %if actions:
244 %if actions:
233 <th>${_('Edit Permission')}</th>
245 <th>${_('Edit Permission')}</th>
234 %endif
246 %endif
235 </thead>
247 </thead>
236 <tbody class="section_${section}">
248 <tbody class="section_${section}">
237 <%
249 <%
238 def sorter(permissions):
250 def sorter(permissions):
239 def custom_sorter(item):
251 def custom_sorter(item):
240 ## read/write/admin
252 ## read/write/admin
241 section = item[1].split('.')[-1]
253 section = item[1].split('.')[-1]
242 section_importance = {'none': u'0',
254 section_importance = {'none': u'0',
243 'read': u'1',
255 'read': u'1',
244 'write':u'2',
256 'write':u'2',
245 'admin':u'3'}.get(section)
257 'admin':u'3'}.get(section)
246 ## sort by group importance+name
258 ## sort by group importance+name
247 return section_importance+item[0]
259 return section_importance+item[0]
248 return sorted(permissions, key=custom_sorter)
260 return sorted(permissions, key=custom_sorter)
249 %>
261 %>
250 %for k, section_perm in sorter(permissions[section].items()):
262 %for k, section_perm in sorter(permissions[section].items()):
251 <% perm_value = section_perm.split('.')[-1] %>
263 <% perm_value = section_perm.split('.')[-1] %>
252 <% _css_class = 'display:none' if perm_value in ['none'] else '' %>
264 <% _css_class = 'display:none' if perm_value in ['none'] else '' %>
253
265
254 %if perm_value != 'none' or show_all:
266 %if perm_value != 'none' or show_all:
255 <tr class="perm_row ${'{}_{}'.format(section, section_perm.split('.')[-1])}" style="${_css_class}">
267 <tr class="perm_row ${'{}_{}'.format(section, section_perm.split('.')[-1])}" style="${_css_class}">
256 <td class="td-name">
268 <td class="td-name">
257 %if section == 'repositories':
269 %if section == 'repositories':
258 <a href="${h.route_path('repo_summary',repo_name=k)}">${k}</a>
270 <a href="${h.route_path('repo_summary',repo_name=k)}">${k}</a>
259 %elif section == 'repositories_groups':
271 %elif section == 'repositories_groups':
260 <a href="${h.route_path('repo_group_home', repo_group_name=k)}">${k}</a>
272 <a href="${h.route_path('repo_group_home', repo_group_name=k)}">${k}</a>
261 %elif section == 'user_groups':
273 %elif section == 'user_groups':
262 ##<a href="${h.route_path('edit_user_group',user_group_id=k)}">${k}</a>
274 ##<a href="${h.route_path('edit_user_group',user_group_id=k)}">${k}</a>
263 ${k}
275 ${k}
264 %endif
276 %endif
265 </td>
277 </td>
266 <td class="td-tags">
278 <td class="td-tags">
267 %if hasattr(permissions[section], 'perm_origin_stack'):
279 %if hasattr(permissions[section], 'perm_origin_stack'):
268 <div>
280 <div>
269 %for i, (perm, origin) in enumerate(reversed(permissions[section].perm_origin_stack[k])):
281 %for i, (perm, origin) in enumerate(reversed(permissions[section].perm_origin_stack[k])):
270 <% _css_class = i > 0 and 'perm_overriden' or '' %>
282 <% _css_class = i > 0 and 'perm_overriden' or '' %>
271 % if i > 0:
283 % if i > 0:
272 <div style="color: #979797">
284 <div style="color: #979797">
273 <i class="icon-arrow_up"></i>
285 <i class="icon-arrow_up"></i>
274 ${_('overridden by')}
286 ${_('overridden by')}
275 <i class="icon-arrow_up"></i>
287 <i class="icon-arrow_up"></i>
276 </div>
288 </div>
277 % endif
289 % endif
278
290
279 <div>
291 <div>
280 <span class="${_css_class} perm_tag ${perm.split('.')[-1]}">
292 <span class="${_css_class} perm_tag ${perm.split('.')[-1]}">
281 ${perm} (${origin})
293 ${perm} (${origin})
282 </span>
294 </span>
283 </div>
295 </div>
284
296
285 %endfor
297 %endfor
286 </div>
298 </div>
287 %else:
299 %else:
288 <span class="perm_tag ${section_perm.split('.')[-1]}">${section_perm}</span>
300 <span class="perm_tag ${section_perm.split('.')[-1]}">${section_perm}</span>
289 %endif
301 %endif
290 </td>
302 </td>
291 %if actions:
303 %if actions:
292 <td class="td-action">
304 <td class="td-action">
293 %if section == 'repositories':
305 %if section == 'repositories':
294 <a href="${h.route_path('edit_repo_perms',repo_name=k,_anchor='permissions_manage')}">${_('edit')}</a>
306 <a href="${h.route_path('edit_repo_perms',repo_name=k,_anchor='permissions_manage')}">${_('edit')}</a>
295 %elif section == 'repositories_groups':
307 %elif section == 'repositories_groups':
296 <a href="${h.route_path('edit_repo_group_perms',repo_group_name=k,_anchor='permissions_manage')}">${_('edit')}</a>
308 <a href="${h.route_path('edit_repo_group_perms',repo_group_name=k,_anchor='permissions_manage')}">${_('edit')}</a>
297 %elif section == 'user_groups':
309 %elif section == 'user_groups':
298 ##<a href="${h.route_path('edit_user_group',user_group_id=k)}">${_('edit')}</a>
310 ##<a href="${h.route_path('edit_user_group',user_group_id=k)}">${_('edit')}</a>
299 %endif
311 %endif
300 </td>
312 </td>
301 %endif
313 %endif
302 </tr>
314 </tr>
315 <% total_counter +=1 %>
303 %endif
316 %endif
317
304 %endfor
318 %endfor
305
319
306 <tr id="empty_${section}" class="noborder" style="display:none;">
320 <tr id="empty_${section}" class="noborder" style="display:none;">
307 <td colspan="6">${_('No matching permission defined')}</td>
321 <td colspan="6">${_('No matching permission defined')}</td>
308 </tr>
322 </tr>
309
323
310 </tbody>
324 </tbody>
311 %endif
325 %endif
312 </table>
326 </table>
313 </div>
327 </div>
314 %endif
328 %endif
315 </div>
329 </div>
316 </div>
330 </div>
317 </div>
331 </div>
332
333 <script>
334 $('#total_count_${section}').html(${total_counter})
335 </script>
336
318 %endfor
337 %endfor
319 </div>
338 </div>
320
339
321 <script>
340 <script>
322 $(document).ready(function(){
341 $(document).ready(function(){
323 var showEmpty = function(section){
342 var showEmpty = function(section){
324 var visible = $('.section_{0} tr.perm_row:visible'.format(section)).length;
343 var visible = $('.section_{0} tr.perm_row:visible'.format(section)).length;
325 if(visible === 0){
344 if(visible === 0){
326 $('#empty_{0}'.format(section)).show();
345 $('#empty_{0}'.format(section)).show();
327 }
346 }
328 else{
347 else{
329 $('#empty_{0}'.format(section)).hide();
348 $('#empty_{0}'.format(section)).hide();
330 }
349 }
331 };
350 };
332
351
333 $('.perm_filter').on('change', function(e){
352 $('.perm_filter').on('change', function(e){
334 var self = this;
353 var self = this;
335 var section = $(this).attr('section');
354 var section = $(this).attr('section');
336
355
337 var opts = {};
356 var opts = {};
338 var elems = $('.filter_' + section).each(function(el){
357 var elems = $('.filter_' + section).each(function(el){
339 var perm_type = $(this).attr('perm_type');
358 var perm_type = $(this).attr('perm_type');
340 var checked = this.checked;
359 var checked = this.checked;
341 opts[perm_type] = checked;
360 opts[perm_type] = checked;
342 if(checked){
361 if(checked){
343 $('.'+section+'_'+perm_type).show();
362 $('.'+section+'_'+perm_type).show();
344 }
363 }
345 else{
364 else{
346 $('.'+section+'_'+perm_type).hide();
365 $('.'+section+'_'+perm_type).hide();
347 }
366 }
348 });
367 });
349 showEmpty(section);
368 showEmpty(section);
350 })
369 })
351 })
370 })
352 </script>
371 </script>
353 </%def>
372 </%def>
General Comments 0
You need to be logged in to leave comments. Login now