From 9898e1650b0ed31358b2e9e3ec6d1427b8a96fdc Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 27 Nov 2014 10:18:41 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AD=A6=E7=94=9F=E7=9C=8B=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E7=A7=81=E6=9C=89=E8=B5=84=E6=BA=90bug=E3=80=822?= =?UTF-8?q?=E3=80=81=E5=BC=95=E7=94=A8=E8=B5=84=E6=BA=90=E5=BC=B9=E6=A1=86?= =?UTF-8?q?=E4=B8=AD=E6=97=A0=E8=AF=BE=E7=A8=8B=E5=8F=AF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=BC=95=E5=85=A5=E6=88=91?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E7=A8=8B=E6=8C=89=E9=92=AE=E3=80=823?= =?UTF-8?q?=E3=80=81=E5=BC=95=E7=94=A8=E8=B5=84=E6=BA=90=E6=97=B6=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 9 +++++++-- app/helpers/attachments_helper.rb | 2 +- app/helpers/files_helper.rb | 6 +++--- app/views/attachments/add_exist_file_to_courses.js.erb | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) 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 %>