mending permissions and test

This commit is contained in:
shlok007 2017-06-13 20:57:55 +05:30
parent b72e64b238
commit aa3df0243e
2 changed files with 19 additions and 13 deletions

View file

@ -29,6 +29,7 @@ class Ability
# Abilities for not signed in users (guests)
def not_signed_in
can [:index], Organization
can [:index], Conference
can [:show], Conference do |conference|
conference.splashpage && conference.splashpage.public == true
@ -168,7 +169,6 @@ class Ability
# conferences that belong to organizations for which user is 'organization_admin'
conf_ids_for_organization_admin_and_organizer = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
can :manage, Resource, conference_id: conf_ids_for_organization_admin_and_organizer
can [:new, :create], Conference if user.has_role?(:organizer, :any)
can :manage, Conference, id: conf_ids_for_organization_admin_and_organizer
can :manage, Splashpage, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Contact, conference_id: conf_ids_for_organization_admin_and_organizer
@ -207,7 +207,10 @@ class Ability
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organization_admin_and_organizer).pluck(:id)).pluck(:id)
# Abilities for Role (Conference resource)
can [:index, :show], Role
can [:index, :show], Role do |role|
role.resource_type == 'Conference'
end
can [:edit, :update, :toggle_user], Role do |role|
role.resource_type == 'Conference' && (conf_ids_for_organization_admin_and_organizer.include? role.resource_id)
end
@ -239,8 +242,9 @@ class Ability
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
# Abilities for Role (Conference resource)
can [:index, :show], Role
can [:index, :show], Role do |role|
role.resource_type == 'Conference'
end
# Can add or remove users from role, when user has that same role for the conference
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
can :toggle_user, Role do |role|
@ -268,8 +272,9 @@ class Ability
end
# Abilities for Role (Conference resource)
can [:index, :show], Role
can [:index, :show], Role do |role|
role.resource_type == 'Conference'
end
# Can add or remove users from role, when user has that same role for the conference
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
can :toggle_user, Role do |role|
@ -287,8 +292,9 @@ class Ability
can :manage, Vday, conference_id: conf_ids_for_volunteers_coordinator
# Abilities for Role (Conference resource)
can [:index, :show], Role
can [:index, :show], Role do |role|
role.resource_type == 'Conference'
end
# Can add or remove users from role, when user has that same role for the conference
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
can :toggle_user, Role do |role|