diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 89a96a836..25bb31cbb 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -351,8 +351,13 @@ class AttachmentsController < ApplicationController 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 + if @message && @message == "" + @message += l(:label_course_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + else + @message += "
" + l(:label_course_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + end end attach_copied_obj = file.copy attach_copied_obj.tag_list.add(file.tag_list) # tag关联 diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index f631f56ff..52002b028 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -69,7 +69,7 @@ module AttachmentsHelper 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 + if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from return true end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index d51606d90..c3a6a7b3e 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -54,11 +54,11 @@ module FilesHelper s.html_safe end - #判断用户是否拥有课程,需用户在该课程中角色为教师 + #判断用户是否拥有课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期 def has_course? user result = false user.courses.each do |course| - if is_course_teacher(user,course) + if is_course_teacher(User.current,course) && course_in_current_or_next_term(course) return true end end @@ -86,7 +86,7 @@ module FilesHelper def visable_attachemnts attachments result = [] attachments.each do |attachment| - if attachment.is_public? || attachment.author_id == User.current.id + if attachment.is_public? || (attachment.container_type == "Course" && attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id result << attachment end end diff --git a/app/views/attachments/add_exist_file_to_courses.js.erb b/app/views/attachments/add_exist_file_to_courses.js.erb index 761111cec..eec1e255a 100644 --- a/app/views/attachments/add_exist_file_to_courses.js.erb +++ b/app/views/attachments/add_exist_file_to_courses.js.erb @@ -1,7 +1,7 @@ <% if !@save_flag && @save_message %> $("#error_show").html("<%= @save_message.join(', ') %>"); -<% elsif @message || @message != "" %> - $("#error_show").html("<%= @message %>"); +<% elsif @message && @message != "" %> + $("#error_show").html("<%= @message.html_safe %>"); <% else %> closeModal(); <% end %>