Abilities refactoring
This commit is contained in:
parent
7a9fc48080
commit
ccc9bed893
7 changed files with 83 additions and 8 deletions
|
@ -161,6 +161,18 @@ class Project < ActiveRecord::Base
|
|||
@admins ||= users_projects.includes(:user).where(:project_access => PROJECT_RWA).map(&:user)
|
||||
end
|
||||
|
||||
def allow_read_for?(user)
|
||||
!users_projects.where(:user_id => user.id, :project_access => [PROJECT_R, PROJECT_RW, PROJECT_RWA]).empty?
|
||||
end
|
||||
|
||||
def allow_write_for?(user)
|
||||
!users_projects.where(:user_id => user.id, :project_access => [PROJECT_RW, PROJECT_RWA]).empty?
|
||||
end
|
||||
|
||||
def allow_admin_for?(user)
|
||||
!users_projects.where(:user_id => user.id, :project_access => [PROJECT_RWA]).empty? || owner_id == user.id
|
||||
end
|
||||
|
||||
def root_ref
|
||||
default_branch || "master"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue