Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

This commit is contained in:
yanxd 2013-10-12 10:37:37 +08:00
commit a5cdbc8e92
16 changed files with 228 additions and 185 deletions

View File

@ -7,13 +7,12 @@ class BidsController < ApplicationController
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, :show_course] before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, :show_course]
before_filter :require_login,:only => [:set_reward] before_filter :require_login,:only => [:set_reward]
helper :watchers helper :watchers
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
@ -22,11 +21,11 @@ class BidsController < ApplicationController
if @project_type == '1' if @project_type == '1'
@bids = Bid.visible.where('reward_type = ?', 3) @bids = Bid.visible.where('reward_type = ?', 3)
# elsif # elsif
# @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
else else
@bids = Bid.visible.where('reward_type = ?', 1) @bids = Bid.visible.where('reward_type = ?', 1)
end end
@bids = @bids.like(params[:name]) if params[:name].present? @bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count @bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page'] @bid_pages = Paginator.new @bid_count, @limit, params['page']
@ -65,28 +64,28 @@ class BidsController < ApplicationController
end end
else else
unless @offset == 0 unless @offset == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else else
limit = @bid_count % @limit limit = @bid_count % @limit
limit = @limit if limit == 0 limit = @limit if limit == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end end
@s_state = 1 @s_state = 1
end end
#end #end
end end
#huang #huang
def contest def contest
# Modified by nie # Modified by nie
# @requirement_title = "4" # @requirement_title = "4"
@offset, @limit = api_offset_and_limit({:limit => 10}) @offset, @limit = api_offset_and_limit({:limit => 10})
@bids = Bid.visible.where('reward_type = ?', 2) @bids = Bid.visible.where('reward_type = ?', 2)
# elsif # 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? @bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count @bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page'] @bid_pages = Paginator.new @bid_count, @limit, params['page']
@ -125,27 +124,27 @@ class BidsController < ApplicationController
end end
else else
unless @offset == 0 unless @offset == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else else
limit = @bid_count % @limit limit = @bid_count % @limit
limit = @limit if limit == 0 limit = @limit if limit == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end end
@s_state = 1 @s_state = 1
end end
#end #end
end end
def fork def fork
@courses = [] @courses = []
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@membership.each do |membership| @membership.each do |membership|
if membership.project.project_type == 1 if membership.project.project_type == 1
@courses << membership.project @courses << membership.project
end end
end end
end end
def create_fork def create_fork
@homework = Bid.new @homework = Bid.new
@homework.name = params[:bid][:name] @homework.name = params[:bid][:name]
@ -171,10 +170,10 @@ class BidsController < ApplicationController
else else
@bid.safe_attributes = params[:bid] @bid.safe_attributes = params[:bid]
@courses = [] @courses = []
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@membership.each do |membership| @membership.each do |membership|
if membership.project.project_type == 1 if membership.project.project_type == 1
@courses << membership.project @courses << membership.project
end end
end end
render :action => 'fork' render :action => 'fork'
@ -192,39 +191,39 @@ class BidsController < ApplicationController
@state = false @state = false
respond_to do |format| respond_to do |format|
if @bid.reward_type == 3 if @bid.reward_type == 3
format.html { format.html {
render :layout => 'base_homework' render :layout => 'base_homework'
} }
else else
format.html { format.html {
render :layout => 'base_bids' render :layout => 'base_bids'
} }
end end
format.api format.api
end end
end end
def show_course def show_course
bids = Bid.where('parent_id = ?', @bid.id) bids = Bid.where('parent_id = ?', @bid.id)
@courses = [] @courses = []
for bid in bids for bid in bids
@courses << bid.courses.first @courses << bid.courses.first
end end
respond_to do |format| respond_to do |format|
if @bid.reward_type == 3 if @bid.reward_type == 3
format.html { format.html {
render :layout => 'base_homework' render :layout => 'base_homework'
} }
else else
format.html { format.html {
render :layout => 'base_bids' render :layout => 'base_bids'
} }
end end
format.api format.api
end end
end end
@ -233,10 +232,10 @@ class BidsController < ApplicationController
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = [] @option = []
@membership.each do |membership| @membership.each do |membership|
unless(membership.project.project_type==1) unless(membership.project.project_type==1)
membership.member_roles.each{|role| membership.member_roles.each{|role|
if(role.role_id == 3) if(role.role_id == 3)
@option << membership.project @option << membership.project
end end
} }
end end
@ -251,23 +250,22 @@ class BidsController < ApplicationController
@homework_list = @bid.homeworks @homework_list = @bid.homeworks
end end
respond_to do |format| respond_to do |format|
if @bid.reward_type == 3 if @bid.reward_type == 3
format.html { format.html {
render :layout => 'base_homework' render :layout => 'base_homework'
} }
else else
format.html { format.html {
render :layout => 'base_bids' render :layout => 'base_bids'
} }
end end
format.api format.api
end end
end end
##### by huang ##### by huang
def show_project_homework def show_project_homework
# flash[:notice] = "" # flash[:notice] = ""
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = [] @option = []
@membership.each do |membership| @membership.each do |membership|
@ -277,19 +275,19 @@ class BidsController < ApplicationController
@user = @bid.author @user = @bid.author
@bidding_project = @bid.biding_projects @bidding_project = @bid.biding_projects
respond_to do |format| respond_to do |format|
if @bid.reward_type == 3 if @bid.reward_type == 3
format.html { format.html {
render :layout => 'base_homework' render :layout => 'base_homework'
} }
else else
format.html { format.html {
render :layout => 'base_bids' render :layout => 'base_bids'
} }
end end
format.api format.api
end end
end end
###添加应标项目 ###添加应标项目
def add def add
project = Project.where('name = ?', params[:bid]).first project = Project.where('name = ?', params[:bid]).first
@ -299,10 +297,10 @@ class BidsController < ApplicationController
flash[:notice] = l(:label_bidding_succeed) flash[:notice] = l(:label_bidding_succeed)
end end
else else
if @bid.reward_type == 3 if @bid.reward_type == 3
flash[:error] = l(:label_bidding_homework_fail) flash[:error] = l(:label_bidding_homework_fail)
else else
flash[:error] = l(:label_bidding_fail) flash[:error] = l(:label_bidding_fail)
end end
end end
@bidding_project = @bid.biding_projects @bidding_project = @bid.biding_projects
@ -371,6 +369,20 @@ class BidsController < ApplicationController
end end
end end
#删除作业
#by xianbo
def homework_destroy
@bid_to_destroy = Bid.find params[:course_id]
(render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_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,8 +407,9 @@ class BidsController < ApplicationController
@bid = Bid.new @bid = Bid.new
@bid.safe_attributes = params[:bid] @bid.safe_attributes = params[:bid]
end end
#huang
def create_contest #huang
def create_contest
@bid = Bid.new @bid = Bid.new
@bid.name = params[:bid][:name] @bid.name = params[:bid][:name]
@bid.description = params[:bid][:description] @bid.description = params[:bid][:description]
@ -417,8 +430,7 @@ class BidsController < ApplicationController
render :action => 'new_bid' render :action => 'new_bid'
end end
end end
#huang #huang
def new_contest def new_contest
@bid = Bid.new @bid = Bid.new
@ -446,7 +458,7 @@ class BidsController < ApplicationController
render :action => 'new_bid' render :action => 'new_bid'
end end
end end
def create_homework def create_homework
@bid = Bid.new @bid = Bid.new
@bid.name = params[:bid][:name] @bid.name = params[:bid][:name]
@ -473,7 +485,7 @@ class BidsController < ApplicationController
render :action => 'new_bid' render :action => 'new_bid'
end end
end end
def add_homework def add_homework
# homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
# homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
@ -483,29 +495,29 @@ class BidsController < ApplicationController
@homework.save_attachments(params[:attachments]) @homework.save_attachments(params[:attachments])
@homework.save @homework.save
@homework_list = @bid.homeworks @homework_list = @bid.homeworks
end end
# 作业统计 # 作业统计
def homework_statistics def homework_statistics
@course = @bid.courses.first @course = @bid.courses.first
@member = [] @member = []
@course.memberships.each do |member| @course.memberships.each do |member|
unless (member.roles && Role.where('id = ? ', 3)).empty? unless (member.roles && Role.where('id = ? ', 3)).empty?
@member.push member @member.push member
end end
end end
if @bid.homework_type = 1 if @bid.homework_type = 1
@student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id) @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id)
@homework_type = true @homework_type = true
else else
@homework_type = false @homework_type = false
end end
@user = @bid.author @user = @bid.author
render :layout => 'base_homework' render :layout => 'base_homework'
end end
def homework_respond def homework_respond
@user = @bid.author @user = @bid.author
render :layout => 'base_homework' render :layout => 'base_homework'
@ -522,7 +534,6 @@ class BidsController < ApplicationController
#format.api { render_api_ok } #format.api { render_api_ok }
end end
end end
def back def back
@jour = @bid.journals_for_messages @jour = @bid.journals_for_messages
@ -541,12 +552,12 @@ class BidsController < ApplicationController
def set_reward def set_reward
@b_p = nil @b_p = nil
@biding_project_id = nil @biding_project_id = nil
if params[:set_reward][:reward] if params[:set_reward][:reward]
# @bid_id = params[:id] # @bid_id = params[:id]
@biding_project_id = params[:set_reward][:b_id] @biding_project_id = params[:set_reward][:b_id]
@b_p = BidingProject.find_by_id(@biding_project_id) @b_p = BidingProject.find_by_id(@biding_project_id)
# 把字段存进表中 # 把字段存进表中
@b_p.update_reward(params[:set_reward][:reward].to_s) @b_p.update_reward(params[:set_reward][:reward].to_s)
end end
@ -556,7 +567,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

