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.
29 lines
825 B
29 lines
825 B
class Weapps::SubjectsController < Weapps::BaseController
|
|
before_action :require_login, except: [:index, :show]
|
|
before_action :find_subject, except: [:index]
|
|
|
|
# 首页
|
|
def index
|
|
subjects = Weapps::SubjectQuery.call(current_laboratory, params)
|
|
@subject_count = subjects.map(&:id).size
|
|
@subjects = paginate subjects
|
|
end
|
|
|
|
# 详情
|
|
def show
|
|
# 合作团队
|
|
Rails.logger.info("##########subject: #{@subject.id}")
|
|
@members = @subject.subject_members.includes(:user)
|
|
shixuns = @subject.shixuns.published.pluck(:id)
|
|
challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id)
|
|
# 实训路径中的所有实训标签
|
|
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
|
|
end
|
|
|
|
private
|
|
def find_subject
|
|
@subject = Subject.find(params[:id])
|
|
end
|
|
|
|
end
|