Various ability fixes and clarifications for guests/users
This commit is contained in:
parent
9c968ad3e2
commit
b6abe96279
1 changed files with 14 additions and 20 deletions
|
|
@ -61,7 +61,6 @@ class Ability
|
||||||
|
|
||||||
signed_in(user) # Inherit abilities from signed user
|
signed_in(user) # Inherit abilities from signed user
|
||||||
# User with role
|
# User with role
|
||||||
can :manage, User if user.is_admin # ??? || (user.has_role? :organizer, :any)
|
|
||||||
can [:new, :create], Conference if user.is_admin || (user.has_role? :organizer, :any)
|
can [:new, :create], Conference if user.is_admin || (user.has_role? :organizer, :any)
|
||||||
can [:index, :show, :gallery_photos], Conference
|
can [:index, :show, :gallery_photos], Conference
|
||||||
can :manage, Conference, id: conf_ids_for_organizer
|
can :manage, Conference, id: conf_ids_for_organizer
|
||||||
|
|
@ -100,45 +99,40 @@ class Ability
|
||||||
can :manage, CallForPaper, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
can :manage, CallForPaper, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
can :manage, Venue, conference_id: conf_ids_for_organizer
|
can :manage, Venue, conference_id: conf_ids_for_organizer
|
||||||
can :index, Venue, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
can :index, Venue, conference_id: conf_ids_for_organizer + conf_ids_for_cfp
|
||||||
|
can :manage, :all if user.is_admin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Abilities for everyone, even guests (not logged in users)
|
||||||
def guest
|
def guest
|
||||||
## Abilities for everyone, even guests (not logged in users)
|
# can view conferences
|
||||||
can [:index, :show, :schedule], Conference do |conference|
|
can [:index, :show, :schedule], Conference
|
||||||
conference.splashpage && conference.splashpage.public == true
|
# can view confirmed Events
|
||||||
end
|
|
||||||
|
|
||||||
# see commercials too
|
|
||||||
|
|
||||||
can :show, Event do |event|
|
can :show, Event do |event|
|
||||||
event.state == 'confirmed'
|
event.state == 'confirmed'
|
||||||
end
|
end
|
||||||
|
# can view Commercials of confirmed Events
|
||||||
can :index, :schedule # show?
|
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
||||||
|
# can view others
|
||||||
can :show, User
|
can :show, User
|
||||||
end
|
end
|
||||||
|
|
||||||
def signed_in(user)
|
def signed_in(user)
|
||||||
guest # Inherits abilities of guest
|
guest # Inherits abilities of guest
|
||||||
|
|
||||||
# Can subscribe, unsubscribe to a conference
|
# subscribe, unsubscribe to a Conference
|
||||||
can [:create, :destroy], Subscription, user_id: user.id
|
can [:create, :destroy], Subscription, user_id: user.id
|
||||||
|
|
||||||
# Conference Registration
|
# can manage their own Registration
|
||||||
can :manage, Registration, user_id: user.id
|
can :manage, Registration, user_id: user.id
|
||||||
|
|
||||||
|
# can manage their own User
|
||||||
can :manage, User, id: user.id
|
can :manage, User, id: user.id
|
||||||
can :show, User
|
|
||||||
|
|
||||||
## Proposals
|
# can manage their own Event
|
||||||
# Users can manage their own proposals
|
|
||||||
can :manage, Event, id: user.events.pluck(:id)
|
can :manage, Event, id: user.events.pluck(:id)
|
||||||
|
# can submit Events for conferences that are not over yet
|
||||||
# Submit proposals only for conferences that are not over yet
|
|
||||||
can :create, Event, conference_id: Conference.where('end_date >= ?', Date.today).pluck(:id)
|
can :create, Event, conference_id: Conference.where('end_date >= ?', Date.today).pluck(:id)
|
||||||
# Users can manage their own commercials
|
# can manage their own commercials
|
||||||
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
|
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
|
||||||
# View commercials of confirmed events
|
|
||||||
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue