Sha256: 6be240296b71cd1273e05652a286f582874a35cee914f07d2c14cccad78ea045

Contents?: true

Size: 1.86 KB

Versions: 11

Compression:

Stored size: 1.86 KB

Contents

class IshManager::Ability
  include ::CanCan::Ability

  def initialize user

    #
    # signed in user
    #
    unless user.blank?
      
      #
      # only sudoer... total power
      #
      if user.profile && user.profile.sudoer?
        can :manage, :all
      end

      can [ :home ], ::IshManager::Ability
      
      can [ :friends_index, :friends_new ], ::IshModels::UserProfile

      #
      # role admin, manager
      #
      if user.profile && [ :admin, :manager ].include?( user.profile.role_name )    

        can [ :create_newsitem, :show, :new_feature, :create_feature ], ::City
        can [ :manage ], ::CoTailors

        can [ :new ], ::Feature

        can [ :index ], ::Gallery
        
        can [ :cities_index, :home, :sites_index, :venues_index ], ::Manager

        can [ :new ], Newsitem

        can [ :new, :create ], Report

        can [ :show, :edit, :update, :create_newsitem, :new_feature, :create_feature, :newsitems_index ], ::Site do |site|
          !site.is_private && !site.is_trash
        end
        can [ :manage ], Ish::StockWatch

        # can [ :new_feature, :create_feature ], ::Tag

      end

      #
      # role guy (and manager)
      #
      if user.profile && [ :manager, :guy ].include?( user.profile.role_name )

        can [ :index, :new, :create ], ::Gallery
        can [ :show, :edit, :update, :create_photo ], ::Gallery do |gallery|
          gallery.user_profile == user.profile
        end
        can [ :show ], ::Gallery do |gallery|
          gallery.shared_profiles.include? user.profile
        end

        can [ :index ], ::Report

        can [ :index ], ::Video
        
      end

    end
    #
    # anonymous user
    #
    user ||= ::User.new
    
    can [ :show ], ::Gallery do |gallery|
      gallery.is_public
    end

    can [ :show ], ::Report do |report|
      report.is_public
    end
    
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ish_manager-0.1.8.201 app/models/ish_manager/ability.rb
ish_manager-0.1.8.200 app/models/ish_manager/ability.rb
ish_manager-0.1.8.199 app/models/ish_manager/ability.rb
ish_manager-0.1.8.198 app/models/ish_manager/ability.rb
ish_manager-0.1.8.197 app/models/ish_manager/ability.rb
ish_manager-0.1.8.196 app/models/ish_manager/ability.rb
ish_manager-0.1.8.195 app/models/ish_manager/ability.rb
ish_manager-0.1.8.194 app/models/ish_manager/ability.rb
ish_manager-0.1.8.193 app/models/ish_manager/ability.rb
ish_manager-0.1.8.192 app/models/ish_manager/ability.rb
ish_manager-0.1.8.188 app/models/ish_manager/ability.rb