@ -23,12 +23,14 @@ class UsersController < ApplicationController
menu_item :requirement_focus, :only => :watch_bids menu_item :requirement_focus, :only => :watch_bids
menu_item :user_newfeedback, :only => :user_newfeedback menu_item :user_newfeedback, :only => :user_newfeedback
menu_item :user_course, :only => :user_courses menu_item :user_course, :only => :user_courses
menu_item :user_homework, :only => :user_homeworks
#Ended by young #Ended by young
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:update, :user_courses] before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:update,
:user_courses, :user_homeworks]
#edit has been deleted by huang, 2013-9-23 #edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks,
:destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info] :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save accept_api_auth :index, :show, :create, :update, :destroy,:tag_save
@ -79,7 +81,7 @@ class UsersController < ApplicationController
def watch_bids def watch_bids
cond = 'bids.reward_type <> 1' cond = 'bids.reward_type <> 1'
@bids = Bid.watched_by(@user) @bids = Bid.watched_by(@user)
@bids = Bid.visible.where('reward_type = ?', 1) # modified by huang @bids = Bid.visible.where('reward_type = ?', 1) # added by huang
@offset, @limit = api_offset_and_limit({:limit => 10}) @offset, @limit = api_offset_and_limit({:limit => 10})
@bid_count = @bids.count @bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page'] @bid_pages = Paginator.new @bid_count, @limit, params['page']
@ -123,19 +125,32 @@ class UsersController < ApplicationController
end end
# end # end
# added by fq # added by huang
def user_courses def user_homeworks
case params[:type]
when "2"
@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
@memberships = [] @memberships = []
@membership.each do |membership| @membership.each do |membership|
if membership.project.project_type == 1 if membership.project.project_type == 1
@membership << membership @memberships << membership
end end
end end
@state = 2 @bid = []
@memberships.each do |membership|
@bid += membership.project.homeworks
end
@bid = @bid.group_by {|bid| bid.courses.first.id}
#add by huang
unless User.current.admin?
if !@user.active?
render_404
return
end
end
end
# added by fq
def user_courses
case params[:type]
when "1" when "1"
@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
@memberships = [] @memberships = []
@ -214,7 +229,7 @@ class UsersController < ApplicationController
when 'xml', 'json' when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15}) @offset, @limit = api_offset_and_limit({:limit => 15})
else else
@limit = 15#per_page_option @limit = 15 #per_page_option
end end
@status = params[:status] || 1 @status = params[:status] || 1

