Conflicts: app/views/projects/_project.html.erb app/views/projects/member.html.erb app/views/users/index.html.erb config/locales/zh.yml db/schema.rb files/2013/10/131007102834__my_course.html.erbexceptionHandle
commit
21ffbe637e
@ -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
|
@ -0,0 +1,45 @@
|
|||||||
|
<% if members.any? %>
|
||||||
|
<% members.each do |member| %>
|
||||||
|
<div class="well">
|
||||||
|
<% next if member.new_record? %>
|
||||||
|
<% unless member.created_on.nil? %>
|
||||||
|
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||||
|
<% end %>
|
||||||
|
<%= member.user.nil? ? '' : (link_to image_tag(url_to_avatar(member.user), :class => 'avatar'), :class => "avatar") %>
|
||||||
|
<%= content_tag "div", link_to_user(member.principal), :class => "nomargin avatar_name" %>
|
||||||
|
|
||||||
|
<% if @project.project_type == 1 %>
|
||||||
|
<div class ="clear avatar_name">
|
||||||
|
<p>
|
||||||
|
<% if member.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
|
||||||
|
<%= l(:label_teacher) %>
|
||||||
|
<% elsif member.roles.sort.collect(&:to_s).join(', ') =='Reporter' %>
|
||||||
|
<%= l(:label_student) %>
|
||||||
|
<% elsif member.roles.sort.collect(&:to_s).join(', ') =='TA' %>
|
||||||
|
<%= l(:label_TA) %>
|
||||||
|
<% else %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<% else%>
|
||||||
|
<%= content_tag "div", content_tag("p", member.roles.sort.collect(&:to_s).join(', ')), :class => "clear avatar_name" %>
|
||||||
|
<% users.each do |user|%>
|
||||||
|
<% if user[:user_id] == member[:user_id]%>
|
||||||
|
<div class="clear avatar_user">
|
||||||
|
<p>
|
||||||
|
<%= l(:label_user_for_project_grade) %>: <span style="color:red"><%= user[:grade] %></span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %>
|
||||||
|
</div>
|
||||||
|
<% end; reset_cycle %>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata">
|
||||||
|
<%= l(:label_no_data) %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
Loading…
Reference in new issue