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.
46 lines
1.0 KiB
46 lines
1.0 KiB
class Cooperative::LaboratoryShixunsController < Cooperative::BaseController
|
|
before_action :check_shixun_ownership!, only: [:edit, :update]
|
|
|
|
helper_method :current_laboratory_shixun
|
|
|
|
def index
|
|
laboratory_shixuns = Admins::LaboratoryShixunQuery.call(current_laboratory, params)
|
|
@laboratory_shixuns = paginate laboratory_shixuns.includes(shixun: %i[tag_repertoires user])
|
|
end
|
|
|
|
def edit
|
|
end
|
|
|
|
def update
|
|
|
|
end
|
|
|
|
def destroy
|
|
return render_js_error('不能删除自建实训', type: :notify) if current_laboratory_shixun.ownership?
|
|
current_laboratory_shixun.destroy!
|
|
|
|
render_delete_success
|
|
end
|
|
|
|
def homepage
|
|
current_laboratory_shixun.update!(homepage: true)
|
|
render_ok
|
|
end
|
|
|
|
def cancel_homepage
|
|
current_laboratory_shixun.update!(homepage: false)
|
|
render_ok
|
|
end
|
|
|
|
private
|
|
|
|
def current_laboratory_shixun
|
|
@_current_laboratory_shixun ||= current_laboratory.laboratory_shixuns.find(params[:id])
|
|
end
|
|
|
|
def check_shixun_ownership!
|
|
return if current_laboratory_shixun.ownership?
|
|
|
|
render_forbidden
|
|
end
|
|
end |