course can be shared files by project's member
This commit is contained in:
parent
5ce9bcdb2c
commit
4bef2eee24
|
@ -0,0 +1,47 @@
|
|||
# encoding: utf-8
|
||||
module FilesHelper
|
||||
|
||||
def downloadAll containers
|
||||
paths = []
|
||||
files = []
|
||||
tmpfile = "tmp.zip"
|
||||
|
||||
containers.each do |container|
|
||||
next if container.attachments.empty?
|
||||
if container.is_a?(Version);end
|
||||
container.attachments.each do |attachment|
|
||||
paths << attachment.diskfile
|
||||
file = attachment.diskfile
|
||||
# logger.error "[FilesHelper] downloadAll: #{e}"
|
||||
begin
|
||||
File.new(file, "r")
|
||||
rescue Exception => e
|
||||
logger.error e
|
||||
next
|
||||
end
|
||||
files << file
|
||||
# zip.add(file.path.dup.sub(directory, ''), file.path)
|
||||
end
|
||||
end
|
||||
|
||||
zipfile_name = "archive.zip"
|
||||
if File.exists? File.open(zipfile_name, "w+")
|
||||
ff = File.open(zipfile_name, "w+")
|
||||
ff.close
|
||||
File.delete ff
|
||||
end
|
||||
Zip::ZipFile.open(zipfile_name, Zip::ZipFile::CREATE) do |zipfile|
|
||||
files.each do |filename|
|
||||
directory = File.dirname filename
|
||||
# Two arguments:
|
||||
# - The name of the file as it will appear in the archive
|
||||
# - The original file, including the path to find it
|
||||
dir = filename.sub(directory+"/", '')
|
||||
zipfile.add(dir, filename)
|
||||
|
||||
end
|
||||
end
|
||||
File.new(zipfile_name,'w+')
|
||||
end
|
||||
|
||||
end
|
|
@ -1,12 +1,13 @@
|
|||
<% if @project.project_type == 1 %>
|
||||
<div class="contextual" style="padding-right: 540px;padding-top: 5px;">
|
||||
<% if User.current.member_of?(@project) %>
|
||||
<%= link_to(l(:label_file_upload), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
||||
<% end %>
|
||||
<%= link_to(l(:label_file_upload), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="contextual" style="padding-right: 540px;padding-top: 5px;">
|
||||
<%= link_to(l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
||||
<!-- %= link_to(l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) % -->
|
||||
<%= link_to(l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add') if User.current.member_of?(@project) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
@ -24,30 +25,33 @@
|
|||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% @containers.each do |container| %>
|
||||
<% next if container.attachments.empty? -%>
|
||||
<% if container.is_a?(Version) -%>
|
||||
<tr>
|
||||
<th colspan="6" align="left">
|
||||
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %>
|
||||
</th>
|
||||
</tr>
|
||||
<% end -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<tr class="file <%= cycle("odd", "even") %>">
|
||||
<td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %></td>
|
||||
<td class="created_on"><%= format_time(file.created_on) %></td>
|
||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||
<!-- <td class="downloads"><%= file.downloads %></td> -->
|
||||
<td class="digest" width="300px"><%= file.description %></td>
|
||||
<td align="center">
|
||||
<%= link_to(image_tag('delete.png'), attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end
|
||||
reset_cycle %>
|
||||
<% end %>
|
||||
<% @containers.each do |container| %>
|
||||
<% next if container.attachments.empty? -%>
|
||||
<% if container.is_a?(Version) -%>
|
||||
<tr>
|
||||
<th colspan="6" align="left">
|
||||
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %>
|
||||
</th>
|
||||
</tr>
|
||||
<% end -%>
|
||||
<% container.attachments.each do |file| %>
|
||||
<tr class="file <%= cycle("odd", "even") %>">
|
||||
<td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %></td>
|
||||
<td class="created_on"><%= format_time(file.created_on) %></td>
|
||||
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||
<!-- <td class="downloads"><%= file.downloads %></td> -->
|
||||
<td class="digest" width="300px"><%= file.description %></td>
|
||||
<td align="center">
|
||||
<%= link_to(image_tag('delete.png'), attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% reset_cycle %>
|
||||
<% end %>
|
||||
<!-- %= h downloadAll(@containers) % -->
|
||||
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<meta name="keywords" content="issue,bug,tracker" />
|
||||
<%= csrf_meta_tag %>
|
||||
<%= favicon %>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
|
||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||
<%= javascript_heads %>
|
||||
<%= heads_for_theme %>
|
||||
|
|
|
@ -1641,7 +1641,8 @@ zh:
|
|||
label_in_course: 在课程中
|
||||
label_assign_homework: 中布置了作业
|
||||
label_noawards: 未评奖
|
||||
label_module_share: dts测试工具
|
||||
label_homework_prompt: 贴心小提示:
|
||||
label_homework_prompt_content: 亲,在这里我们的作业将以项目的形式提交,如果小伙伴们还没有创建项目,请先创建一个项目。项目创建成功后,就可以
|
||||
label_create_homework: 布置了作业:
|
||||
label_create_homework: 布置了作业:
|
||||
|
||||
label_module_share: DTS测试工具
|
||||
|
|
|
@ -48,3 +48,8 @@
|
|||
position:relative;
|
||||
top:1px;
|
||||
}
|
||||
|
||||
#share_project_id {
|
||||
float: right;
|
||||
width: 100%;
|
||||
}
|
Loading…
Reference in New Issue