diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index b65cfc23d..28561bb0e 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -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} diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 8e1067775..684c68513 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -94,8 +94,8 @@ <% 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 %> diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index ba002292c..80292340f 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -3,12 +3,12 @@ <%= form_for(@homework) do |f|%>

标 题: - <%= 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;"%>

描 述: - <%= 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;" %>

diff --git a/config/routes.rb b/config/routes.rb index 05041ac98..e168108fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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