changeset 2436:4ab0e4d478b6 codereview

merge with beta
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 10 Jun 2012 02:26:02 +0200
parents f29469677319 (current diff) 751c1c56e080 (diff)
children 471ac5256400
files rhodecode/controllers/admin/users.py rhodecode/templates/admin/users/user_edit.html
diffstat 3 files changed, 51 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/docs/changelog.rst	Sun Jun 10 02:08:10 2012 +0200
+++ b/docs/changelog.rst	Sun Jun 10 02:26:02 2012 +0200
@@ -31,6 +31,7 @@
   reformated based on user suggestions. Additional rss/atom feeds for user
   journal
 - various i18n improvements
+- #478 permissions overview for admin in user edit view
 
 fixes
 +++++
--- a/rhodecode/controllers/admin/users.py	Sun Jun 10 02:08:10 2012 +0200
+++ b/rhodecode/controllers/admin/users.py	Sun Jun 10 02:26:02 2012 +0200
@@ -35,7 +35,8 @@
 from rhodecode.lib.exceptions import DefaultUserException, \
     UserOwnsReposException
 from rhodecode.lib import helpers as h
-from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
+from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator,\
+    AuthUser
 from rhodecode.lib.base import BaseController, render
 
 from rhodecode.model.db import User, Permission, UserEmailMap
@@ -111,7 +112,7 @@
         # url('user', id=ID)
         user_model = UserModel()
         c.user = user_model.get(id)
-
+        c.perm_user = AuthUser(user_id=id)
         _form = UserForm(edit=True, old_data={'user_id': id,
                                               'email': c.user.email})()
         form_result = {}
@@ -174,6 +175,7 @@
         if c.user.username == 'default':
             h.flash(_("You can't edit this user"), category='warning')
             return redirect(url('users'))
+        c.perm_user = AuthUser(user_id=id)
         c.user.permissions = {}
         c.granted_permissions = UserModel().fill_perms(c.user)\
             .permissions['global']
--- a/rhodecode/templates/admin/users/user_edit.html	Sun Jun 10 02:08:10 2012 +0200
+++ b/rhodecode/templates/admin/users/user_edit.html	Sun Jun 10 02:26:02 2012 +0200
@@ -157,6 +157,52 @@
         </div>
     </div>
     ${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>
+  
+              <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 c.perm_user.permissions[section]:
+                     <%
+                     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:
+                                ${k}
+                            %endif
+                        </td>
+                        <td>
+                            %if section == 'global':
+                             ${h.bool2icon(True)}
+                            %else:
+                            <span class="perm_tag ${_perm}">${section_perm}</span>
+                            %endif
+                         </td>
+                    </tr>
+                %endfor
+                </tbody>
+               </table>
+              </div>
+           %endfor
+    </div>    
 </div>
 <div class="box box-right">
     <!-- box / title -->