用户为创建课程,或没有作为教师的课程时,不显示引入我的课程按钮

This commit is contained in:
z9hang 2014-11-24 14:39:31 +08:00
parent c5fcb9168e
commit feccad8fa5
2 changed files with 13 additions and 2 deletions

View File

@ -54,6 +54,17 @@ module FilesHelper
s.html_safe
end
#判断用户是否拥有课程,需用户在该课程中角色为教师
def has_course? user
result = false
user.courses.each do |course|
if is_course_teacher(user,course)
return true
end
end
result
end
# 判断指定的资源时候符合类型
def isTypeOk(attachment, type, contentType)
result = false

View File

@ -21,7 +21,7 @@
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if User.current.logged? %>
<% if is_course_teacher(User.current,@course) && file.author_id == User.current.id %>
<%= link_to "选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current) %>
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<span id="is_public_<%= file.id %>">
@ -31,7 +31,7 @@
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>
<% else %>
<%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current) %>
<% end %>
<% else %>
<% end %>