添加删除项目型作业功能

This commit is contained in:
z9hang 2014-05-15 10:50:46 +08:00
parent 6086b25db7
commit c48b850cf7
4 changed files with 18 additions and 3 deletions

View File

@ -7,7 +7,7 @@ class BidsController < ApplicationController
menu_item :homework_respond, :only => :homework_respond menu_item :homework_respond, :only => :homework_respond
menu_item :homework_statistics, :only => :homework_statistics menu_item :homework_statistics, :only => :homework_statistics
#Ended by young #Ended by young
before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
:show_course, :show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] :show_course, :show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
# added by fq # added by fq
before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest]
@ -500,6 +500,15 @@ class BidsController < ApplicationController
end end
end end
#删除已提交的项目作业(不删项目)
def delete
binding_project = params[:binding_project]
if BidingProject.delete(binding_project)
redirect_to project_for_bid_path
else
redirect_to 403;
end
end
## 新建留言 ## 新建留言
def create def create

View File

@ -19,7 +19,7 @@ class BidingProject < ActiveRecord::Base
self.create(:user_id => User.current.id, :bid_id => bid_id, self.create(:user_id => User.current.id, :bid_id => bid_id,
:project_id => project_id, :description => description) :project_id => project_id, :description => description)
end end
# used to update the reward ,the value varies from 0,1,2,3,4,5 # used to update the reward ,the value varies from 0,1,2,3,4,5
# added by william # added by william
def update_reward(which) def update_reward(which)

View File

@ -153,7 +153,12 @@
<span class="required">迟交</span> <span class="required">迟交</span>
<% end %> <% end %>
</td> </td>
<td align="right"><%= link_to image_tag('delete.png') %></td> <td align="right">
<% if b_project.user.id == User.current.id || User.current.id == b_project.bid.author.id
%>
<%= link_to image_tag('delete.png'),{ :action => "delete", :binding_project => b_project}, :confirm => "Are you sure?" %>
<% end %>
</td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@ -550,6 +550,7 @@ RedmineApp::Application.routes.draw do
match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid'
match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang
match 'calls/:id/add', :controller => 'bids', :action => 'add' 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 match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework', via: :post
match 'calls/:id/new_submit_homework', to: 'bids#new_submit_homework', via: :get, as: 'new_submit_homework' match 'calls/:id/new_submit_homework', to: 'bids#new_submit_homework', via: :get, as: 'new_submit_homework'
match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond' match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond'