1. 修复作业无附件时会将作业删除的问题

2.修复作业无附件时不会显示作业的问题
3.去除多余页面显示
This commit is contained in:
sw 2014-06-03 09:03:56 +08:00
parent 22688dd5da
commit cc5eb3d0af
4 changed files with 18 additions and 21 deletions

View File

@ -139,9 +139,9 @@ class AttachmentsController < ApplicationController
# Make sure association callbacks are called # Make sure association callbacks are called
container = @attachment.container container = @attachment.container
@attachment.container.attachments.delete(@attachment) @attachment.container.attachments.delete(@attachment)
if container.attachments.empty? #if container.attachments.empty?
container.delete #container.delete
end #end
respond_to do |format| respond_to do |format|
format.html { redirect_to_referer_or respond_path(@bid) } format.html { redirect_to_referer_or respond_path(@bid) }

View File

@ -36,14 +36,19 @@ class HomeworkAttachController < ApplicationController
@homework.save_attachments(params[:attachments]) @homework.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@homework) render_attachment_warning_if_needed(@homework)
@homework.save #@homework.save
respond_to do |format| respond_to do |format|
if @homework.save if @homework.save
format.html { redirect_to @homework, notice: 'Post was successfully created.' } #ContestingSoftapplication.create(:contest_id => params[:contest_id], :softapplication_id => @softapplication.id)
format.json { render json: @homework, status: :created, location: @homework } #format.html { redirect_to project_for_bid_path(:id => @homework.bid), notice: l(:notice_attendingcontest_work_successfully_created) }
# format.json { render json: @softapplication, status: :created, location: @softapplication }
flash[:notice] = l(:notice_attendingcontest_work_successfully_created)
redirect_back_or_default(project_for_bid_path)
else else
format.js { render status: 406 }
format.html { render action: "new" } format.html { render action: "new" }
format.json { render json: @homework.errors, status: :unprocessable_entity } # format.json { render json: @softapplication.errors, status: :unprocessable_entity }
end end
end end
#end #end
@ -65,15 +70,10 @@ class HomeworkAttachController < ApplicationController
def update def update
@homework = HomeworkAttach.find(params[:id]) @homework = HomeworkAttach.find(params[:id])
respond_to do |format| #@homework.name = params[:name]
if @homework.update_attributes(params[:homework]) #@homework.name = params[:description]
format.html { redirect_to @homework, notice: 'Homework was successfully updated.' } #@homework.save
format.json { head :no_content } @homework.update_attribute(params[:homework])
else
format.html { render action: "edit" }
format.json { render json: @homework.errors, status: :unprocessable_entity }
end
end
end end
def destroy def destroy

View File

@ -25,7 +25,6 @@
<% end %> <% end %>
<% display_id = im_watching_student_id? @bid%> <% display_id = im_watching_student_id? @bid%>
<% @homework_list.each do |homework|%> <% @homework_list.each do |homework|%>
<% if homework.attachments.any?%>
<table width="660px" border="0" align="center"> <table width="660px" border="0" align="center">
<tr> <tr>
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td> <td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
@ -81,7 +80,7 @@
<%= format("%.2f", sum * 1.0 / stars_reates_count) %> <%= format("%.2f", sum * 1.0 / stars_reates_count) %>
</td> </td>
<td valign="top" align="right"> <td valign="top" align="right">
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.attachments[0].created_on.to_s) %> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
<span class="required">迟交</span> <span class="required">迟交</span>
<% end %> <% end %>
</td> </td>
@ -118,6 +117,5 @@
</td> </td>
</tr> </tr>
</table> </table>
<div class="line_under"></div> <div class="line_under"></div>
<% end %>
<% end %> <% end %>

View File

@ -1,6 +1,5 @@
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p> <p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
<div class="box"> <div class="box">
<%= @homework.attachments.count %>
<%= form_for(@homework) do |f|%> <%= form_for(@homework) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;"> <p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标 题:</strong> <strong>标 题:</strong>