delete homework

This commit is contained in:
xianbo 2013-10-11 20:32:44 +08:00
parent 8ce8de09cb
commit d7f7ff5fa9
5 changed files with 158 additions and 145 deletions

View File

@ -13,7 +13,6 @@ class BidsController < ApplicationController
helper :attachments helper :attachments
include AttachmentsHelper include AttachmentsHelper
helper :projects helper :projects
def index def index
@project_type = params[:project_type] @project_type = params[:project_type]
# Modified by nie # Modified by nie
@ -264,7 +263,6 @@ class BidsController < ApplicationController
end end
end end
##### by huang ##### by huang
def show_project_homework def show_project_homework
# flash[:notice] = "" # flash[:notice] = ""
@ -371,6 +369,19 @@ class BidsController < ApplicationController
end end
end end
#删除作业
#by xianbo
def homework_destroy
@bid_to_destroy = Bid.find params[:course_id]
@bid_to_destroy.destroy
respond_to do |format|
format.html { redirect_to :back }
format.js
#format.api { render_api_ok }
end
end
#end by xianbo
##引用 ##引用
def new def new
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id] @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
@ -395,6 +406,7 @@ class BidsController < ApplicationController
@bid = Bid.new @bid = Bid.new
@bid.safe_attributes = params[:bid] @bid.safe_attributes = params[:bid]
end end
#huang #huang
def create_contest def create_contest
@bid = Bid.new @bid = Bid.new
@ -418,7 +430,6 @@ class BidsController < ApplicationController
end end
end end
#huang #huang
def new_contest def new_contest
@bid = Bid.new @bid = Bid.new
@ -523,7 +534,6 @@ class BidsController < ApplicationController
end end
end end
def back def back
@jour = @bid.journals_for_messages @jour = @bid.journals_for_messages
@jour.each_with_index {|j,i| j.indice = i+1} @jour.each_with_index {|j,i| j.indice = i+1}
@ -556,7 +566,6 @@ class BidsController < ApplicationController
end end
end end
# added by william # added by william
# used to manage the bid and end the bid # used to manage the bid and end the bid
def manage def manage

View File

@ -55,7 +55,6 @@ class Bid < ActiveRecord::Base
acts_as_activity_provider :find_options => {:include => [:projects, :author]}, acts_as_activity_provider :find_options => {:include => [:projects, :author]},
:author_key => :author_id :author_key => :author_id
safe_attributes 'name', safe_attributes 'name',
'description', 'description',
'budget', 'budget',
@ -64,7 +63,6 @@ class Bid < ActiveRecord::Base
# safe_attributes 'name', # safe_attributes 'name',
# 'description', # 'description',
# 'deadline' # 'deadline'
def add_jour(user, notes, reference_user_id = 0) def add_jour(user, notes, reference_user_id = 0)
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
end end
@ -122,5 +120,4 @@ class Bid < ActiveRecord::Base
end end
end end
end end
end end

View File

