Explorar o código

HUE-9129 [useradmin] Add a is_admin column to the list user page

Romain %!s(int64=5) %!d(string=hai) anos
pai
achega
c6d3a7ca6a

+ 15 - 15
apps/useradmin/src/useradmin/templates/list_groups.mako

@@ -64,9 +64,9 @@ ${layout.menubar(section='groups')}
       <thead>
       <tr>
         %if is_admin(user):
-            <th width="1%">
-              <div class="select-all hue-checkbox fa"></div>
-            </th>
+          <th width="1%">
+            <div class="select-all hue-checkbox fa"></div>
+          </th>
         %endif
         <th>${_('Group Name')}</th>
         <th>${_('Members')}</th>
@@ -74,27 +74,27 @@ ${layout.menubar(section='groups')}
       </tr>
       </thead>
       <tbody>
-          % for group in groups:
+        % for group in groups:
           <tr class="tableRow"
               data-search="${group.name}${', '.join([group_user.username for group_user in group.user_set.all()])}">
-          %if is_admin(user):
+          % if is_admin(user):
             <td data-row-selector-exclude="true">
               <div class="hue-checkbox groupCheck fa" data-name="${group.name}" data-row-selector-exclude="true"></div>
             </td>
-          %endif
+          % endif
           <td>
-            %if is_admin(user):
+            % if is_admin(user):
               <strong><a title="${ _('Edit %(groupname)s') % dict(groupname=group.name) }"
-                         href="${ url('useradmin.views.edit_group', name=group.name) }"
-                         data-row-selector="true">${group.name}</a></strong>
-            %else:
+                        href="${ url('useradmin.views.edit_group', name=group.name) }"
+                        data-row-selector="true">${group.name}</a></strong>
+            % else:
               <strong>${group.name}</strong>
-            %endif
+            % endif
           </td>
-            <td>${', '.join([group_user.username for group_user in group.user_set.all()])}</td>
-            <td>${', '.join([perm.app + "." + perm.action for perm in group_permissions(group)])}</td>
-          </tr>
-          % endfor
+          <td>${', '.join([group_user.username for group_user in group.user_set.all()])}</td>
+          <td>${', '.join([perm.app + "." + perm.action for perm in group_permissions(group)])}</td>
+        </tr>
+        % endfor
       </tbody>
       <tfoot class="hide">
       <tr>

+ 42 - 33
apps/useradmin/src/useradmin/templates/list_users.mako

@@ -37,15 +37,15 @@ ${layout.menubar(section='users')}
 
     <%actionbar:render>
       <%def name="search()">
-          <input type="text" class="input-xlarge search-query filter-input" placeholder="${_('Search for name, group, etc...')}">
+        <input type="text" class="input-xlarge search-query filter-input" placeholder="${_('Search for name, group, etc...')}">
       </%def>
       <%def name="actions()">
-        %if is_admin(user):
-            <button class="btn delete-user-btn" title="${_('Delete')}" disabled="disabled"><i class="fa fa-trash-o"></i> ${_('Delete')}</button>
-        %endif
+        % if is_admin(user):
+          <button class="btn delete-user-btn" title="${_('Delete')}" disabled="disabled"><i class="fa fa-trash-o"></i> ${_('Delete')}</button>
+        % endif
       </%def>
       <%def name="creation()">
-        %if is_admin(user):
+        % if is_admin(user):
             % if not is_ldap_setup:
               <a href="${ url('useradmin.views.edit_user') }" class="btn"><i class="fa fa-user"></i> ${_('Add user')}</a>
             %endif
@@ -62,7 +62,7 @@ ${layout.menubar(section='users')}
               title="${ _('Learn how to integrate Hue with your company LDAP') }" target="_blank">
               <i class="fa fa-question-circle"></i>
             </a>
-        %endif
+        % endif
       </%def>
     </%actionbar:render>
 
@@ -70,43 +70,51 @@ ${layout.menubar(section='users')}
       <thead>
       <tr>
         %if is_admin(user):
-            <th width="1%">
-              <div class="select-all hue-checkbox fa"></div>
-            </th>
+          <th width="1%">
+            <div class="select-all hue-checkbox fa"></div>
+          </th>
         %endif
         <th>${_('Username')}</th>
         <th>${_('First Name')}</th>
         <th>${_('Last Name')}</th>
         <th>${_('E-mail')}</th>
+        <th>${_('Is admin')}</th>
         <th>${_('Groups')}</th>
         <th>${_('Last Login')}</th>
       </tr>
       </thead>
       <tbody>
-          % for listed_user in users:
-          <tr class="tableRow"
-              data-search="${listed_user.username}${listed_user.first_name}${listed_user.last_name}${listed_user.email}${', '.join([group.name for group in listed_user.groups.all()])}">
-          %if is_admin(user):
-              <td data-row-selector-exclude="true">
-                <div class="hue-checkbox userCheck fa" data-row-selector-exclude="true" data-id="${ listed_user.id }"></div>
-              </td>
-          %endif
+        % for listed_user in users:
+        <tr class="tableRow"
+            data-search="${listed_user.username}${listed_user.first_name}${listed_user.last_name}${listed_user.email}${', '.join([group.name for group in listed_user.groups.all()])}">
+          % if is_admin(user):
+            <td data-row-selector-exclude="true">
+              <div class="hue-checkbox userCheck fa" data-row-selector-exclude="true" data-id="${ listed_user.id }"></div>
+            </td>
+          % endif
           <td>
-            %if is_admin(user) or user.username == listed_user.username:
-              <strong><a title="${_('Edit %(username)s') % dict(username=listed_user.username)}"
-                         href="${ url('useradmin.views.edit_user', username=listed_user.username) }"
-                         data-row-selector="true">${listed_user.username}</a></strong>
-            %else:
+            % if is_admin(user) or user.username == listed_user.username:
+              <strong>
+                <a title="${_('Edit %(username)s') % dict(username=listed_user.username)}"
+                    href="${ url('useradmin.views.edit_user', username=listed_user.username) }"
+                    data-row-selector="true">${listed_user.username}</a>
+              </strong>
+            % else:
               <strong>${listed_user.username}</strong>
-            %endif
+            % endif
           </td>
-            <td>${listed_user.first_name}</td>
-            <td>${listed_user.last_name}</td>
-            <td>${listed_user.email}</td>
-            <td>${', '.join([group.name for group in listed_user.groups.all()])}</td>
-            <td>${date(listed_user.last_login)} ${time(listed_user.last_login).replace("p.m.","PM").replace("a.m.","AM")}</td>
-          </tr>
-          % endfor
+          <td>${listed_user.first_name}</td>
+          <td>${listed_user.last_name}</td>
+          <td>${listed_user.email}</td>
+          <td>
+            % if is_admin(listed_user):
+              <i class="fa fa-check"></i>
+            % endif
+          </td>
+          <td>${', '.join([group.name for group in listed_user.groups.all()])}</td>
+          <td>${date(listed_user.last_login)} ${time(listed_user.last_login).replace("p.m.","PM").replace("a.m.","AM")}</td>
+        </tr>
+        % endfor
       </tbody>
       <tfoot class="hide">
       <tr>
@@ -170,9 +178,10 @@ ${layout.menubar(section='users')}
       "bInfo": false,
       "bFilter": true,
       "aoColumns": [
-        %if is_admin(user):
-            { "bSortable": false },
-        %endif
+        % if is_admin(user):
+          { "bSortable": false },
+        % endif
+        null,
         null,
         null,
         null,