init commit
This commit is contained in:
parent
93efff9452
commit
9ba1224867
307 changed files with 11053 additions and 0 deletions
34
app/models/ability.rb
Normal file
34
app/models/ability.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
class Ability
|
||||
def self.allowed(object, subject)
|
||||
case subject.class.name
|
||||
when "Project" then project_abilities(object, subject)
|
||||
else []
|
||||
end
|
||||
end
|
||||
|
||||
def self.project_abilities(user, project)
|
||||
rules = []
|
||||
|
||||
rules << [
|
||||
:read_project,
|
||||
:read_issue,
|
||||
:read_team_member,
|
||||
:read_note
|
||||
] if project.readers.include?(user)
|
||||
|
||||
rules << [
|
||||
:write_project,
|
||||
:write_issue,
|
||||
:write_note
|
||||
] if project.writers.include?(user)
|
||||
|
||||
rules << [
|
||||
:admin_project,
|
||||
:admin_issue,
|
||||
:admin_team_member,
|
||||
:admin_note
|
||||
] if project.admins.include?(user)
|
||||
|
||||
rules.flatten
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue