引用课程中已有的资源时提示资源已存在
This commit is contained in:
parent
8a3669ba3b
commit
f267a3daf8
|
@ -25,6 +25,7 @@ class AttachmentsController < ApplicationController
|
|||
#before_filter :login_without_softapplication, only: [:download]
|
||||
accept_api_auth :show, :download, :upload
|
||||
require 'iconv'
|
||||
include AttachmentsHelper
|
||||
|
||||
|
||||
def show
|
||||
|
@ -346,8 +347,13 @@ class AttachmentsController < ApplicationController
|
|||
def add_exist_file_to_courses
|
||||
file = Attachment.find(params[:file_id])
|
||||
courses = params[:courses][:course]
|
||||
@message = ""
|
||||
courses.each do |course|
|
||||
c = Course.find(course);
|
||||
if course_contains_attachment?(c,file)
|
||||
@message += l(:label_course_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed)
|
||||
next
|
||||
end
|
||||
attach_copied_obj = file.copy
|
||||
attach_copied_obj.tag_list.add(file.tag_list) # tag关联
|
||||
attach_copied_obj.container = c
|
||||
|
|
|
@ -67,6 +67,15 @@ module AttachmentsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def course_contains_attachment? course,attachment
|
||||
course.attachments.each do |att|
|
||||
if att.id == attachment.id || att.copy_from == attachment.copy_from || att.copy_from = attachment.id || att.id == attachment.copy_from
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deletable? container, user=User.current
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<% if !@save_flag%>
|
||||
<% if !@save_flag && @save_message %>
|
||||
$("#error_show").html("<%= @save_message.join(', ') %>");
|
||||
<% elsif @message || @message != "" %>
|
||||
$("#error_show").html("<%= @message %>");
|
||||
<% else %>
|
||||
closeModal();
|
||||
<% end %>
|
||||
|
|
|
@ -2205,3 +2205,7 @@ zh:
|
|||
label_my_score: 我的评分
|
||||
field_open_anonymous_evaluation: 是否使用匿评
|
||||
label_course_empty_select: 尚未选择课程!
|
||||
label_course_prompt: 课程:
|
||||
label_contain_resource: 已包含资源:
|
||||
label_quote_resource_failed: ",此资源引用失败! "
|
||||
|
||||
|
|
Loading…
Reference in New Issue