Changeset - fda60c2ad65f
[Not reviewed]
beta
0 4 1
Marcin Kuzminski - 13 years ago 2013-04-04 14:08:58
marcin@python-works.com
fixed sort of permissions summary it's now perm+name
unified permissions summary for users and user groups
5 files changed with 76 insertions and 219 deletions:
0 comments (0 inline, 0 general)
rhodecode/templates/admin/permissions/permissions.html
Show inline comments
 
@@ -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 -->
rhodecode/templates/admin/users/user_edit.html
Show inline comments
 
@@ -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 -->
rhodecode/templates/admin/users/user_edit_my_account.html
Show inline comments
 
@@ -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>
rhodecode/templates/admin/users_groups/users_group_edit.html
Show inline comments
 
@@ -138,9 +138,13 @@ ${h.end_form()}
 
        </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 @@ ${h.end_form()}
 
    </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>
rhodecode/templates/base/perms_summary.html
Show inline comments
 
new file 100644
 
## 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>
0 comments (0 inline, 0 general)