View File

@ -12,7 +12,7 @@ class Bid < ActiveRecord::Base
has_many :homework_for_courses, :dependent => :destroy has_many :homework_for_courses, :dependent => :destroy
has_many :courses, :through => :homework_for_courses, :source => :project has_many :courses, :through => :homework_for_courses, :source => :project
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
acts_as_attachable acts_as_attachable
NAME_LENGTH_LIMIT = 60 NAME_LENGTH_LIMIT = 60
@ -30,11 +30,11 @@ class Bid < ActiveRecord::Base
validate :validate_user validate :validate_user
validate :validate_reward_type validate :validate_reward_type
after_create :act_as_activity after_create :act_as_activity
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
nil nil
} }
scope :like, lambda {|arg| scope :like, lambda {|arg|
if arg.blank? if arg.blank?
where(nil) where(nil)
@ -54,17 +54,15 @@ 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',
'deadline' 'deadline'
# 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
@ -72,7 +70,7 @@ class Bid < ActiveRecord::Base
def self.creat_bids(budget, deadline, name, description=nil, reward_type) def self.creat_bids(budget, deadline, name, description=nil, reward_type)
self.create(:author_id => User.current.id, :budget => budget, self.create(:author_id => User.current.id, :budget => budget,
:deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type) :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 end
def update_bids(budget, deadline, name, description=nil) def update_bids(budget, deadline, name, description=nil)
@ -102,25 +100,24 @@ class Bid < ActiveRecord::Base
def validate_user def validate_user
errors.add :author_id, :invalid if author.nil? || !author.active? errors.add :author_id, :invalid if author.nil? || !author.active?
end end
def validate_reward_type def validate_reward_type
errors.add :reward_type, :invalid if self.reward_type == 0 errors.add :reward_type, :invalid if self.reward_type == 0
end end
def act_as_activity def act_as_activity
self.acts << Activity.new(:user_id => self.author_id) self.acts << Activity.new(:user_id => self.author_id)
end end
# used to validate weather the user is the creater of the bid # used to validate weather the user is the creater of the bid
# added by william # added by william
def validate_bid_manager(user_id) def validate_bid_manager(user_id)
unless user_id.nil? unless user_id.nil?
if self.author_id == user_id if self.author_id == user_id
return true return true
else else
return false return false
end end
end end
end end
end end

View File

@ -7,22 +7,34 @@
<td> <td>
<table width="100%" border="0"> <table width="100%" border="0">
<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') %></strong></td> <td colspan="2" valign="top"><strong><span><%= 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') %></span>
<span style="float: right"><%= 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'
) if (User.current.admin?||User.current.id==bid.author_id)&&(bid.homework_type == 1)%></span></td>
</strong></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) %> <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 %> <%= 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 %>
<% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td> <% 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>

