]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3106 Error trying to configure group privileges for a project
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 27 Mar 2012 13:01:13 +0000 (15:01 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 27 Mar 2012 13:02:57 +0000 (15:02 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_groups.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_users.html.erb

index aeda37991525559738d3a6cdc2f7b74e7ba18504..fdb1a8d902e4485f522d9dc5c2dca6ca2610ed40 100644 (file)
@@ -31,7 +31,8 @@ class RolesController < ApplicationController
   def projects
     @projects=Project.find(:all,
       :conditions => {:enabled=>true, :scope => Project::SCOPE_SET, :qualifier => [Project::QUALIFIER_VIEW, Project::QUALIFIER_SUBVIEW, Project::QUALIFIER_PROJECT]},
-      :include => ['user_roles', 'group_roles']).sort{|a,b| a.name.downcase<=>b.name.downcase}
+      :include => ['user_roles', 'group_roles'])
+    Api::Utils.insensitive_sort!(@projects){|project| project.name}
   end
 
   def edit_users
index 55936a07bfe5ecb045ebb5a810ac84cf413903b4..775018331966e0bfc1f6de29f4a36488eb362a04 100644 (file)
@@ -21,24 +21,25 @@ module RolesHelper
   
   def users(role, resource_id=nil)
     resource_id=(resource_id.blank? ? nil : resource_id.to_i)
-    user_roles=UserRole.find(:all, :conditions => {:role => role, :resource_id => resource_id})
-    user_roles.map {|ur| ur.user}.sort
+    user_roles=UserRole.find(:all, :include => 'user', :conditions => {:role => role, :resource_id => resource_id})
+    users = user_roles.map { |ur| ur.user }
+    Api::Utils.insensitive_sort(users) {|user| user.name}
   end
 
   def all_users
-    User.find(:all, :conditions => ["active=?", true], :order => 'name')
+    users = User.find(:all, :conditions => ["active=?", true])
+    Api::Utils.insensitive_sort(users) {|user| user.name}
   end
 
   def groups(role, resource_id=nil)
     resource_id=(resource_id.blank? ? nil : resource_id.to_i)
     group_roles=GroupRole.find(:all, :conditions => {:role => role, :resource_id => resource_id})
-    group_roles.map{|ur| ur.group}.sort do |x,y|
-      x ? x<=>y : -1
-    end
+    groups = group_roles.map{|ur| ur.group}
+    Api::Utils.insensitive_sort(groups) {|group| group ? group.name : ''}
   end
 
   def all_groups
-    [nil].concat(Group.find(:all, :order => 'name'))
+    [nil].concat(Api::Utils.insensitive_sort(Group.all) {|group| group.name})
   end
 
   def group_name(group)
index 33a568e23b25804a69e0ecfd1516e3d57a3f5364..fec44e938a915393bb1260fb177094c5e9ecd68e 100644 (file)
     <table>
       <tbody>
         <tr>
-          <td style="padding: 5px 0pt;" valign="top">
+          <td style="padding: 5px 0;" valign="top">
             <h2>Ungranted groups</h2>
-            <select name="from" id="from" size="20" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
-              <% ungranted_groups.sort.each do |group| %>
+            <select name="from" id="from" size="20" style="margin: 5px 0; width: 300px;" multiple="multiple">
+              <% ungranted_groups.each do |group| %>
                 <option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
               <% end %>
             </select>
           </td>
-          <td style="padding: 0pt 10px;" align="center">
+          <td style="padding: 0 10px;" align="center">
             <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
             <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
             <button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
@@ -38,7 +38,7 @@
             <h2>Role: <%= role_name(@role) -%></h2>
 
             <select name="groups[]" id="to" size="20" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
-              <% granted_groups.sort.each do |group| %>
+              <% granted_groups.each do |group| %>
                 <option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
               <% end %>
             </select><br>
index b0be2583ba569c8c14c025a1973e70651a1731cb..7c724973203ac9c1e6a3639c370b9df5f7076c01 100644 (file)
     <table>
       <tbody>
         <tr>
-          <td style="padding: 5px 0pt;" valign="top">
+          <td style="padding: 5px 0;" valign="top">
             <h2>Ungranted users</h2>
-            <select name="from" id="from" size="30" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
-              <% ungranted_users.sort.each do |user| %>
+            <select name="from" id="from" size="30" style="margin: 5px 0; width: 300px;" multiple="multiple">
+              <% ungranted_users.each do |user| %>
                 <option value="<%= user.id -%>"><%= user.name -%></option>
               <% end %>
             </select>
           </td>
-          <td style="padding: 0pt 10px;" align="center">
+          <td style="padding: 0 10px;" align="center">
             <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
             <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
             <button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
           <td class="box" style="padding: 5px 10px;" valign="top">
             <h2>Role: <%= role_name(@role) -%></h2>
 
-            <select name="users[]" id="to" size="30" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
+            <select name="users[]" id="to" size="30" multiple="multiple" style="margin: 5px 0; width: 300px;">
               <%= options_from_collection_for_select(granted_users, "id", "name") %>
             </select><br>
 
-            <div style="padding: 5px 0pt;">
+            <div style="padding: 5px 0;">
               <input id="save" value="Save" onclick="SelectBox.select_all('to');submit();return false;" type="submit">
             </div>
           </td>