socialforge/app/views/files/_course_list.html.erb

91 lines
6.2 KiB
Plaintext
Raw Normal View History

2015-12-28 16:19:30 +08:00
<% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
<% curse_attachments.each do |file| %>
<% 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_time(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%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= 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
<ul>
<li class="homepagePostSettingIcon">
2015-12-31 12:27:31 +08:00
<% if User.current.logged? %>
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
<ul class="homepagePostSettiongText">
2015-12-31 11:12:00 +08:00
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}')") %></li>
2015-12-30 17:27:44 +08:00
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
2015-12-28 16:19:30 +08:00
<% if @course.is_public? %>
<li>
<span id="is_public_<%= file.id %>">
2015-12-28 16:19:30 +08:00
<%= 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>
2015-12-28 16:19:30 +08:00
<%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" && file.destroyable %>
</li>
2015-12-31 12:27:31 +08:00
</ul>
2015-10-19 17:01:47 +08:00
2015-12-31 12:27:31 +08:00
<% end %>
<%else%>
<ul class="resourceSendO">
<li><%= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}')") %></li>
</ul>
<% end %>
<% end %>
2015-12-28 16:19:30 +08:00
</li>
</ul>
2015-12-27 23:24:21 +08:00
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
</div>
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% 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' %>
2015-12-31 11:12:00 +08:00
<%=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 => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
2016-01-08 18:03:59 +08:00
<% else %>
2015-12-28 16:19:30 +08:00
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
2016-01-08 18:03:59 +08:00
<%=link_to "点击展开更多", course_files_path(:course_id => course.id, :page => @page), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
2015-12-28 16:19:30 +08:00
<%end%>
<% end%>
2015-12-31 11:12:00 +08:00