| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- class Ability
- include CanCan::Ability
- def initialize(user)
- # Define abilities for the passed in user here. For example:
- #
- # user ||= User.new # guest user (not logged in)
- # if user.admin?
- # can :manage, :all
- # else
- # can :read, :all
- # end
- if user
- can :dashboard # allow access to dashboard
- can :access, :rails_admin # only allow admin users to access Rails Admin
- cannot :history, :all
- cannot :import, :all
- cannot :export, :all
- cannot :destroy, :all
- if user.email == AdminUser::SUPER_ADMIN
- can :manage, :all
- can :import, :all
- # can :export, :all
- # can :read, :all
- # can :destroy, :all
- # can :create, :all
- # can :update, :all
- else
- user.permissions.each do |permission|
- eval "can :#{permission.can}, #{permission.model}"
- end
-
- can :update, AdminUser, :id => user.id
- can :read, AdminUser, :id => user.id
- cannot :history, :all
- # cannot :destroy, ChannelQrcode
- # cannot :refund_at_once, Project
- # cannot :destroy, ["ProductAttr", "ProductAttrKey", "ProductAttrValue"]
- # cannot :delete, ["ProductAttr", "ProductAttrKey", "ProductAttrValue"]
- # cannot :export, ["ProductAttr", "ProductAttrKey", "ProductAttrValue"]
- end
- #cannot :destroy, DianshiOrder
- # cannot :new, DianbiOrder
- # cannot :new, VipOrder
- # cannot :new, DianshiOrder
- # cannot :update, User
- # cannot :generate_analyze_report_record, AnalyzeReport
- # can :generate_analyze_report_record, AnalyzeReport, :remark => "当前汇总"
- end
- #
- # The first argument to `can` is the action you are giving the user
- # permission to do.
- # If you pass :manage it will apply to every action. Other common actions
- # here are :read, :create, :update and :destroy.
- #
- # The second argument is the resource the user can perform the action on.
- # If you pass :all it will apply to every resource. Otherwise pass a Ruby
- # class of the resource.
- #
- # The third argument is an optional hash of conditions to further filter the
- # objects.
- # For example, here the user can only update published articles.
- #
- # can :update, Article, :published => true
- #
- # See the wiki for details:
- # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
- end
- end
|