@ -13,21 +13,26 @@
<tr> <tr>
<td colspan="2" valign="top"><strong><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: &nbsp; <td colspan="2" valign="top"><strong><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: &nbsp;
<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>&nbsp;&nbsp;&nbsp; <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>&nbsp;&nbsp;&nbsp;
<%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %></strong></td> <%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %></strong> <%= link_to(
l(:button_delete),
{:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'icon icon-del'
) %></span></td>
</td>
</tr> </tr>
<tr> <tr>
<td width="500"> <td width="500">
<table border="0"> <table border="0">
<tr> <tr>
<td> <% if bid.reward_type.nil? or bid.reward_type == 1 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: 微软雅黑"><%= l(:label_call_bonus) %>&nbsp;<%= l(:label_RMB_sign) %><%= bid.budget%></span></strong> <% elsif bid.reward_type == 2 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong> <% else %> <!-- <strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %>&nbsp;<%= bid.budget%>&nbsp;<%= l(:label_bids_credit_number) %></span></strong> --> <% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td> <td> <% if bid.reward_type.nil? or bid.reward_type == 1 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: 微软雅黑"><%= l(:label_call_bonus) %>&nbsp;<%= l(:label_RMB_sign) %><%= bid.budget%></span></strong> <% elsif bid.reward_type == 2 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong> <% else %> <!-- <strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %>&nbsp;<%= bid.budget%>&nbsp;<%= l(:label_bids_credit_number) %></span></strong> --> <% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td>
</tr> </tr>
<tr> <tr>
<td><span class="font_lighter"> <td><span class="font_lighter"> <% if bid.homework_type == 1%>
<% if bid.homework_type == 1%>
<%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, project_for_bid_path(bid.id) %></strong>) <%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, project_for_bid_path(bid.id) %></strong>)
<% else %><%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<strong><%= link_to bid.biding_projects.count, project_for_bid_path(bid.id) %></strong>)<% end %> <% else %><%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<strong><%= link_to bid.biding_projects.count, project_for_bid_path(bid.id) %></strong>)<% end %> </span><span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)</span></td>
</span><span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)</span></td>
</tr> </tr>
</table></td> </table></td>
<td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td> <td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td>
@ -50,5 +55,7 @@
<% end %> <% end %>
<% else %> <% else %>
<p class="font_description"><%= l(:label_my_create_honework_no_homework) %></p> <p class="font_description">
<%= l(:label_my_create_honework_no_homework) %>
</p>
<% end %> <% end %>

View File

@ -13,8 +13,7 @@
<tr> <tr>
<td colspan="2" valign="top"><strong><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: &nbsp;<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> <td colspan="2" valign="top"><strong><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: &nbsp;<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> <%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> </strong></td>
</strong></td>
</tr> </tr>
<tr> <tr>
<td width="500"> <td width="500">
@ -23,11 +22,9 @@
<td> <% if bid.reward_type.nil? or bid.reward_type == 1 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: 微软雅黑"><%= l(:label_call_bonus) %>&nbsp;<%= l(:label_RMB_sign) %><%= bid.budget%></span></strong> <% elsif bid.reward_type == 2 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong> <% else %> <!-- <strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %>&nbsp;<%= bid.budget%>&nbsp;<%= l(:label_bids_credit_number) %></span></strong> --> <% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td> <td> <% if bid.reward_type.nil? or bid.reward_type == 1 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: 微软雅黑"><%= l(:label_call_bonus) %>&nbsp;<%= l(:label_RMB_sign) %><%= bid.budget%></span></strong> <% elsif bid.reward_type == 2 %> <strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong> <% else %> <!-- <strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %>&nbsp;<%= bid.budget%>&nbsp;<%= l(:label_bids_credit_number) %></span></strong> --> <% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td>
</tr> </tr>
<tr> <tr>
<td><span class="font_lighter"> <td><span class="font_lighter"> <% if bid.homework_type == 1%>
<% if bid.homework_type == 1%>
<%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, project_for_bid_path(bid.id) %></strong>) <%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, project_for_bid_path(bid.id) %></strong>)
<% else %><%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<strong><%= link_to bid.biding_projects.count, project_for_bid_path(bid.id) %></strong>)<% end %> <% else %><%= l(:label_x_homework_project, :count => bid.biding_projects.count) %>(<strong><%= link_to bid.biding_projects.count, project_for_bid_path(bid.id) %></strong>)<% end %> </span><span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)
</span><span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)</span></td>
</tr> </tr>
</table></td> </table></td>
<td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td> <td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td>
@ -50,5 +47,7 @@
<% end %> <% end %>
<% else %> <% else %>
<p class="font_description"><%= l(:label_my_honework_no_homework) %></p> <p class="font_description">
<%= l(:label_my_honework_no_homework) %>
</p>
<% end %> <% end %>

View File

@ -60,6 +60,7 @@ RedmineApp::Application.routes.draw do
post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply' post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
post 'bids/homework_destroy', :to => 'bids#homework_destroy'
# Misc issue routes. TODO: move into resources # Misc issue routes. TODO: move into resources
match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues' match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'