mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 11:44:02 +00:00
Drop Organization abilities
This commit is contained in:
parent
b9a50ef20d
commit
dc1a6a4363
3 changed files with 4 additions and 23 deletions
|
|
@ -17,7 +17,6 @@ class Ability
|
|||
|
||||
# Abilities for not signed in users (guests)
|
||||
def not_signed_in
|
||||
can [:index, :conferences, :code_of_conduct], Organization
|
||||
can [:index], Conference
|
||||
can [:show], Conference do |conference|
|
||||
conference.splashpage&.public == true
|
||||
|
|
@ -86,7 +85,6 @@ class Ability
|
|||
end
|
||||
end
|
||||
|
||||
can :index, Organization
|
||||
can :index, Ticket
|
||||
can :manage, TicketPurchase, user_id: user.id
|
||||
can [:new, :create], Payment, user_id: user.id
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class AdminAbility
|
|||
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
|
||||
end
|
||||
|
||||
can [:index, :admins], Organization
|
||||
can :index, Ticket
|
||||
can :manage, TicketPurchase, user_id: user.id
|
||||
can [:new, :create], Payment, user_id: user.id
|
||||
|
|
@ -81,7 +80,6 @@ class AdminAbility
|
|||
|
||||
# Abilities for signed in users with roles
|
||||
def signed_in_with_roles(user)
|
||||
signed_in_with_organization_admin_role(user) if user.has_cached_role? :organization_admin, :any
|
||||
signed_in_with_organizer_role(user) if user.has_cached_role? :organizer, :any
|
||||
signed_in_with_cfp_role(user) if user.has_cached_role? :cfp, :any
|
||||
signed_in_with_info_desk_role(user) if user.has_cached_role? :info_desk, :any
|
||||
|
|
@ -90,22 +88,9 @@ class AdminAbility
|
|||
common_abilities_for_roles(user)
|
||||
end
|
||||
|
||||
def signed_in_with_organization_admin_role(user)
|
||||
org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id)
|
||||
conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id)
|
||||
|
||||
can [:read, :update, :destroy, :assign_org_admins, :unassign_org_admins, :admins], Organization, id: org_ids_for_organization_admin
|
||||
can :new, Conference
|
||||
can :manage, Conference, organization_id: org_ids_for_organization_admin
|
||||
can [:index, :show], Role
|
||||
|
||||
signed_in_with_organizer_role(user, conf_ids_for_organization_admin)
|
||||
end
|
||||
|
||||
def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = [])
|
||||
# ids of all the conferences for which the user has the 'organizer' role and
|
||||
# conferences that belong to organizations for which user is 'organization_admin'
|
||||
conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
|
||||
def signed_in_with_organizer_role(user)
|
||||
# ids of all the conferences for which the user has the 'organizer' role
|
||||
conf_ids = Conference.with_role(:organizer, user).pluck(:id)
|
||||
# ids of all the tracks that belong to the programs of the above conferences
|
||||
track_ids = Track.joins(:program).where('programs.conference_id IN (?)', conf_ids).pluck(:id)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue