Sha256: 8248755ef4d0503bade20ff1936e2071512194b3b6882593a0535c263c1dde34
Contents?: true
Size: 1.9 KB
Versions: 8
Compression:
Stored size: 1.9 KB
Contents
module Thredded class Ability include ::CanCan::Ability def initialize(user) user ||= Thredded::NullUser.new user_details = Thredded::UserDetail.where(user_id: user.id).first can :manage, :all if user_details.try(:superadmin?) can :read, Thredded::Messageboard do |messageboard| Thredded::MessageboardUserPermissions.new(messageboard, user).readable? end can :manage, Thredded::Topic do |topic| Thredded::TopicUserPermissions.new(topic, user, user_details).manageable? end can :read, Thredded::Topic do |topic| Thredded::TopicUserPermissions.new(topic, user, user_details).readable? end can :create, Thredded::Topic do |topic| Thredded::TopicUserPermissions.new(topic, user, user_details).creatable? end cannot :manage, Thredded::PrivateTopic can :list, Thredded::PrivateTopic do |private_topic| Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).listable? end can :manage, Thredded::PrivateTopic do |private_topic| Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).manageable? end can :create, Thredded::PrivateTopic do |private_topic| Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).creatable? end can :read, Thredded::PrivateTopic do |private_topic| Thredded::PrivateTopicUserPermissions.new(private_topic, user, user_details).readable? end can :edit, Thredded::Post do |post| Thredded::PostUserPermissions.new(post, user, user_details).editable? end can :manage, Thredded::Post do |post| Thredded::PostUserPermissions.new(post, user, user_details).manageable? end can :create, Thredded::Post do |post| Thredded::PostUserPermissions.new(post, user, user_details).creatable? end end end end
Version data entries
8 entries across 8 versions & 1 rubygems