Module: ArtfullyOse::CommonAbilities
- Included in:
- Ability
- Defined in:
- lib/artfully_ose/common_abilities.rb
Instance Method Summary collapse
- #default_abilities_for(user) ⇒ Object
- #household_abilities_for(user) ⇒ Object
- #import_ablilities_for(user) ⇒ Object
- #order_ablilities_for(user) ⇒ Object
- #paid_ticketing_abilities_for(user) ⇒ Object
- #person_abilities_for(user) ⇒ Object
- #ticketing_abilities_for(user) ⇒ Object
Instance Method Details
#default_abilities_for(user) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/artfully_ose/common_abilities.rb', line 9 def default_abilities_for(user) cannot [ :edit, :destroy ], Show, :live? => true can :manage, Organization do |organization| user.current_organization.can?( :manage, organization ) && (user == organization.owner) end can :view, Organization do |organization| user.current_organization.can?( :view, organization ) end can :view, Statement do |statement| user.is_in_organization? end can :manage, Search do |search| search.organization == user.current_organization end end |
#household_abilities_for(user) ⇒ Object
80 81 82 83 84 |
# File 'lib/artfully_ose/common_abilities.rb', line 80 def household_abilities_for(user) can :manage, Household do |household| (user.current_organization.can? :manage, household) end end |
#import_ablilities_for(user) ⇒ Object
3 4 5 6 7 |
# File 'lib/artfully_ose/common_abilities.rb', line 3 def import_ablilities_for(user) can :manage, Import do |chart| user.is_in_organization? end end |
#order_ablilities_for(user) ⇒ Object
64 65 66 67 68 |
# File 'lib/artfully_ose/common_abilities.rb', line 64 def order_ablilities_for(user) can :manage, Order do |order| user.current_organization.can? :manage, order end end |
#paid_ticketing_abilities_for(user) ⇒ Object
60 61 62 |
# File 'lib/artfully_ose/common_abilities.rb', line 60 def paid_ticketing_abilities_for(user) #Nothing here for now end |
#person_abilities_for(user) ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/artfully_ose/common_abilities.rb', line 70 def person_abilities_for(user) can :manage, Person do |person| user.current_organization.can? :manage, person end can :manage, Segment do |segment| user.current_organization.can?(:manage, segment) end end |
#ticketing_abilities_for(user) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/artfully_ose/common_abilities.rb', line 29 def ticketing_abilities_for(user) can [:manage, :bulk_edit ], Ticket do |ticket| user.current_organization.can? :manage, ticket end #This is the ability that the controller uses to authorize creating/editing an event can :manage, Event do |event| user.current_organization.can? :manage, event end can :new, Event do |event| user.is_in_organization? end can :create, :paid_events do user.current_organization.can? :access, :paid_ticketing end can :create_tickets, Array do |sections| sections.select {|s| s.price.to_i > 0}.empty? || (user.current_organization.can? :access, :paid_ticketing) end can [ :manage, :show, :hide, :duplicate ], Show do |show| user.current_organization.can?(:manage, show) end can :manage, Chart do |chart| user.current_organization.can? :manage, chart end end |