View File

@ -20,7 +20,7 @@
:method => :post, :method => :post,
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:class => 'icon icon-del' :class => 'icon icon-del'
) if @message.destroyable_by?(User.current) %> ) if @bid.destroyable_by?(User.current) %>
</div> </div>
<h3><%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %></h3> <h3><%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %></h3>

View File

@ -47,7 +47,7 @@
<table border="0"> <table border="0">
<tr> <tr>
<td align="cneter"> <td align="cneter">
<%= text_field_tag 'course_password', nil, :style => 'width:200px'%></td> </td>
<%= text_field_tag 'course_password', nil, :size => 45 %> <%= text_field_tag 'course_password', nil, :size => 45 %>

View File

@ -18,7 +18,7 @@
<% else %> <% else %>
<% unless @user != User.current %> <% unless @user != User.current %>
<% if @user.user_extensions.identity == 0 %> <% if @user.user_extensions.identity == 0 %>
<%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %> <p><%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %></p>
<% end %> <% end %>
<% end %> <% end %>
<ul class="user_project_sort"> <ul class="user_project_sort">
@ -49,11 +49,11 @@
<td align="right" > <td align="right" >
<% if membership.roles.sort.collect(&:to_s).join(', ') =='Manager' %> <% if membership.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
Teacher 老师
<% elsif membership.roles.sort.collect(&:to_s).join(', ') =='Reporter' %> <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='Reporter' %>
Student 学生
<% elsif membership.roles.sort.collect(&:to_s).join(', ') =='TA' %> <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='TA' %>
TA 助教
<% end %> <% end %>
</td> </td>
</tr> </tr>

