From cc5eb3d0af0e750e3719f10edd4b738548d8d507 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 3 Jun 2014 09:03:56 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=97=A0=E9=99=84=E4=BB=B6=E6=97=B6=E4=BC=9A=E5=B0=86=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=88=A0=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98=202.?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=9A=E6=97=A0=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E4=BC=9A=E6=98=BE=E7=A4=BA=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=203.=E5=8E=BB=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 6 ++--- app/controllers/homework_attach_controller.rb | 26 +++++++++---------- app/views/bids/_homework_list.html.erb | 6 ++--- app/views/homework_attach/edit.html.erb | 1 - 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 2f642f544..99160b0c0 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -139,9 +139,9 @@ class AttachmentsController < ApplicationController # Make sure association callbacks are called container = @attachment.container @attachment.container.attachments.delete(@attachment) - if container.attachments.empty? - container.delete - end + #if container.attachments.empty? + #container.delete + #end respond_to do |format| format.html { redirect_to_referer_or respond_path(@bid) } diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 18da32d81..b65cfc23d 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -36,14 +36,19 @@ class HomeworkAttachController < ApplicationController @homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@homework) - @homework.save + #@homework.save + respond_to do |format| if @homework.save - format.html { redirect_to @homework, notice: 'Post was successfully created.' } - format.json { render json: @homework, status: :created, location: @homework } + #ContestingSoftapplication.create(:contest_id => params[:contest_id], :softapplication_id => @softapplication.id) + #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 + format.js { render status: 406 } 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 @@ -65,15 +70,10 @@ class HomeworkAttachController < ApplicationController def update @homework = HomeworkAttach.find(params[:id]) - respond_to do |format| - if @homework.update_attributes(params[:homework]) - format.html { redirect_to @homework, notice: 'Homework was successfully updated.' } - format.json { head :no_content } - else - format.html { render action: "edit" } - format.json { render json: @homework.errors, status: :unprocessable_entity } - end - end + #@homework.name = params[:name] + #@homework.name = params[:description] + #@homework.save + @homework.update_attribute(params[:homework]) end def destroy diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 57e3fe686..8e1067775 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -25,7 +25,6 @@ <% end %> <% display_id = im_watching_student_id? @bid%> <% @homework_list.each do |homework|%> - <% if homework.attachments.any?%>
<%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> | @@ -81,7 +80,7 @@ <%= format("%.2f", sum * 1.0 / stars_reates_count) %>- <% 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) %> 迟交 <% end %> | @@ -118,6 +117,5 @@
<%=raw l(:label_new_homework)%>
标 题: