parent
953c621d71
commit
bb2f8c67ac
@ -1,2 +0,0 @@
|
||||
class GtaskBanksController < ApplicationController
|
||||
end
|
@ -0,0 +1,32 @@
|
||||
class TaskBanksController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :find_bank
|
||||
before_action :bank_admin, only: [:update]
|
||||
|
||||
def show
|
||||
@bank_attachments = @bank.attachments
|
||||
end
|
||||
|
||||
def update
|
||||
@bank.update_attributes(gtask_bank_params)
|
||||
Attachment.associate_container(params[:attachment_ids], @graduation_topic.id, @graduation_topic.class) if params[:attachment_ids]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_bank
|
||||
@bank = GtaskBank.find_by!(id: params[:id])
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
|
||||
end
|
||||
|
||||
def bank_admin
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
|
||||
end
|
||||
|
||||
def gtask_bank_params
|
||||
tip_exception("name参数不能为空") if params[:gtopic_bank][:name].blank?
|
||||
tip_exception("description参数不能为空") if params[:gtopic_bank][:description].blank?
|
||||
params.require(:gtopic_bank).permit(:name, :topic_type, :topic_source, :topic_property_first, :description,
|
||||
:topic_property_second, :source_unit, :topic_repeat, :province, :city)
|
||||
end
|
||||
end
|
@ -0,0 +1,14 @@
|
||||
json.(@bank, :id, :name, :description, :task_type, :is_public)
|
||||
# 附件
|
||||
json.attachments @bank_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
||||
|
||||
# 分组要求
|
||||
if @bank.task_type == 2
|
||||
json.group_info do
|
||||
json.max_number @bank.max_num
|
||||
json.min_number @bank.min_num
|
||||
json.base_on_project @bank.base_on_project
|
||||
end
|
||||
end
|
Loading…
Reference in new issue