Skip to content
Snippets Groups Projects
Commit b06451f4 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

refact

parent ef69ba6f
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ class Ability
end
def initialize(user)
@user = user ||= User.new # guest user (not logged in)
@user = user ||=@ User.new # guest user (not logged in)
end
protected
......@@ -16,16 +16,4 @@ class Ability
def managed_websites_ids
@managed_websites_ids ||= @user.websites_to_manage.pluck(:communication_website_id)
end
def managed_pages_ids
@managed_pages_ids ||= Communication::Website::Page.where(communication_website_id: managed_websites_ids).pluck(:id)
end
def managed_posts_ids
@managed_posts_ids ||= Communication::Website::Post.where(communication_website_id: managed_websites_ids).pluck(:id)
end
def managed_programs_ids
@managed_programs_ids ||= user.programs_to_manage.pluck(:education_program_id)
end
end
......@@ -19,4 +19,10 @@ class Ability::ProgramManager < Ability
can :manage, University::Person::Involvement, target_type: "Education::Program", target_id: managed_programs_ids
can :manage, University::Role, target_type: "Education::Program", target_id: managed_programs_ids
end
protected
def managed_programs_ids
@managed_programs_ids ||= @user.programs_to_manage.pluck(:education_program_id)
end
end
\ No newline at end of file
......@@ -25,4 +25,14 @@ class Ability::WebsiteManager < Ability
can :manage, University::Person::Experience, university_id: @user.university_id
can :manage, University::Person::Involvement, university_id: @user.university_id
end
protected
def managed_pages_ids
@managed_pages_ids ||= Communication::Website::Page.where(communication_website_id: managed_websites_ids).pluck(:id)
end
def managed_posts_ids
@managed_posts_ids ||= Communication::Website::Post.where(communication_website_id: managed_websites_ids).pluck(:id)
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment