delete homework

exceptionHandle
xianbo 12 years ago
parent 8ce8de09cb
commit d7f7ff5fa9

@ -13,7 +13,6 @@ class BidsController < ApplicationController
helper :attachments
include AttachmentsHelper
helper :projects
def index
@project_type = params[:project_type]
# Modified by nie
@ -22,7 +21,7 @@ class BidsController < ApplicationController
if @project_type == '1'
@bids = Bid.visible.where('reward_type = ?', 3)
# elsif
# @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
# @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
else
@bids = Bid.visible.where('reward_type = ?', 1)
end
@ -65,13 +64,13 @@ class BidsController < ApplicationController
end
else
unless @offset == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
limit = @limit if limit == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end
@s_state = 1
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
limit = @limit if limit == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end
@s_state = 1
end
#end
end
@ -86,7 +85,7 @@ class BidsController < ApplicationController
@bids = Bid.visible.where('reward_type = ?', 2)
# elsif
# @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
# @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
@bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
@ -125,13 +124,13 @@ class BidsController < ApplicationController
end
else
unless @offset == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
limit = @limit if limit == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end
@s_state = 1
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
limit = @limit if limit == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end
@s_state = 1
end
#end
end
@ -141,7 +140,7 @@ class BidsController < ApplicationController
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@membership.each do |membership|
if membership.project.project_type == 1
@courses << membership.project
@courses << membership.project
end
end
end
@ -174,7 +173,7 @@ class BidsController < ApplicationController
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@membership.each do |membership|
if membership.project.project_type == 1
@courses << membership.project
@courses << membership.project
end
end
render :action => 'fork'
@ -192,14 +191,14 @@ class BidsController < ApplicationController
@state = false
respond_to do |format|
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
else
format.html {
render :layout => 'base_bids'
}
render :layout => 'base_bids'
}
end
format.api
@ -214,14 +213,14 @@ class BidsController < ApplicationController
end
respond_to do |format|
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
else
format.html {
render :layout => 'base_bids'
}
render :layout => 'base_bids'
}
end
format.api
@ -236,7 +235,7 @@ class BidsController < ApplicationController
unless(membership.project.project_type==1)
membership.member_roles.each{|role|
if(role.role_id == 3)
@option << membership.project
@option << membership.project
end
}
end
@ -251,23 +250,22 @@ class BidsController < ApplicationController
@homework_list = @bid.homeworks
end
respond_to do |format|
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
else
format.html {
render :layout => 'base_bids'
}
render :layout => 'base_bids'
}
end
format.api
end
end
##### by huang
def show_project_homework
# flash[:notice] = ""
# flash[:notice] = ""
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = []
@membership.each do |membership|
@ -277,14 +275,14 @@ class BidsController < ApplicationController
@user = @bid.author
@bidding_project = @bid.biding_projects
respond_to do |format|
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
if @bid.reward_type == 3
format.html {
render :layout => 'base_homework'
}
else
format.html {
render :layout => 'base_bids'
}
render :layout => 'base_bids'
}
end
format.api
end
@ -300,9 +298,9 @@ class BidsController < ApplicationController
end
else
if @bid.reward_type == 3
flash[:error] = l(:label_bidding_homework_fail)
flash[:error] = l(:label_bidding_homework_fail)
else
flash[:error] = l(:label_bidding_fail)
flash[:error] = l(:label_bidding_fail)
end
end
@bidding_project = @bid.biding_projects
@ -371,6 +369,19 @@ class BidsController < ApplicationController
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
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
@ -395,8 +406,9 @@ class BidsController < ApplicationController
@bid = Bid.new
@bid.safe_attributes = params[:bid]
end
#huang
def create_contest
#huang
def create_contest
@bid = Bid.new
@bid.name = params[:bid][:name]
@bid.description = params[:bid][:description]
@ -418,7 +430,6 @@ class BidsController < ApplicationController
end
end
#huang
def new_contest
@bid = Bid.new
@ -492,7 +503,7 @@ class BidsController < ApplicationController
@member = []
@course.memberships.each do |member|
unless (member.roles && Role.where('id = ? ', 3)).empty?
@member.push member
@member.push member
end
end
if @bid.homework_type = 1
@ -523,7 +534,6 @@ class BidsController < ApplicationController
end
end
def back
@jour = @bid.journals_for_messages
@jour.each_with_index {|j,i| j.indice = i+1}
@ -556,7 +566,6 @@ class BidsController < ApplicationController
end
end
# added by william
# used to manage the bid and end the bid
def manage

@ -55,16 +55,14 @@ class Bid < ActiveRecord::Base
acts_as_activity_provider :find_options => {:include => [:projects, :author]},
:author_key => :author_id
safe_attributes 'name',
'description',
'budget',
'deadline'
# safe_attributes 'name',
# 'description',
# 'deadline'
# 'description',
# 'deadline'
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)
end
@ -72,7 +70,7 @@ class Bid < ActiveRecord::Base
def self.creat_bids(budget, deadline, name, description=nil, reward_type)
self.create(:author_id => User.current.id, :budget => budget,
:deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type)
# self.acts << Activity.new(:user_id => self.author_id)
# self.acts << Activity.new(:user_id => self.author_id)
end
def update_bids(budget, deadline, name, description=nil)
@ -115,12 +113,11 @@ class Bid < ActiveRecord::Base
# added by william
def validate_bid_manager(user_id)
unless user_id.nil?
if self.author_id == user_id
return true
else
return false
end
if self.author_id == user_id
return true
else
return false
end
end
end
end

@ -12,43 +12,50 @@
<table width="100%" border="0">
<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') %>&nbsp;&nbsp;&nbsp;
<%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %></strong></td>
</tr>
<tr>
<td width="500">
<table border="0">
<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>
</tr>
<tr>
<td><span class="font_lighter">
<% 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>)
<% 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 %>
<%= 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> <%= 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>
<td width="500">
<table border="0">
</span><span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)</span></td>
</tr>
</table></td>
<td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td>
<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>
</tr>
<tr>
<td>
<div class="bid-description" style="border-left: 1px solid rgb(225, 225, 225); border-bottom: 1px solid rgb(225, 225, 225); padding-left: 20px; padding-bottom: 10px; margin-bottom: 20px;">
<table width="100%">
<tr>
<td> <%= bid.description%> </td>
</tr>
</table>
</div></td>
<td><span class="font_lighter"> <% 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>)
<% 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>
</tr>
</table></td>
<td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td>
</tr>
<tr>
<td>
<div class="bid-description" style="border-left: 1px solid rgb(225, 225, 225); border-bottom: 1px solid rgb(225, 225, 225); padding-left: 20px; padding-bottom: 10px; margin-bottom: 20px;">
<table width="100%">
<tr>
<td> <%= bid.description%> </td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
<% end %>
<% end %>
<% end %>
<% 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 %>

@ -12,9 +12,8 @@
<table width="100%" border="0">
<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') %>
&nbsp;&nbsp;&nbsp;
<%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %>
</strong></td>
&nbsp;&nbsp;&nbsp;
<%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> </strong></td>
</tr>
<tr>
<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>
</tr>
<tr>
<td><span class="font_lighter">
<% if bid.homework_type == 1%>
<td><span class="font_lighter"> <% 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>)
<% 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>
<% 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>)
</tr>
</table></td>
<td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td>
@ -50,5 +47,7 @@
<% end %>
<% else %>
<p class="font_description"><%= l(:label_my_honework_no_homework) %></p>
<p class="font_description">
<%= l(:label_my_honework_no_homework) %>
</p>
<% end %>

@ -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/edit', :to => 'messages#edit'
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
match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'

Loading…
Cancel
Save