Sha256: b35527ac152576ba67eb64fbc3e1ea9b13da9e660ddb2d5e8551671af3b0a1d1

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

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

  def initialize user

    #
    # signed in user
    #
    unless user.blank?

      can [ :index, :new, :create ], ::Gallery
      can [ :show, :edit, :update, :create_photo ], ::Gallery do |gallery|
        gallery.user_profile == user.profile
      end
      
      can [ :home ], ::IshManager::Ability
      
      can [ :friends_index, :friends_new ], ::IshModels::UserProfile

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

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

        can [ :new ], ::Feature

        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 ], ::Site do |site|
          !site.is_private && !site.is_trash
        end
        can [ :manage ], Ish::StockWatch

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

      end

      if user.profile && user.profile.sudoer?
        can :manage, :all # @TODO: this is important
        can [ :manage ], ::Gallery
        can [ :manage ], ::Gallery2
        can [ :home ], ::Manager
        can :destroy, ::Photo
      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

8 entries across 8 versions & 1 rubygems

Version Path
ish_manager-0.1.8.79 app/models/ish_manager/ability.rb
ish_manager-0.1.8.78 app/models/ish_manager/ability.rb
ish_manager-0.1.8.77 app/models/ish_manager/ability.rb
ish_manager-0.1.8.76 app/models/ish_manager/ability.rb
ish_manager-0.1.8.75 app/models/ish_manager/ability.rb
ish_manager-0.1.8.74 app/models/ish_manager/ability.rb
ish_manager-0.1.8.73 app/models/ish_manager/ability.rb
ish_manager-0.1.8.72 app/models/ish_manager/ability.rb