2015-12-28 16:19:30 +08:00
|
|
|
|
2014-11-21 11:38:53 +08:00
|
|
|
<% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
|
2015-05-20 11:56:34 +08:00
|
|
|
<% curse_attachments.each do |file| %>
|
2015-07-01 10:30:26 +08:00
|
|
|
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
|
2015-12-27 23:24:21 +08:00
|
|
|
<div class="resources mt10"><!--资源库内容开始--->
|
|
|
|
<div class="homepagePostBrief">
|
|
|
|
<div class="homepagePostPortrait">
|
|
|
|
<%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
|
|
|
|
</div>
|
|
|
|
<div class="homepagePostDes">
|
2015-12-28 16:19:30 +08:00
|
|
|
<div class="homepagePostTitle break_word mt-4">
|
2015-12-27 23:24:21 +08:00
|
|
|
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
|
|
|
download_named_attachment_path(file.id, file.filename),
|
|
|
|
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %>
|
|
|
|
<%= file_preview_eye(file, class: 'preview') %>
|
2015-12-28 16:19:30 +08:00
|
|
|
<span id="image_private_<%= file.id%>">
|
|
|
|
<% if file.is_public? == false%>
|
|
|
|
<span class="img_private ml5">私有</span>
|
|
|
|
<%end %>
|
|
|
|
</span>
|
2015-12-27 23:24:21 +08:00
|
|
|
</div>
|
|
|
|
<div class="mt5">
|
|
|
|
<span class="fontGrey2 mr15 fl">上传时间:<%= format_date(file.created_on)%></span>
|
2015-12-28 16:19:30 +08:00
|
|
|
<% if file.tag_list.length > 0%>
|
|
|
|
<span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span>
|
|
|
|
<% end %>
|
2015-12-27 23:24:21 +08:00
|
|
|
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
|
|
|
|
<p class="fl ml15 fontGrey2">下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
|
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
<div class="tag_h">
|
|
|
|
<!-- container_type = 1 代表是课程里的资源 -->
|
|
|
|
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
|
|
|
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
|
|
|
</div>
|
|
|
|
<div class="homepagePostSetting">
|
2015-12-28 16:19:30 +08:00
|
|
|
<% if User.current.logged? %>
|
|
|
|
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
|
|
|
|
<ul>
|
|
|
|
<li class="homepagePostSettingIcon">
|
|
|
|
<ul class="homepagePostSettiongText">
|
|
|
|
|
2014-11-22 13:45:17 +08:00
|
|
|
|
2015-12-28 16:19:30 +08:00
|
|
|
<% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
|
|
|
|
<% if @course.is_public? %>
|
|
|
|
<li>
|
|
|
|
<span id="is_public_<%= file.id %>">
|
|
|
|
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
<%else%>
|
|
|
|
<li>
|
|
|
|
<span id="is_public_<%= file.id %>">
|
|
|
|
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
<%end%>
|
|
|
|
<li>
|
|
|
|
<%= link_to( '删除资源', attachment_path(file),
|
|
|
|
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course"%>
|
2015-10-19 17:01:47 +08:00
|
|
|
|
2015-12-28 16:19:30 +08:00
|
|
|
</li>
|
|
|
|
<% end %>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
2015-12-27 23:24:21 +08:00
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-05-20 11:56:34 +08:00
|
|
|
<% else %>
|
|
|
|
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
|
|
|
|
<% end %>
|
2015-04-03 11:30:48 +08:00
|
|
|
<% end %>
|
2015-12-27 23:24:21 +08:00
|
|
|
|
2015-12-28 16:19:30 +08:00
|
|
|
<% if curse_attachments.count == 10%>
|
|
|
|
<% if params[:action] == 'search' %>
|
|
|
|
<div id="show_more_attachments" class="loadMore mt10 f_grey">展开更多<%=link_to "", search_course_files_path({:course_id => course.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "more_attachments_link",:remote => "true",:class => "none" %></div>
|
|
|
|
<%else%>
|
|
|
|
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
|
|
|
|
<div id="show_more_attachments" class="loadMore mt10 f_grey">展开更多<%=link_to "", course_files_path({:course_id => course.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "more_attachments_link",:remote => "true",:class => "none" %></div>
|
|
|
|
<%end%>
|
|
|
|
<% end%>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$("#show_more_attachments").mouseover(function(){
|
|
|
|
$("#more_attachments_link").click();
|
|
|
|
});
|
|
|
|
</script>
|