View File

@ -4,7 +4,7 @@
<% @bid.each do |bids|%> <% @bid.each do |bids|%>
<!-- <h2><%= link_to(Project.find(bids[0]).name, project_path(bids[0])) %></h2> --> <!-- <h2><%= link_to(Project.find(bids[0]).name, project_path(bids[0])) %></h2> -->
<% for bid in bids[1] %> <% for bid in bids[1] %>
<% if @user == bid.author %> <% if @user == bid.author %>
<table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;"> <table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
<tr> <tr>
<td colspan="2" valign="top" width="50" ><%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %></td> <td colspan="2" valign="top" width="50" ><%= link_to(image_tag(url_to_avatar(bid.author), :class => 'avatar'), user_path(bid.author), :class => "avatar") %></td>
@ -12,43 +12,51 @@
<table width="100%" border="0"> <table width="100%" border="0">
<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> </span>
<span style="float: right"><%= 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'
) if User.current.admin?||User.current.id==bid.author_id%></span></td>
</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>
<tr> <tr>
<td width="500"> <td><span class="font_lighter"> <% if bid.homework_type == 1%>
<table border="0"> <%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, project_for_bid_path(bid.id) %></strong>)
<tr> <% 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>
<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 %>
</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> </tr>
</table></td> </table></td>
<td width="200" align="right" class="a"><span class="font_lighter"> <%= format_time bid.created_on %></span></td>
</tr> </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> </table>
<% end %> <% end %>
<% end %> <% end %>
<% 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

@ -3,7 +3,7 @@
<% @bid.each do |bids|%> <% @bid.each do |bids|%>
<!-- <h2><%= link_to(Project.find(bids[0]).name, project_path(bids[0])) %></h2> --> <!-- <h2><%= link_to(Project.find(bids[0]).name, project_path(bids[0])) %></h2> -->
<% for bid in bids[1]%> <% for bid in bids[1]%>
<% unless @user == bid.author %> <% unless @user == bid.author %>
<table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;"> <table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
<tr> <tr>
@ -12,9 +12,8 @@
<table width="100%" border="0"> <table width="100%" border="0">
<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

@ -48,11 +48,11 @@
<td align="right" > <td align="right" >
<% if membership.roles.sort.collect(&:to_s).join(', ') =='Manager' %> <% if membership.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
Teacher 老师
<% elsif membership.roles.sort.collect(&:to_s).join(', ') =='Reporter' %> <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='Reporter' %>
Student 学生
<% elsif membership.roles.sort.collect(&:to_s).join(', ') =='TA' %> <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='TA' %>
TA 助教
<% end %> <% end %>
</td> </td>
</tr> </tr>

View File

