diff --git a/app/services/search_service.rb b/app/services/search_service.rb index a45875e07..72cd49c14 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -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 diff --git a/app/services/subject_search_service.rb b/app/services/subject_search_service.rb index 9c2776beb..dc5b069a5 100644 --- a/app/services/subject_search_service.rb +++ b/app/services/subject_search_service.rb @@ -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 diff --git a/app/services/users/subject_service.rb b/app/services/users/subject_service.rb index 53ff3f4b9..d0b995c8e 100644 --- a/app/services/users/subject_service.rb +++ b/app/services/users/subject_service.rb @@ -70,12 +70,21 @@ class Users::SubjectService end def manage_subject_status_filter(relations) - status = case params[:status] - when 'editing' then 0 - when 'applying' then 1 - when 'published' then 2 - end - relations = relations.where(status: status) if status + if params[:status] == "publiced" + relations = relations.where(public: 2) + elsif params[:status] == "applying" + relations = relations.where(public: 1) + else + status = case params[:status] + when 'editing' then + 0 + when 'applying' then + 1 + when 'published' then + 2 + end + relations = relations.where(status: status) if status + end relations end