Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

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.erb
This commit is contained in:
xianbo 2013-10-24 08:33:07 +08:00
commit 21ffbe637e
17 changed files with 181 additions and 103 deletions

View File

@ -26,6 +26,8 @@ class BidsController < ApplicationController
else
@bids = Bid.visible.where('reward_type = ?', 1)
end
@bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count

View File

@ -282,13 +282,13 @@ class UsersController < ApplicationController
when '1'
@offset ||= @user_pages.reverse_offset
unless @offset == 0
@users_statuses = scope.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
else
limit = @user_count % @limit
if limit == 0
limit = @limit
end
@users_statuses = scope.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
end
@s_type = 1
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}

View File

@ -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

View File

@ -21,7 +21,7 @@
<!-- 如果需求到期 并且是该需求的管理员 -->
<td style="color: red;" align="right" valign="0.1em" width="15%">
<td style="color: red;" align="right" valign="0.1em" width="16%">
<strong><span id="reward_result_<%=b_project.id%>">
<%= l(:label_system_grade) %>:<%= (b_project.project.project_status.grade.nil? ? 0 : b_project.project.project_status.grade) unless (b_project.project.project_status.nil? && b_project.project.nil?) %>
<% if get_prize(b_project).nil? or get_prize(b_project) == "" %>

View File

@ -1,5 +1,5 @@
<!-- fq -->
<%= form_tag(calls_path, :method => :get) do %>
<%= form_tag(:controller => 'bids', :action => 'contest', :method => :get) do %>
<div class="project-search-block">
<table width="100%" valign="center">
<tr>
@ -19,7 +19,7 @@
<td align="right">
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td>

View File

@ -23,6 +23,9 @@
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'reward_type', params[:reward_type] %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td>

View File

@ -1,12 +1,14 @@
<% 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) % -->
<%= link_to(l(:label_file_upload), new_project_file_path(@project), :class => 'icon icon-add') if User.current.member_of?(@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 +26,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>

View File

@ -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 %>

View File

@ -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 %>

View File

@ -88,7 +88,9 @@
<%= content_tag('span', "#{l(:label_create_time)}: ") %><%= content_tag('span', format_time(@project.created_on)) %>
</div>
<div class="grade">
<% if @project.project_type !=1 %>
<%= content_tag('span', "#{l(:label_project_grade)}: ")%><span style='color:red'><%= @project.project_status.grade%></span>
<% end %>
</div>
<!-- added by liuping -->

View File

@ -14,8 +14,7 @@
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td>
</tr>
</table>

View File

@ -1,66 +1,31 @@
<div class="member_header"><p><%= l(:label_member_list)%></p></div>
<div class="member_header">
<p>
<%= l(:label_member_list)%>
</p>
</div>
<div class="member_content">
<%= error_messages_for 'member' %>
<% roles = Role.find_all_givable
members = @project.member_principals.includes(:roles, :principal).all.sort %>
<%
users = UserGrade.find_by_sql("select * from user_grades where project_id = #{@project.id}").sort {|a,b| a[:grade] <=> b[:grade]}
%>
<% temp = [] %>
<% users.each do |user|%>
<% members.each do |member|%>
<% if member[:user_id] == user[:user_id] %>
<% temp << member%>
<% end %>
<% end %>
<% end %>
<% temps = temp.reverse %>
<% if temps.any? %>
<% temps.each do |member| %>
<div class="well">
<!--Modified by nie-->
<% 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" %>
<!-- added by huang modified by bai-->
<% 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 %>
<!-- 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 %>
<%= error_messages_for 'member' %>
<% roles = Role.find_all_givable
members = @project.member_principals.includes(:roles, :principal).all.sort %>
<% if @project.project_type == 1 %>
<% else %>
<% users = UserGrade.find_by_sql("select * from user_grades where project_id = #{@project.id}")%>
<% if users %>
<% users.sort {|a,b| a[:grade] <=> b[:grade]} %>
<% temp = [] %>
<% users.each do |user|%>
<% members.each do |member|%>
<% if member[:user_id] == user[:user_id] %>
<% temp << member%>
<% end %>
<% end %>
<% end %>
<% members = temp.reverse %>
<% end %>
<% end %>
<%= render :partial => 'member_list', :locals => {:members => members} %>
</div>

View File

@ -1,7 +1,7 @@
<!-- <h3>测试结果</h3> -->
<p id="stcloud">
<a href="http://www.trustie.net/webdts/" style="float:right" target="_blank">进入测试平台</a>
<p id="stcloud" style="padding-bottom: 5px">
<a href="http://www.trustie.net/webdts/" style="float:right" target="_blank"><strong>进入测试平台</strong></a>
</p>
<% @shares.each do |share| %>

View File

@ -117,6 +117,10 @@
<div>
<%= link_to image_tag(url_to_avatar(user), :class => 'avatar'), user_path(user) %>
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
<div style="position:relative;float:left;margin-top:-2px;margin-left: 160px">
<%= l(:label_user_grade) %>: <span style="color:red"><%= user.user_status.grade %></span>
</div>
<!-- <%= content_tag "div", "#{l(:label_user_grade)}:" %><%= user.user_status.grade %> -->
</div>
@ -125,9 +129,9 @@
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
</div>
<div style="position:relative;float:left;margin-top:-20px;margin-left: 724px">
<!-- <div style="position:relative;float:left;margin-top:-20px;margin-left: 724px">
<%= l(:label_user_grade) %>: <span style="color:red"><%= user.user_status.grade %></span>
</div>
</div> -->
<div class="user-bottom">
<% unless user.memberships.empty? %>

View File

@ -1641,6 +1641,7 @@ zh:
label_in_course: 在课程中
label_assign_homework: 中布置了作业
label_noawards: 未评奖
label_course_modify_settings: 配置课程
label_module_share: dts测试工具
label_homework_prompt: 贴心小提示:

View File

@ -237,7 +237,7 @@ end
Redmine::MenuManager.map :top_college_menu do |menu|
menu.push :home, :home_path
menu.push :new_course, {:controller => 'projects', :action => 'course', :project_type => 1 }
menu.push :new_course, {:controller => 'projects', :action => 'course', :project_type => 1}
menu.push :new_homework, {:controller => 'bids', :action => 'index', :project_type => 1 }
menu.push :new_contest, {:controller => 'bids', :action => 'contest', :project_type => 1}
menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 0 }, :caption => :label_project_plural

View File

@ -48,3 +48,8 @@
position:relative;
top:1px;
}
#share_project_id {
float: right;
width: 100%;
}