You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
789 B
22 lines
789 B
class Users::SubjectsController < Users::BaseController
|
|
def index
|
|
subjects = Users::SubjectService.new(observed_user, query_params).call
|
|
|
|
## 云上实验室过滤
|
|
if current_laboratory.main_site?
|
|
not_subject_ids = Subject.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}")
|
|
subjects = subjects.where.not(id: not_subject_ids)
|
|
else
|
|
subjects = subjects.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id })
|
|
end
|
|
|
|
@count = subjects.count
|
|
@subjects = paginate(subjects.includes(:user, :repertoire), special: observed_user.is_teacher?)
|
|
end
|
|
|
|
private
|
|
|
|
def query_params
|
|
params.permit(:category, :status, :sort_direction)
|
|
end
|
|
end |