@@ -30,7 +30,7 class RolesController < ApplicationController | |||
|
30 | 30 | def new |
|
31 | 31 | # Prefills the form with 'Non member' role permissions |
|
32 | 32 | @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) |
|
33 | @roles = Role.all | |
|
33 | @roles = Role.sorted.all | |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | def create |
@@ -43,7 +43,7 class RolesController < ApplicationController | |||
|
43 | 43 | flash[:notice] = l(:notice_successful_create) |
|
44 | 44 | redirect_to :action => 'index' |
|
45 | 45 | else |
|
46 | @roles = Role.all | |
|
46 | @roles = Role.sorted.all | |
|
47 | 47 | render :action => 'new' |
|
48 | 48 | end |
|
49 | 49 | end |
@@ -70,7 +70,7 class RolesController < ApplicationController | |||
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | def permissions |
|
73 | @roles = Role.find(:all, :order => 'builtin, position') | |
|
73 | @roles = Role.sorted.all | |
|
74 | 74 | @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? } |
|
75 | 75 | if request.post? |
|
76 | 76 | @roles.each do |role| |
@@ -26,7 +26,7 class Role < ActiveRecord::Base | |||
|
26 | 26 | ['own', :label_issues_visibility_own] |
|
27 | 27 | ] |
|
28 | 28 | |
|
29 |
|
|
|
29 | named_scope :sorted, {:order => 'builtin, position'} | |
|
30 | 30 | named_scope :givable, { :conditions => "builtin = 0", :order => 'position' } |
|
31 | 31 | named_scope :builtin, lambda { |*args| |
|
32 | 32 | compare = 'not' if args.first == true |
@@ -1,7 +1,7 | |||
|
1 | 1 | class AddRolePosition < ActiveRecord::Migration |
|
2 | 2 | def self.up |
|
3 | 3 | add_column :roles, :position, :integer, :default => 1 |
|
4 | Role.update_all("position = (SELECT COUNT(*) FROM #{Role.table_name} r WHERE r.id < id) + 1") | |
|
4 | Role.all.each_with_index {|role, i| role.update_attribute(:position, i+1)} | |
|
5 | 5 | end |
|
6 | 6 | |
|
7 | 7 | def self.down |
General Comments 0
You need to be logged in to leave comments.
Login now