1. Takumi IINO
  2. RhodeCode

Commits

Marcin Kuzminski  committed 199fd21

Show admin dropdown for users who are admin of repo groups

  • Participants
  • Parent commits fdb0f59
  • Branches beta

Comments (0)

Files changed (4)

File rhodecode/lib/auth.py

View file
  • Ignore whitespace
         return self.admin
 
     @property
+    def repos_admin(self):
+        """
+        Returns list of repositories you're an admin of
+        """
+        return [x[0] for x in self.permissions['repositories'].iteritems()
+                if x[1] == 'repository.admin']
+
+    @property
+    def groups_admin(self):
+        """
+        Returns list of repositories groups you're an admin of
+        """
+        return [x[0] for x in self.permissions['repositories_groups'].iteritems()
+                if x[1] == 'group.admin']
+
+    @property
     def ip_allowed(self):
         """
         Checks if ip_addr used in constructor is allowed from defined list of

File rhodecode/templates/admin/repos_groups/repos_groups_edit.html

View file
  • Ignore whitespace
         ${self.breadcrumbs()}
         <ul class="links">
           <li>
-            <span>${h.link_to(_(u'Add new child group'),h.url('new_repos_group', parent_group=c.repos_group.group_id))}</span>
+            <span>${h.link_to(_(u'Add child group'),h.url('new_repos_group', parent_group=c.repos_group.group_id))}</span>
           </li>
         </ul>
     </div>

File rhodecode/templates/admin/repos_groups/repos_groups_show.html

View file
  • Ignore whitespace
         ${self.breadcrumbs()}
         <ul class="links">
           <li>
-            <span>${h.link_to(_(u'Add new group'),h.url('new_repos_group'))}</span>
+            %if h.HasPermissionAny('hg.admin')():
+             <span>${h.link_to(_(u'Add group'),h.url('new_repos_group'))}</span>
+            %endif
           </li>
         </ul>
     </div>

File rhodecode/templates/base/base.html

View file
  • Ignore whitespace
                 %endif
 
                 % if h.HasPermissionAll('hg.admin')('access admin main page'):
-                 <li>
-                   ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')}
-                    <%def name="admin_menu()">
-                    <ul>
-                        <li>${h.link_to(_('admin journal'),h.url('admin_home'),class_='journal')}</li>
-                        <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li>
-                        <li>${h.link_to(_('repositories groups'),h.url('repos_groups'),class_='repos_groups')}</li>
-                        <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li>
-                        <li>${h.link_to(_('users groups'),h.url('users_groups'),class_='groups')}</li>
-                        <li>${h.link_to(_('permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li>
-                        <li>${h.link_to(_('ldap'),h.url('ldap_home'),class_='ldap')}</li>
-                        <li>${h.link_to(_('defaults'),h.url('defaults'),class_='defaults')}</li>
-                        <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li>
-                    </ul>
-                    </%def>
-                    ## ADMIN MENU
-                    ${admin_menu()}
-                 </li>
+                   <li>
+                     ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')}
+                      <%def name="admin_menu()">
+                      <ul>
+                          <li>${h.link_to(_('admin journal'),h.url('admin_home'),class_='journal')}</li>
+                          <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li>
+                          <li>${h.link_to(_('repositories groups'),h.url('repos_groups'),class_='repos_groups')}</li>
+                          <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li>
+                          <li>${h.link_to(_('users groups'),h.url('users_groups'),class_='groups')}</li>
+                          <li>${h.link_to(_('permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li>
+                          <li>${h.link_to(_('ldap'),h.url('ldap_home'),class_='ldap')}</li>
+                          <li>${h.link_to(_('defaults'),h.url('defaults'),class_='defaults')}</li>
+                          <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li>
+                      </ul>
+                      </%def>
+                      ## ADMIN MENU
+                      ${admin_menu()}
+                   </li>
+                ## if you're a admin of any groups, show admin menu for it
+                % elif c.rhodecode_user.groups_admin:
+                   <li>
+                     ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')}
+                      <%def name="admin_menu_simple()">
+                      <ul>
+                          <li>${h.link_to(_('repositories groups'),h.url('repos_groups'),class_='repos_groups')}</li>
+                      </ul>
+                      </%def>
+                      ## ADMIN MENU
+                      ${admin_menu_simple()}
+                   </li>
                 % endif
                </ul>
             </li>
                 <span>${_('Search')}</span>
                 </a>
             </li>
-            %if h.HasPermissionAll('hg.admin')('access admin main page'):
+            % if h.HasPermissionAll('hg.admin')('access admin main page'):
             <li ${is_current('admin')}>
                <a class="menu_link" title="${_('Admin')}" href="${h.url('admin_home')}">
                <span class="icon">
                </a>
                 ${admin_menu()}
             </li>
-            %endif
+            % elif c.rhodecode_user.groups_admin:
+            <li ${is_current('admin')}>
+               <a class="menu_link" title="${_('Admin')}" href="${h.url('admin_home')}">
+               <span class="icon">
+                   <img src="${h.url('/images/icons/cog_edit.png')}" alt="${_('Admin')}" />
+               </span>
+               <span>${_('Admin')}</span>
+               </a>
+                ${admin_menu_simple()}
+            </li>                
+            % endif
             ${usermenu()}
         %endif
 <script type="text/javascript">