ability.rb revision 17e3eda463c5fe407b4498c996c7fd0474e34e41
# Define abilities for the passed in user here.
if user.admin?
can { true }
elsif user.id
# Repositories
can [:create], Repository
can :show, Repository do |subject|
else
true
end
end
can [:write], Repository do |subject|
end
can [:update, :destroy, :permissions], Repository do |subject|
end
# Ontology
end
# Logics
end
can [:destroy, :permissions], Logic do |subject|
end
# LogicMappings
can [:update], LogicMapping do |subject|
end
can [:destroy, :permissions], LogicMapping do |subject|
end
can [:create], LogicMapping
# LanguageMappings
can [:update], LanguageMapping do |subject|
end
can [:destroy, :permissions], LanguageMapping do |subject|
end
can [:create], LanguageMapping
# LogicAdjoints
can [:update], LogicAdjoint do |subject|
end
can [:destroy, :permissions], LogicAdjoint do |subject|
end
can [:create], LogicAdjoint
# LanguageAdjoints
can [:update], LanguageAdjoint do |subject|
end
can [:destroy, :permissions], LanguageAdjoint do |subject|
end
can [:create], LanguageAdjoint
# Languages
end
can [:destroy, :permissions], Language do |subject|
end
# Serializations
can [:create, :destroy, :update], Serialization
# Team permissions
end
# Comments
subject.user == user || subject.commentable.permission?(:owner, user)
end
# TODO tests written?
subject.user == user || subject.metadatable.permission?(:editor, user)
end
else
can :show, Repository do |subject|
end
end
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
end
end