changeset 3666:fda60c2ad65f beta

fixed sort of permissions summary it's now perm+name unified permissions summary for users and user groups
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 04 Apr 2013 14:08:58 +0200
parents 690a955ba785
children 16c153cf1759
files rhodecode/templates/admin/permissions/permissions.html rhodecode/templates/admin/users/user_edit.html rhodecode/templates/admin/users/user_edit_my_account.html rhodecode/templates/admin/users_groups/users_group_edit.html rhodecode/templates/base/perms_summary.html
diffstat 5 files changed, 76 insertions(+), 219 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/templates/admin/permissions/permissions.html	Thu Apr 04 13:18:24 2013 +0200
+++ b/rhodecode/templates/admin/permissions/permissions.html	Thu Apr 04 14:08:58 2013 +0200
@@ -104,63 +104,8 @@
     </div>
 
     ## permissions overview
-    <div id="perms" class="table">
-           %for section in sorted(c.perm_user.permissions.keys()):
-              <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
-              %if not c.perm_user.permissions[section]:
-                  <span class="empty_data">${_('Nothing here yet')}</span>
-              %else:
-              <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
-               <table id="tbl_list_${section}">
-                <thead>
-                    <tr>
-                    <th class="left">${_('Name')}</th>
-                    <th class="left">${_('Permission')}</th>
-                    <th class="left">${_('Edit Permission')}</th>
-                </thead>
-                <tbody>
-                %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
-                     %>
-                    <tr>
-                        <td>
-                            %if section == 'repositories':
-                                <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
-                            %elif section == 'repositories_groups':
-                                <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
-                            %else:
-                                ${h.get_permission_name(k)}
-                            %endif
-                        </td>
-                        <td>
-                            %if section == 'global':
-                             ${h.boolicon(k.split('.')[-1] != 'none')}
-                            %else:
-                             <span class="perm_tag ${_perm}">${section_perm}</span>
-                            %endif
-                        </td>
-                        <td>
-                            %if section == 'repositories':
-                                <a href="${h.url('edit_repo',repo_name=k,anchor='permissions_manage')}">${_('edit')}</a>
-                            %elif section == 'repositories_groups':
-                                <a href="${h.url('edit_repos_group',group_name=k,anchor='permissions_manage')}">${_('edit')}</a>
-                            %else:
-                                --
-                            %endif
-                        </td>
-                    </tr>
-                %endfor
-                </tbody>
-               </table>
-              </div>
-              %endif
-           %endfor
-    </div>
+    <%include file="/base/perms_summary.html"/>
+
 </div>
 <div class="box box-left" style="clear:left">
     <!-- box / title -->
--- a/rhodecode/templates/admin/users/user_edit.html	Thu Apr 04 13:18:24 2013 +0200
+++ b/rhodecode/templates/admin/users/user_edit.html	Thu Apr 04 14:08:58 2013 +0200
@@ -190,63 +190,9 @@
     ${h.end_form()}
 
     ## permissions overview
-    <div id="perms" class="table">
-           %for section in sorted(c.perm_user.permissions.keys()):
-              <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
-              %if not c.perm_user.permissions[section]:
-                  <span class="empty_data">${_('Nothing here yet')}</span>
-              %else:
-              <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
-               <table id="tbl_list_${section}">
-                <thead>
-                    <tr>
-                    <th class="left">${_('Name')}</th>
-                    <th class="left">${_('Permission')}</th>
-                    <th class="left">${_('Edit Permission')}</th>
-                </thead>
-                <tbody>
-                %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
-                     %>
-                    <tr>
-                        <td>
-                            %if section == 'repositories':
-                                <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
-                            %elif section == 'repositories_groups':
-                                <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
-                            %else:
-                                ${h.get_permission_name(k)}
-                            %endif
-                        </td>
-                        <td>
-                            %if section == 'global':
-                             ${h.boolicon(k.split('.')[-1] != 'none')}
-                            %else:
-                             <span class="perm_tag ${_perm}">${section_perm}</span>
-                            %endif
-                        </td>
-                        <td>
-                            %if section == 'repositories':
-                                <a href="${h.url('edit_repo',repo_name=k,anchor='permissions_manage')}">${_('edit')}</a>
-                            %elif section == 'repositories_groups':
-                                <a href="${h.url('edit_repos_group',group_name=k,anchor='permissions_manage')}">${_('edit')}</a>
-                            %else:
-                                --
-                            %endif
-                        </td>
-                    </tr>
-                %endfor
-                </tbody>
-               </table>
-              </div>
-              %endif
-           %endfor
-    </div>
+    <%namespace name="p" file="/base/perms_summary.html"/>
+    ${p.perms_summary(c.perm_user.permissions)}
+
 </div>
 <div class="box box-left" style="clear:left">
     <!-- box / title -->
--- a/rhodecode/templates/admin/users/user_edit_my_account.html	Thu Apr 04 13:18:24 2013 +0200
+++ b/rhodecode/templates/admin/users/user_edit_my_account.html	Thu Apr 04 14:08:58 2013 +0200
@@ -43,54 +43,10 @@
          </ul>
     </div>
     <!-- end box / title -->
-    <div id="perms_container">
-        <div id="perms" class="table">
-           %for section in sorted(c.rhodecode_user.permissions.keys()):
-            <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
+    ## permissions overview
+    <%namespace name="p" file="/base/perms_summary.html"/>
+    ${p.perms_summary(c.perm_user.permissions)}
 
