修复成员 bug,修复作业显示bug‘

This commit is contained in:
nieguanghui 2013-10-30 10:45:37 +08:00
parent 41b5d48346
commit 224a194759
4 changed files with 33 additions and 99 deletions

View File

@ -310,8 +310,18 @@ class BidsController < ApplicationController
# @project = Project.where("id in []", a)
@user = @bid.author
@bidding_project = @bid.biding_projects.all
@bidding_project = @bidding_project.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
#added by nie
@temp = []
@bidding_project.each do |pro|
if pro.project && pro.project.project_status
@temp << pro
end
@temp
end
if @temp.size > 0
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
end
#ended
if @bid.homework_type == 1
@homework = HomeworkAttach.new
@homework_list = @bid.homeworks

View File

@ -48,14 +48,14 @@ class MembersController < ApplicationController
def create
members = []
project_info = []
user_grade = []
user_grades = []
if params[:membership]
if params[:membership][:user_ids]
attrs = params[:membership].dup
user_ids = attrs.delete(:user_ids)
user_ids.each do |user_id|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
user_grade << UserGrade.new(:user_id => user_id, :project_id => @project.id)
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
## added by nie
if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id)
@ -65,6 +65,7 @@ class MembersController < ApplicationController
end
else
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
user_grades << UserGrade.new(:user_id => params[:membership][:user_id], :project_id => @project.id)
## added by nie
if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id])
@ -74,7 +75,7 @@ class MembersController < ApplicationController
@project.members << members
# added by nie
@project.project_infos << project_info
@project.user_grades << user_grade
@project.user_grades << user_grades
# end
end
@ -126,21 +127,21 @@ class MembersController < ApplicationController
def destroy
if request.delete? && @member.deletable?
@member.destroy
# end
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_admin.size > 0
user_admin.each do |user|
user.destroy
@member.destroy
# end
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_admin.size > 0
user_admin.each do |user|
user.destroy
end
end
end
user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_grade.size > 0
user_grade.each do |grade|
grade.destroy
user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
if user_grade.size > 0
user_grade.each do |grade|
grade.destroy
end
end
end
end
respond_to do |format|
format.html { redirect_to_settings_in_projects }
format.js

View File

@ -1,5 +1,6 @@
<% bidding_project.each do |b_project|%>
<% if b_project.project %>
<table width="90%" border="0" align='center'>
<tr>
<td>
@ -23,7 +24,7 @@
<td style="color: red;" align="right" valign="0.1em" width="16%">
<strong><span id="reward_result_<%=b_project.id%>"> <!-- 调用js进行刷新 -->
<%= 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?) %>
<%= l(:label_system_grade) %>:<%= (b_project.project.project_status.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) == "" %>
<% if @bid.deadline < Date.today %>
<%= l(:label_noawards)%>
@ -157,4 +158,5 @@
</tr>
</table>
<% end %>
<% end %>

View File

@ -20,48 +20,7 @@
<% end %>
</td>
</table>
<!-- <% bidding_project.each do |b_project|%>
<table width="90%" border="0" align='center'>
<tr>
<td>
<table width="660px" border="0" align='center'>
<tr>
<td width="50px" valign="top" colspan="2" align="middle">
<div style="width: 50px; height: 50px;">
<%= link_to image_tag(url_to_avatar(b_project.project), :class => 'avatar3'), :class => "avatar" %>
</div></td>
<td width="60%" valign="top">
<table width="100%" valign="top">
<tr>
<td colspan="2" valign="top"><strong><%= link_to(b_project.project.name, project_path(b_project.project)) %></strong><a class="font_lighter"><%= l(:label_jion_bidding_homework)%></a></td>
</tr>
<tr></tr>
<tr>
<td valign="top"><%= b_project.project.description %></td>
</tr>
<tr>
<td valign="top"><a class="font_lighter"><%=format_time(b_project.created_at) %></a></td>
</tr>
</table></td>
<td width="30%">
<div class="bid-user-message" style="border-left: 1px solid rgb(225, 225, 225); margin-left: 20px; padding-left: 20px;">
<table width="100%">
<tr>
<td><%= l(:label_bidding_user_studentcode) %> : <%= @user.user_extensions.student_id %></td>
</tr>
<tr>
<td><%= l(:label_bidding_user_homework) %> : <%= link_to(b_project.user.name, user_path(b_project.user)) %></td>
</tr>
<tr>
<td style=" word-wrap: break-word; word-break: break-all"><%= l(:label_bidding_reason_homewrok) %> : <%= b_project.description %></td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
<% end %> -->
<% else %>
<table width="1000px" border="0" style="padding-left: 15px">
@ -74,44 +33,6 @@
<% end %>
</table>
<!-- <% bidding_project.each do |b_project|%>
<table width="90%" border="0" align='center'>
<tr>
<td>
<table width="660px" border="0" align='center'>
<tr>
<td width="50px" valign="top" colspan="2" align="middle">
<div style="width: 50px; height: 50px;">
<%= link_to image_tag(url_to_avatar(b_project.project), :class => 'avatar3'), :class => "avatar" %>
</div></td>
<td width="60%" valign="top">
<table width="100%" valign="top">
<tr>
<td colspan="2" valign="top"><strong><%= link_to(b_project.project.name, project_path(b_project.project)) %></strong><a class="font_lighter"><%= l(:label_join_bidding)%></a></td>
</tr>
<tr></tr>
<tr>
<td valign="top"><%= b_project.project.description %></td>
</tr>
<tr>
<td valign="top"><a class="font_lighter"><%= b_project.created_at%></a></td>
</tr>
</table></td>
<td width="30%">
<div class="bid-user-message" style="border-left: 1px solid rgb(225, 225, 225); margin-left: 20px; padding-left: 20px;">
<table width="100%">
<tr>
<td><%= l(:label_bidding_user) %><%= link_to(b_project.user.name, user_path(b_project.user)) %></td>
</tr>
<tr>
<td style=" word-wrap: break-word; word-break: break-all"><%= l(:label_bidding_reason) %><%= b_project.description %></td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
<% end %> -->
<% end %>
<%= render :partial=> "list_projects",:locals => {:bidding_project => bidding_project,:bid => @bid }%>