Sha256: ab05ea6fc1571cad11c4f70a57a79aed7864d9ac13084a33654579f38f7f69a0

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

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

  def initialize user 

    #
    # signed in user
    #
    unless user.blank?

      # 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 ], IshModels::StockWatch

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

      end

      if user.profile && user.profile.sudoer?
        can :manage, :all # HEREHERE
        can [ :manage ], ::Gallery
        can [ :manage ], ::Gallery2
        can [ :home ], ::Manager
        can :destroy, ::Photo
      end

      can [ :show ], ::Gallery do |gallery|
        gallery.user == user
      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

2 entries across 2 versions & 1 rubygems

Version Path
ish_manager-0.1.8.59 app/models/ish_manager/ability.rb
ish_manager-0.1.8.58 app/models/ish_manager/ability.rb