修改作业在进行修改、删除、添加时的代码

president
sw 11 years ago
parent cc5eb3d0af
commit 1a0de23b38

@ -32,23 +32,16 @@ class HomeworkAttachController < ApplicationController
:bid_id => bid_id
}
@bid = Bid.find bid_id
@homework_list = @bid.homeworks
@homework = HomeworkAttach.new(options)
@homework.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@homework)
#@homework.save
respond_to do |format|
if @homework.save
#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: @softapplication.errors, status: :unprocessable_entity }
redirect_to project_for_bid_path
end
end
#end
@ -70,15 +63,21 @@ class HomeworkAttachController < ApplicationController
def update
@homework = HomeworkAttach.find(params[:id])
name = params[:homework_name]
description = params[:homework_description]
@homework.name = name
@homework.description = description
#@homework.save_attachments(params[:attachments])
@homework.save
#@homework.name = params[:name]
#@homework.name = params[:description]
#@homework.save
@homework.update_attribute(params[:homework])
#@homework.update_attribute(params[:homework])
end
def destroy
#@homework = HomeworkAttach.find(params([:id]))
#@homework.destroy
@homework = HomeworkAttach.find(params[:id])
@homework.destroy
#respond_to do |format|
# format.html {render @homework}
# format.json {render json: @homework}

@ -94,8 +94,8 @@
<td>
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
<%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => homework},
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
<%= link_to(l(:label_bid_respond_delete), homework,
method: :delete, :confirm => l(:text_are_you_sure)) %>
<% end %>
</td>
</tr>

@ -3,12 +3,12 @@
<%= form_for(@homework) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标 题:</strong>
<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;"%>
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
</p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描 述:</strong>
<span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>
</p>
<p style="padding-left: 60px">

@ -574,7 +574,7 @@ RedmineApp::Application.routes.draw do
match 'calls/new_bid', :controller => 'bids', :action => 'new_bid'
match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang
match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid'
match 'calls/:id/new_homework', :controller => 'homework_attach', :action => 'new', :as => 'new_homework_attach'
match 'calls/:id/new_exercise_book', :controller => 'homework_attach', :action => 'new', :as => 'new_homework_attach'
match 'calls/:id/add', :controller => 'bids', :action => 'add'
match 'calls/:id/delete', :controller => 'bids', :action => 'delete'
match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework', via: :post

Loading…
Cancel
Save