diff --git a/rhodecode/templates/admin/permissions/permissions.html b/rhodecode/templates/admin/permissions/permissions.html --- a/rhodecode/templates/admin/permissions/permissions.html +++ b/rhodecode/templates/admin/permissions/permissions.html @@ -104,63 +104,8 @@ ## permissions overview -
- %for section in sorted(c.perm_user.permissions.keys()): -
${section.replace("_"," ").capitalize()}
- %if not c.perm_user.permissions[section]: - ${_('Nothing here yet')} - %else: -
- - - - - - - - - %for k in sorted(c.perm_user.permissions[section], key=lambda s: s.lower): - <% - if section != 'global': - section_perm = c.perm_user.permissions[section].get(k) - _perm = section_perm.split('.')[-1] - else: - _perm = section_perm = None - %> - - - - - - %endfor - -
${_('Name')}${_('Permission')}${_('Edit Permission')}
- %if section == 'repositories': - ${k} - %elif section == 'repositories_groups': - ${k} - %else: - ${h.get_permission_name(k)} - %endif - - %if section == 'global': - ${h.boolicon(k.split('.')[-1] != 'none')} - %else: - ${section_perm} - %endif - - %if section == 'repositories': - ${_('edit')} - %elif section == 'repositories_groups': - ${_('edit')} - %else: - -- - %endif -
-
- %endif - %endfor -
+ <%include file="/base/perms_summary.html"/> +
diff --git a/rhodecode/templates/admin/users/user_edit.html b/rhodecode/templates/admin/users/user_edit.html --- a/rhodecode/templates/admin/users/user_edit.html +++ b/rhodecode/templates/admin/users/user_edit.html @@ -190,63 +190,9 @@ ${h.end_form()} ## permissions overview -
- %for section in sorted(c.perm_user.permissions.keys()): -
${section.replace("_"," ").capitalize()}
- %if not c.perm_user.permissions[section]: - ${_('Nothing here yet')} - %else: -
- - - - - - - - - %for k in sorted(c.perm_user.permissions[section], key=lambda s: s.lower): - <% - if section != 'global': - section_perm = c.perm_user.permissions[section].get(k) - _perm = section_perm.split('.')[-1] - else: - _perm = section_perm = None - %> - - - - - - %endfor - -
${_('Name')}${_('Permission')}${_('Edit Permission')}
- %if section == 'repositories': - ${k} - %elif section == 'repositories_groups': - ${k} - %else: - ${h.get_permission_name(k)} - %endif - - %if section == 'global': - ${h.boolicon(k.split('.')[-1] != 'none')} - %else: - ${section_perm} - %endif - - %if section == 'repositories': - ${_('edit')} - %elif section == 'repositories_groups': - ${_('edit')} - %else: - -- - %endif -
-
- %endif - %endfor -
+ <%namespace name="p" file="/base/perms_summary.html"/> + ${p.perms_summary(c.perm_user.permissions)} +
diff --git a/rhodecode/templates/admin/users/user_edit_my_account.html b/rhodecode/templates/admin/users/user_edit_my_account.html --- a/rhodecode/templates/admin/users/user_edit_my_account.html +++ b/rhodecode/templates/admin/users/user_edit_my_account.html @@ -43,54 +43,10 @@
-
-
- %for section in sorted(c.rhodecode_user.permissions.keys()): -
${section.replace("_"," ").capitalize()}
+ ## permissions overview + <%namespace name="p" file="/base/perms_summary.html"/> + ${p.perms_summary(c.perm_user.permissions)} -
- - - - - - - - %for k in sorted(c.rhodecode_user.permissions[section], key=lambda s: s.lower): - <% - if section != 'global': - section_perm = c.rhodecode_user.permissions[section].get(k) - _perm = section_perm.split('.')[-1] - else: - _perm = section_perm = None - %> - %if _perm not in ['none']: - - - - - %endif - %endfor - -
${_('Name')}${_('Permission')}
- %if section == 'repositories': - ${k} - %elif section == 'repositories_groups': - ${k} - %else: - ${k} - %endif - - %if section == 'global': - ${h.boolicon(True)} - %else: - ${section_perm} - %endif -
-
- %endfor -
-
${h.end_form()} + + ## permissions overview + <%namespace name="p" file="/base/perms_summary.html"/> + ${p.perms_summary(c.users_group.permissions)} -
+
${_('Group members')}
@@ -165,63 +169,6 @@
-
- -
-
${_('Permissions defined for this group')}
-
- ## permissions overview -
- %for section in sorted(c.users_group.permissions.keys()): -
${section.replace("_"," ").capitalize()}
- %if not c.users_group.permissions: - ${_('No permissions set yet')} - %else: -
- - - - - - - - - %for k in sorted(c.users_group.permissions[section], key=lambda s: s.lower): - <% - section_perm = c.users_group.permissions[section].get(k) - _perm = section_perm.split('.')[-1] - %> - - - - - - %endfor - -
${_('Name')}${_('Permission')}${_('Edit Permission')}
- %if section == 'repositories': - ${k} - %elif section == 'repositories_groups': - ${k} - %endif - - ${section_perm} - - %if section == 'repositories': - ${_('edit')} - %elif section == 'repositories_groups': - ${_('edit')} - %else: - -- - %endif -
-
- %endif - %endfor -
-
- - diff --git a/rhodecode/templates/base/perms_summary.html b/rhodecode/templates/base/perms_summary.html new file mode 100644 --- /dev/null +++ b/rhodecode/templates/base/perms_summary.html @@ -0,0 +1,63 @@ +## snippet for displaying permissions overview for users + +<%def name="perms_summary(permissions)"> +
+ %for section in sorted(permissions.keys()): +
${section.replace("_"," ").capitalize()}
+ %if not permissions[section]: + ${_('No permissions defined yet')} + %else: +
+ + + + + + + + + %if section == 'global': + %for k in sorted(permissions[section], key=lambda s: s.lower()): + + + + + + %endfor + %else: + %for k, section_perm in sorted(permissions[section].items(), key=lambda s: s[1]+s[0].lower()): + + + + + + %endfor + %endif + + +
${_('Name')}${_('Permission')}${_('Edit Permission')}
+ ${h.get_permission_name(k)} + + ${h.boolicon(k.split('.')[-1] != 'none')} + + ${_('edit')} +
+ %if section == 'repositories': + ${k} + %elif section == 'repositories_groups': + ${k} + %endif + + ${section_perm} + + %if section == 'repositories': + ${_('edit')} + %elif section == 'repositories_groups': + ${_('edit')} + %endif +
+
+ %endif + %endfor +
+