-            <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
-            <table id="tbl_list_${section}">
-              <thead>
-                  <tr>
-                  <th class="left">${_('Name')}</th>
-                  <th class="left">${_('Permission')}</th>
-              </thead>
-              <tbody>
-            %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']:
-                <tr>
-                    <td>
-                        %if section == 'repositories':
-                            <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
-                        %elif section == 'repositories_groups':
-                            <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
-                        %else:
-                            ${k}
-                        %endif
-                    </td>
-                    <td>
-                        %if section == 'global':
-                         ${h.boolicon(True)}
-                        %else:
-                        <span class="perm_tag ${_perm}">${section_perm}</span>
-                        %endif
-                     </td>
-                </tr>
-             %endif
-            %endfor
-            </tbody>
-            </table>
-            </div>
-           %endfor
-        </div>
-    </div>
     <div id="my_container" style="display:none">
         <div class="table yui-skin-sam" id="repos_list_wrap"></div>
         <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
--- a/rhodecode/templates/admin/users_groups/users_group_edit.html	Thu Apr 04 13:18:24 2013 +0200
+++ b/rhodecode/templates/admin/users_groups/users_group_edit.html	Thu Apr 04 14:08:58 2013 +0200
@@ -138,9 +138,13 @@
         </div>
     </div>
     ${h.end_form()}
+
+    ## permissions overview
+    <%namespace name="p" file="/base/perms_summary.html"/>
+    ${p.perms_summary(c.users_group.permissions)}
 </div>
 
-<div class="box box-right">
+<div class="box box-right" style="clear:right">
     <!-- box / title -->
     <div class="title">
         <h5>${_('Group members')}</h5>
@@ -165,63 +169,6 @@
     </div>
 </div>
 
-<div class="box box-left">
-    <!-- box / title -->
-    <div class="title">
-        <h5>${_('Permissions defined for this group')}</h5>
-    </div>
- ## permissions overview
-    <div id="perms" class="table">
-       %for section in sorted(c.users_group.permissions.keys()):
-          <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
-          %if not c.users_group.permissions:
-              <span class="empty_data">${_('No permissions set yet')}</span>
-          %else:
-          <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
-           <table id="tbl_list_repository">
-            <thead>
-                <tr>
-                <th class="left">${_('Name')}</th>
-                <th class="left">${_('Permission')}</th>
-                <th class="left">${_('Edit Permission')}</th>
-            </thead>
-            <tbody>
-            %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]
-                 %>
-                <tr>
-                    <td>
-                        %if section == 'repositories':
-                            <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
-                        %elif section == 'repositories_groups':
-                            <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
-                        %endif
-                    </td>
-                    <td>
-                         <span class="perm_tag ${_perm}">${section_perm}</span>
-                    </td>
-                    <td>
-                        %if section == 'repositories':
-                            <a href="${h.url('edit_repo',repo_name=k,anchor='permissions_manage')}">${_('edit')}</a>
-                        %elif section == 'repositories_groups':
-                            <a href="${h.url('edit_repos_group',group_name=k,anchor='permissions_manage')}">${_('edit')}</a>
-                        %else:
-                            --
-                        %endif
-                    </td>
-                </tr>
-            %endfor
-            </tbody>
-           </table>
-          </div>
-          %endif
-       %endfor
-    </div>
-</div>
-
-
 <script type="text/javascript">
   MultiSelectWidget('users_group_members','available_members','edit_users_group');
 </script>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rhodecode/templates/base/perms_summary.html	Thu Apr 04 14:08:58 2013 +0200
@@ -0,0 +1,63 @@
+## snippet for displaying permissions overview for users
+
+<%def name="perms_summary(permissions)">
+<div id="perms" class="table">
+     %for section in sorted(permissions.keys()):
+        <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
+        %if not permissions[section]:
+            <span class="empty_data">${_('No permissions defined yet')}</span>
+        %else:
+        <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
+         <table id="tbl_list_${section}">
+          <thead>
+              <tr>
+              <th class="left">${_('Name')}</th>
+              <th class="left">${_('Permission')}</th>
+              <th class="left">${_('Edit Permission')}</th>
+          </thead>
+          <tbody>
+          %if section == 'global':
+              %for k in sorted(permissions[section], key=lambda s: s.lower()):
+                  <tr>
+                      <td>
+                          ${h.get_permission_name(k)}
+                      </td>
+                      <td>
+                           ${h.boolicon(k.split('.')[-1] != 'none')}
+                      </td>
+                      <td>
+                           <a href="${h.url('edit_permission', id='default')}">${_('edit')}</a>
+                      </td>
+                  </tr>
+              %endfor
+          %else:
+              %for k, section_perm in sorted(permissions[section].items(), key=lambda s: s[1]+s[0].lower()):
+                  <tr>
+                      <td>
+                          %if section == 'repositories':
+                              <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
+                          %elif section == 'repositories_groups':
+                              <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
+                          %endif
+                      </td>
+                      <td>
+                           <span class="perm_tag ${section_perm.split('.')[-1]}">${section_perm}</span>
+                      </td>
+                      <td>
+                          %if section == 'repositories':
+                              <a href="${h.url('edit_repo',repo_name=k,anchor='permissions_manage')}">${_('edit')}</a>
+                          %elif section == 'repositories_groups':
+                              <a href="${h.url('edit_repos_group',group_name=k,anchor='permissions_manage')}">${_('edit')}</a>
+                          %endif
+                      </td>
+                  </tr>
+              %endfor
+          %endif
+
+          </tbody>
+         </table>
+        </div>
+        %endif
+     %endfor
+</div>
+</%def>