mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-09 06:24:04 +08:00
init project
This commit is contained in:
28
app/controllers/weapps/subjects_controller.rb
Normal file
28
app/controllers/weapps/subjects_controller.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
Reference in New Issue
Block a user