毕设选题的题库

dev_aliyun_beta
cxt 6 years ago
parent 44e7a4da00
commit e82ef836d5

@ -0,0 +1,32 @@
class GtopicBanksController < 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(gtopic_bank_params)
Attachment.associate_container(params[:attachment_ids], @graduation_topic.id, @graduation_topic.class) if params[:attachment_ids]
end
private
def find_bank
@bank = GtopicBank.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 gtopic_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,6 @@
json.(@bank, :id, :name, :description, :is_public, :topic_type, :topic_source, :topic_property_first, :topic_property_second,
:source_unit, :topic_repeat, :province, :city)
json.attachment_list @bank_attachments do |attachment|
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
end

@ -641,6 +641,8 @@ Rails.application.routes.draw do
end
end
resources :gtopic_banks
resources :attachments
resources :schools do

Loading…
Cancel
Save