课程资源上传允许多选tag
This commit is contained in:
parent
2c5cd1a4b3
commit
e7d53f5e16
|
@ -374,30 +374,29 @@ class FilesController < ApplicationController
|
|||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||
Mailer.run.attachments_added(attachments[:files])
|
||||
end
|
||||
|
||||
if params[:course_attachment_type] && params[:course_attachment_type] != "5"
|
||||
case params[:course_attachment_type]
|
||||
when "1"
|
||||
tag_name = l(:label_courseware)
|
||||
when "2"
|
||||
tag_name = l(:label_software)
|
||||
when "3"
|
||||
tag_name = l(:label_media)
|
||||
when "4"
|
||||
tag_name = l(:label_code)
|
||||
when "6"
|
||||
tag_name = "论文"
|
||||
else
|
||||
tag_name = ""
|
||||
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
|
||||
params[:course_attachment_type].each do |type|
|
||||
tag_name = get_tag_name_by_type_number type
|
||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||
attachments[:files].each do |attachment|
|
||||
attachment.tag_list.add(tag_name)
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
end
|
||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||
attachments[:files].each do |attachment|
|
||||
attachment.tag_list.add(tag_name)
|
||||
attachment.save
|
||||
else
|
||||
if params[:course_attachment_type] && params[:course_attachment_type] != "5"
|
||||
tag_name = get_tag_name_by_type_number params[:course_attachment_type]
|
||||
if !attachments.empty? && attachments[:files] && tag_name != ""
|
||||
attachments[:files].each do |attachment|
|
||||
attachment.tag_list.add(tag_name)
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# TODO: 临时用 nyan
|
||||
sort_init 'created_on', 'desc'
|
||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||
|
@ -424,6 +423,23 @@ class FilesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def get_tag_name_by_type_number type
|
||||
case type
|
||||
when "1"
|
||||
tag_name = l(:label_courseware)
|
||||
when "2"
|
||||
tag_name = l(:label_software)
|
||||
when "3"
|
||||
tag_name = l(:label_media)
|
||||
when "4"
|
||||
tag_name = l(:label_code)
|
||||
when "6"
|
||||
tag_name = "论文"
|
||||
else
|
||||
tag_name = ""
|
||||
end
|
||||
end
|
||||
|
||||
def tag_saveEx
|
||||
@tags = params[:tag_name][:name]
|
||||
@obj_id = params[:object_id]
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
<input type="hidden" name="in_course_toolbar" value="Y">
|
||||
<!--<p class="c_grey fr mt10 mr5">-->
|
||||
<div class="c_dark">
|
||||
<input name="course_attachment_type" type="radio" value="1" checked class="c_dark" >课件</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type" type="radio" value="2" class="c_dblue">软件</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type" type="radio" value="3" class="c_dblue">媒体</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type" type="radio" value="4" class="c_dblue">代码</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type" type="radio" value="6" class="c_dblue">论文</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type" type="radio" value="5" class="c_dblue">其他</input></a>
|
||||
<input name="course_attachment_type[]" type="checkbox" value="1" checked class="c_dark" >课件</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type[]" type="checkbox" value="2" class="c_dblue">软件</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type[]" type="checkbox" value="3" class="c_dblue">媒体</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type[]" type="checkbox" value="4" class="c_dblue">代码</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type[]" type="checkbox" value="6" class="c_dblue">论文</input> <span class="c_grey">|</span>
|
||||
<input name="course_attachment_type[]" type="checkbox" value="5" class="c_dblue">其他</input></a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue