diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index dd8dc84c4..cbbf36ea8 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -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] diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index f023e8413..86ec79e67 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -10,12 +10,12 @@
- 课件 |  - 软件 |  - 媒体 |  - 代码 |  - 论文 |  - 其他 + 课件 |  + 软件 |  + 媒体 |  + 代码 |  + 论文 |  + 其他