Browse Source

use "do end" instead of {} at app/models/user.rb

git-svn-id: http://svn.redmine.org/redmine/trunk@19973 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.2.0
Toshi MARUYAMA 3 years ago
parent
commit
de3fcfe63e
1 changed files with 8 additions and 7 deletions
  1. 8
    7
      app/models/user.rb

+ 8
- 7
app/models/user.rb View File

def membership(project) def membership(project)
project_id = project.is_a?(Project) ? project.id : project project_id = project.is_a?(Project) ? project.id : project


@membership_by_project_id ||= Hash.new {|h, project_id|
h[project_id] = memberships.where(:project_id => project_id).first
}
@membership_by_project_id ||=
Hash.new do |h, project_id|
h[project_id] = memberships.where(:project_id => project_id).first
end
@membership_by_project_id[project_id] @membership_by_project_id[project_id]
end end


roles = roles_for_project(context) roles = roles_for_project(context)
return false unless roles return false unless roles


roles.any? {|role|
roles.any? do |role|
(context.is_public? || role.member?) && (context.is_public? || role.member?) &&
role.allowed_to?(action) && role.allowed_to?(action) &&
(block_given? ? yield(role, self) : true) (block_given? ? yield(role, self) : true)
}
end
elsif context && context.is_a?(Array) elsif context && context.is_a?(Array)
if context.empty? if context.empty?
false false


# authorize if user has at least one role that has this permission # authorize if user has at least one role that has this permission
roles = self.roles.to_a | [builtin_role] roles = self.roles.to_a | [builtin_role]
roles.any? {|role|
roles.any? do |role|
role.allowed_to?(action) && role.allowed_to?(action) &&
(block_given? ? yield(role, self) : true) (block_given? ? yield(role, self) : true)
}
end
else else
false false
end end

Loading…
Cancel
Save