实践课程搜索流程

dev_jupyter
daiao 5 years ago
parent 1b285e2b6b
commit 3c206b52e3

@ -41,7 +41,8 @@ class SearchService < ApplicationService
when 'shixun' then
{ where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns)).pluck(:id) } }
when 'subject' then
{ where: { id: Laboratory.current.subjects.pluck(:id) } }
{ where: { id: Laboratory.current.subjects.where(public: 2, status: 2)
.or( Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns).pluck(:id)) } }
when 'course' then
{ where: { id: Laboratory.current.all_courses.pluck(:id) } }
else

@ -17,9 +17,12 @@ class SubjectSearchService < ApplicationService
if type == "mine"
@subjects = @subjects.where(id: User.current.subjects).visible.unhidden
else
@subjects = @subjects.visible.unhidden
if User.current.admin? || User.current.business?
@subjects = @subjects.unhidden
else
@subjects = @subjects.publiced.unhidden.or(@subjects.where(id: User.current.subjects))
end
end
Subject.search(keyword, search_options)
end

Loading…
Cancel
Save