diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb
index 50dd79a08..2e07421f8 100644
--- a/app/helpers/attachments_helper.rb
+++ b/app/helpers/attachments_helper.rb
@@ -34,6 +34,16 @@ module AttachmentsHelper
:locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
end
end
+
+ def link_to_attachments_course(container, options = {})
+ options.assert_valid_keys(:author, :thumbnails)
+
+ if container.attachments.any?
+ options = {:deletable => container.attachments_deletable?, :author => true}.merge(options)
+ render :partial => 'attachments/course_file_links',
+ :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
+ end
+ end
def attach_delete(project)
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
diff --git a/app/views/attachments/_course_file_links.html.erb b/app/views/attachments/_course_file_links.html.erb
new file mode 100644
index 000000000..d32025787
--- /dev/null
+++ b/app/views/attachments/_course_file_links.html.erb
@@ -0,0 +1,72 @@
+
+ <% is_float ||= false %>
+ <% for attachment in attachments %>
+
+ <%if is_float%>
+
+ <% end%>
+
+ <% if options[:length] %>
+ <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%>
+ <% else %>
+ <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%>
+ <% end %>
+
+ <%if is_float%>
+
+ <% end%>
+
+ <% if attachment.is_text? %>
+ <%= link_to image_tag('magnifier.png'),
+ :controller => 'attachments',
+ :action => 'show',
+ :id => attachment,
+ :filename => attachment.filename%>
+ <% end %>
+
+ <%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %>
+
+
(
+ <%= number_to_human_size attachment.filesize %>)
+
+ <% if options[:deletable] %>
+ <% if attachment.container_type == 'HomeworkAttach' %>
+ <%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},
+ :data => {:confirm => l(:text_are_you_sure)},
+ :method => :delete,
+ :class => 'delete delete-homework-icon',
+ :remote => true,
+ :title => l(:button_delete) %>
+ <% else %>
+ <%= link_to image_tag('delete.png'), attachment_path(attachment),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :method => :delete,
+ :class => 'delete',
+ #:remote => true,
+ #:id => "attachments_" + attachment.id.to_s,
+ :title => l(:button_delete) %>
+ <% end %>
+ <% end %>
+ <% if options[:wrap] %>
+
+
+ <% end %>
+ <% if options[:author] %>
+
+ <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>,
+ <%= format_time(attachment.created_on) %>
+
+ <% end %>
+
+ <% end %>
+ <% if defined?(thumbnails) && thumbnails %>
+ <% images = attachments.select(&:thumbnailable?) %>
+ <% if images.any? %>
+
+ <% images.each do |attachment| %>
+
<%= thumbnail_tag(attachment) %>
+ <% end %>
+
+ <% end %>
+ <% end %>
+
diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb
index e79913380..d3d392c31 100644
--- a/app/views/messages/_course_show.html.erb
+++ b/app/views/messages/_course_show.html.erb
@@ -81,7 +81,7 @@
) if @message.course_destroyable_by?(User.current) %>
<%= textilizable(@topic, :content) %>
- <%= link_to_attachments @topic, :author => false %>
+ <%= link_to_attachments_course @topic, :author => false %>
<% if User.current.logged? %>
@@ -109,7 +109,7 @@
<%= format_time(message.created_on) %>
<%= textilizable message,:content,:attachments => message.attachments %>
- <%= link_to_attachments message, :author => false %>
+ <%= link_to_attachments_course message, :author => false %>