@ -1,19 +1,8 @@
<!-- added by fq --> <!-- added by fq -->
<!--huang--> <!--huang-->
<%= user_course @state%>
<% if @state == 0 %>
<% if @user.user_extensions.identity == 0 %> <!-- for teacher--> <% if @user.user_extensions.identity == 0 %> <!-- for teacher-->
<%= render :partial => 'my_course' %> <%= render :partial => 'my_course' %>
<% else %> <!--for student--> <% else %> <!--for student-->
<%= render :partial => 'my_joinedcourse' %> <%= render :partial => 'my_joinedcourse' %>
<% end %> <% end %>
<% elsif @state == 1 %>
<% if @user.user_extensions.identity == 0 %>
<%= render :partial => 'my_create_homework' %>
<% else %>
<%= render :partial => 'my_homework' %>
<% end %>
<% else @state == 2 %>
<%= render :partial => 'my_joinedcourse' %>
<% end %>

View File

@ -0,0 +1,9 @@
<!-- added by fq -->
<!--huang-->
<% if @user.user_extensions.identity == 0 %>
<%= render :partial => 'my_create_homework' %>
<% else %>
<%= render :partial => 'my_homework' %>
<% end %>

View File

@ -3,7 +3,7 @@
<% if @bid.size > 0%> <% if @bid.size > 0%>
<% for bid in @bid%> <% for bid in @bid %>
<table width="90%" border="0" align="center" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px; margin-top: 30px;font-size:14px;"> <table width="90%" border="0" align="center" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px; margin-top: 30px;font-size:14px;">
<tr> <tr>

View File

@ -1489,6 +1489,7 @@ zh:
label_welcome_trustie_description: 面向有创意和激情的高校大学生与创业者,提供社交化的项目管理、协同研究、软件开发和众包平台。 label_welcome_trustie_description: 面向有创意和激情的高校大学生与创业者,提供社交化的项目管理、协同研究、软件开发和众包平台。
label_user_project: 项目 label_user_project: 项目
label_user_course: 课程 label_user_course: 课程
label_user_homework: 作业
label_bid_respond_quote: 回复 label_bid_respond_quote: 回复
label_bid_if_agreement: 如果喜欢我,请点击我 label_bid_if_agreement: 如果喜欢我,请点击我
label_bid_respond_delete: 删除 label_bid_respond_delete: 删除
@ -1497,6 +1498,7 @@ zh:
label_newfeedback_delete: 删除 label_newfeedback_delete: 删除
label_user_all_activity: 所有动态 label_user_all_activity: 所有动态
label_user_activity_myself: 只看自己 label_user_activity_myself: 只看自己
label_my_honework_no_homework: 暂无任何作业!
label_user_all_respond: 所有反馈 label_user_all_respond: 所有反馈
label_layouts_feedback: 留言 label_layouts_feedback: 留言
label_welcome_participate: 参与了 label_welcome_participate: 参与了

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'
@ -92,6 +93,7 @@ RedmineApp::Application.routes.draw do
match 'user_watchlist', :to => 'users#user_watchlist', :via => :get, :as => "user_watchlist" #add by huang match 'user_watchlist', :to => 'users#user_watchlist', :via => :get, :as => "user_watchlist" #add by huang
match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang
match 'user_courses', :to => 'users#user_courses', :via => :get match 'user_courses', :to => 'users#user_courses', :via => :get
match 'user_homeworks', :to => 'users#user_homeworks', :via => :get
end end
end end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"

View File

@ -330,8 +330,8 @@ end
Redmine::MenuManager.map :user_menu do |menu| Redmine::MenuManager.map :user_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show' } menu.push :activity, {:controller => 'users', :action => 'show' }
menu.push :user_course, {:controller => 'users', :action => 'user_courses'} menu.push :user_course, {:controller => 'users', :action => 'user_courses'}
menu.push :user_project, {:controller => 'users', :action => 'user_projects'} menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'}
menu.push :user_project, {:controller => 'users', :action => 'user_projects'}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback'} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback'}