From dcbaf1c02b7bf3bf8ea36176bb793cb6da3cbbc5 Mon Sep 17 00:00:00 2001 From: william Date: Mon, 23 Sep 2013 20:12:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 95 +++++++++------------------ app/helpers/bids_helper.rb | 9 +++ app/models/bid.rb | 16 ++++- app/models/biding_project.rb | 18 ++++- app/views/bids/_form.html.erb | 3 + app/views/bids/_history.html.erb | 8 ++- app/views/bids/_new_bid.html.erb | 1 + app/views/bids/_project_list.html.erb | 60 ++++++----------- app/views/bids/index.html.erb | 1 - app/views/bids/show.html.erb | 22 +++++-- app/views/bids/show_project.html.erb | 14 ++-- app/views/projects/index.html.erb | 1 + app/views/projects/show.html.erb | 13 +++- app/views/tags/_tag.html.erb | 2 +- config/locales/zh.yml | 15 ++++- config/routes.rb | 12 +++- db/schema.rb | 58 ++++++++++++++-- lib/redmine.rb | 2 + 18 files changed, 220 insertions(+), 130 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index e5af4ac85..64373760e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -2,10 +2,11 @@ class BidsController < ApplicationController #Added by young menu_item :respond - menu_item :project, :only => :show_project + menu_item :project, :only => [:show_project,:show_results] #Ended by young - before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add, :new] - + before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results] + before_filter :require_login,:only => [:set_reward] + helper :watchers def index # Modified by nie @@ -17,13 +18,6 @@ class BidsController < ApplicationController @bid_pages = Paginator.new @bid_count, @limit, params['page'] @offset ||= @bid_pages.reverse_offset - #@bids = @bids.offset(@offset).limit(@limit).all.reverse - # unless @offset == 0 - # @bids = @bids.offset(@offset).limit(@limit).all.reverse - # else - # limit = @bid_count % @limit - # @bids = @bids.offset(@offset).limit(limit).all.reverse - # end #added by nie if params[:bid_sort_type].present? case params[:bid_sort_type] @@ -58,20 +52,6 @@ class BidsController < ApplicationController end end #end - # @limit = api_offset_and_limit({:limit => 5}) - # @bids = Bid.visible - # @bids = @bids.like(params[:name]) if params[:name].present? - # @bid_count = @bids.count - # @bid_pages = Paginator.new @bid_count, @limit, params['page'] - # @offset ||= @bid_pages.reverse_offset - # #@bids = @bids.offset(@offset).limit(@limit).all.reverse - # unless @offset == 0 - # @bids = @bid_count.offset(@offset).limit(@limit).all.reverse - # else - # limit = @bid_count%@limit - # @bids = @bid_count.offset(@offset).limit(limit).all.reverse - # end - # #end end def show @@ -84,9 +64,6 @@ class BidsController < ApplicationController @jour = @jours[@offset, @limit] @state = false - # - # @journals = @bid.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all - # @journals.each_with_index {|j,i| j.indice = i+1} respond_to do |format| format.html { render :layout => 'base_bids' @@ -147,12 +124,6 @@ class BidsController < ApplicationController end refer_user_id = params[:bid_message][:reference_user_id].to_i @bid.add_jour(User.current, message, refer_user_id) - # if a_message.size > 5 - # @message = a_message[-5, 5] - # else - # @message = a_message - # end - # @message_count = a_message.count end @user = @bid.author @jours = @bid.journals_for_messages.reverse @@ -221,37 +192,6 @@ class BidsController < ApplicationController def new_bid @bid = Bid.new @bid.safe_attributes = params[:bid] - # if params[:bid_title] - # # if params[:bid_budget].to_s =~ /^(\d+)$|^(\d+).([0-9]{2})$/ - # unless params[:bid_reward_type] == "0" - # if params[:bid_deadline].to_s =~ /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/ - # bid = Bid.creat_bids(params[:bid_budget], params[:bid_deadline], params[:bid_title] , params[:bid_description], params[:bid_reward_type].to_i) - # unless bid.watched_by?(User.current) - # if bid.add_watcher(User.current) - # flash[:notice] = l(:label_bid_succeed) - # end - # end - # else - # flash[:error] = l(:label_wrong_date) - # end - # else - # flash[:error] = "wrong" - # end - # # else - # # flash[:error] = l(:label_wrong_budget) - # # end - # end - # @limit = 5 - # @bid_count = Bid.count - # @bid_pages = Paginator.new @bid_count, @limit, params['page'] - # @offset ||= @bid_pages.offset - # @bids = Bid.offset(@offset).limit(@limit).all - # respond_to do |format| - # # format.html - # format.html { redirect_to :back } - # format.js - # # format.api { render_api_ok } - # end end def create_bid @@ -300,6 +240,33 @@ class BidsController < ApplicationController end end + #added by william + #used to set the bidding project reward + def set_reward + @b_p = nil + @biding_project_id = nil + + if params[:set_reward][:reward] + # @bid_id = params[:id] + @biding_project_id = params[:set_reward][:b_id] + @b_p = BidingProject.find_by_id(@biding_project_id) + + # 把字段存进表中 + @b_p.update_reward(params[:set_reward][:reward].to_s) + end + + respond_to do |format| + format.js + end + end + + + # added by william + # used to manage the bid and end the bid + def manage + + end + private def find_bid diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index 784a11379..f1c0ca35e 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -1,5 +1,8 @@ +#enconding:utf-8 # fq module BidsHelper + + def render_notes(bid, journal, options={}) content = '' removable = User.current == journal.user || User.current == bid.author @@ -37,4 +40,10 @@ module BidsHelper Bid.tagged_with(tag_name).order('updated_on desc') end + # used to get the reward and handle the value which can be used to display in views + # added by william + def get_prize(b_project) + b_project.get_reward + end + end \ No newline at end of file diff --git a/app/models/bid.rb b/app/models/bid.rb index ef51e9589..5821fb0c1 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -18,7 +18,8 @@ class Bid < ActiveRecord::Base # validates_presence_of :deadline, :message => 'test' # validates_format_of :deadline, :with => validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/ - validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/, :if => Proc.new { |p| p.reward_type == 1 } + validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/, + :if => Proc.new { |p| p.reward_type == 1 } validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{1})$/, :if => Proc.new { |p| p.reward_type == 3 } validate :validate_user validate :validate_reward_type @@ -99,4 +100,17 @@ class Bid < ActiveRecord::Base def act_as_activity self.acts << Activity.new(:user_id => self.author_id) end + + # used to validate weather the user is the creater of the bid + # 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 + end + end + end diff --git a/app/models/biding_project.rb b/app/models/biding_project.rb index 4b6c2b6c3..cc9c1fba2 100644 --- a/app/models/biding_project.rb +++ b/app/models/biding_project.rb @@ -1,6 +1,6 @@ ## fq class BidingProject < ActiveRecord::Base - attr_accessible :bid_id, :project_id, :user_id, :description + attr_accessible :bid_id, :project_id, :user_id, :description,:reward belongs_to :bid belongs_to :project @@ -20,6 +20,18 @@ class BidingProject < ActiveRecord::Base :project_id => project_id, :description => description) end + # used to update the reward ,the value varies from 0,1,2,3,4,5 + # added by william + def update_reward(which) + self.update_attribute(:reward,which) + end + + # return the reward,the value is a type of string + # added by william + def get_reward + self.reward + end + def cancel_bidding unless self.nil? if User.current.id == self.user_id @@ -41,5 +53,7 @@ class BidingProject < ActiveRecord::Base def validate_project errors.add :project_id, :invalid if project.nil? end - + end + + diff --git a/app/views/bids/_form.html.erb b/app/views/bids/_form.html.erb index da3e3b35b..3f9d66998 100644 --- a/app/views/bids/_form.html.erb +++ b/app/views/bids/_form.html.erb @@ -29,6 +29,9 @@

<%= select_tag 'bid_reward_type', "".html_safe, :onChange => "show('bid_reward_type', 'bid_budget', '"+l(:label_bids_reward_what)+"','"+l(:label_bids_new_money)+"','"+l(:label_bids_new_credit)+"','"+l(:label_bids_new_content)+"')" %> <%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %> + + +

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('bid_deadline')%>

\ No newline at end of file diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb index 21115cdb8..ad246f6a5 100644 --- a/app/views/bids/_history.html.erb +++ b/app/views/bids/_history.html.erb @@ -1,4 +1,10 @@ - + + + diff --git a/app/views/bids/_new_bid.html.erb b/app/views/bids/_new_bid.html.erb index 50bad5360..afce79577 100644 --- a/app/views/bids/_new_bid.html.erb +++ b/app/views/bids/_new_bid.html.erb @@ -74,6 +74,7 @@ border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 30p
<%=l(:label_user_response)%>
+ diff --git a/app/views/bids/_project_list.html.erb b/app/views/bids/_project_list.html.erb index 2be061612..b06585baa 100644 --- a/app/views/bids/_project_list.html.erb +++ b/app/views/bids/_project_list.html.erb @@ -1,51 +1,33 @@ <%= render_flash_messages %> -
<%= submit_tag l(:button_new_bid), :name => nil , :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%>
+ + + +<% if @bid.deadline > Date.today %> + +
+ <% if User.current.logged? %> <% end %> +
<%= l(:label_bidding_project) %>(<%= @bidding_project.count%>)
<%= toggle_link l(:button_bidding), 'put-bid-form' %>
-<% @bidding_project.each do |b_project|%> - - - - -
- - - - - - -
-
- <%= link_to image_tag(url_to_avatar(b_project.project), :class => 'avatar3'), :class => "avatar" %> -
- - - - - - - - - - - -
<%= link_to(b_project.project.name, project_path(b_project.project)) %><%= l(:label_join_bidding)%>
<%= b_project.project.description %>
<%= b_project.created_at%>
-
- - - - - - - -
<%= l(:label_bidding_user) %><%= link_to(b_project.user.name, user_path(b_project.user)) %>
<%= l(:label_bidding_reason) %><%= b_project.description %>
-
+ <% else %> + +
+ <%= l(:label_bid_end)%> +
+
+ + <% end %> + + + +<%= render :partial=> "list_projects",:locals => {:bidding_project => @bidding_project,:bid => @bid }%> + diff --git a/app/views/bids/index.html.erb b/app/views/bids/index.html.erb index 091ef31c2..b9ec2c13d 100644 --- a/app/views/bids/index.html.erb +++ b/app/views/bids/index.html.erb @@ -12,7 +12,6 @@ <% end %> - - - - +
<%= render :partial => 'history', :locals => { :bid => @bid, :journals => @jour, :state => false} %>
@@ -44,7 +52,7 @@ diff --git a/app/views/bids/show_project.html.erb b/app/views/bids/show_project.html.erb index ba0b99283..9dc4172bf 100644 --- a/app/views/bids/show_project.html.erb +++ b/app/views/bids/show_project.html.erb @@ -57,6 +57,7 @@ <% if User.current.logged? %> + diff --git a/config/locales/zh.yml b/config/locales/zh.yml index e2991260f..339aa1bb0 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1353,4 +1353,17 @@ zh: label_projects_feedback_respond: 回复 label_projects_feedback_respond_success: 回复成功 button_projects_feedback_respond: 回复 - label_projects_feedback_respond_content: 请输入回复内容 \ No newline at end of file + label_projects_feedback_respond_content: 请输入回复内容 + +# added by william + label_bidding_results: 应标结果 + label_bid_end: 该需求已经结束! + label_special_reward: 特等奖 + label_first_reward: 一等奖 + label_second_reward: 二等奖 + label_third_reward: 三等奖 + label_excellence_reward: 优秀奖 + label_comfort_reward: 入围奖 + + + diff --git a/config/routes.rb b/config/routes.rb index 39139473a..86e3deaca 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,12 +12,13 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software +# along with this program; if not, write tobthe Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do resources :shares + #added by william get "tags/index" get "tags/show" @@ -25,6 +26,7 @@ RedmineApp::Application.routes.draw do get "praise_tread/praise_plus" get "praise_tread/tread_plus" + #end root :to => 'welcome#index', :as => 'home' @@ -122,7 +124,6 @@ RedmineApp::Application.routes.draw do post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue' delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue' - resources :projects do member do get 'settings(/:tab)', :action => 'settings', :as => 'settings' @@ -445,6 +446,13 @@ RedmineApp::Application.routes.draw do match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' match 'calls/create_bid', :to => 'bids#create_bid' match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post + match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post] + + #added by william + # match 'calls/:id/set_results',:controller => 'bids', :action => 'set_results',:via => [:get,:post],:as => 'set_results' + # match 'calls/:id/set_prizes',:controller => 'bids',:action => 'set_prizes',:as => 'set_prizes' + match 'calls/:id/set_reward',:controller => 'bids',:action => 'set_reward',:as => 'set_reward' + ## 测试用 # match 'test/index', :controller => 'test', :action => 'index' # added by young diff --git a/db/schema.rb b/db/schema.rb index ddd0ce85c..b8ca66994 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130828080407) do +ActiveRecord::Schema.define(:version => 20130918004629) do create_table "a_user_watchers", :force => true do |t| t.string "name" @@ -77,18 +77,20 @@ ActiveRecord::Schema.define(:version => 20130828080407) do t.string "description" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "reward" end create_table "bids", :force => true do |t| t.string "name" - t.string "budget", :null => false + t.string "budget", :null => false t.integer "author_id" t.date "deadline" t.string "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false t.integer "commit" t.integer "reward_type" + t.integer "homework_type" end create_table "boards", :force => true do |t| @@ -161,6 +163,20 @@ ActiveRecord::Schema.define(:version => 20130828080407) do add_index "comments", ["author_id"], :name => "index_comments_on_author_id" add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + create_table "courses", :force => true do |t| + t.integer "tea_id" + t.string "name" + t.integer "state" + t.string "code" + t.integer "time" + t.string "extra" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "location" + t.string "term" + t.string "string" + end + create_table "custom_fields", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -246,6 +262,18 @@ ActiveRecord::Schema.define(:version => 20130828080407) do add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + create_table "homework_attaches", :force => true do |t| + t.integer "bid_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_for_courses", :force => true do |t| + t.integer "project_id" + t.integer "bid_id" + end + create_table "issue_categories", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -476,6 +504,9 @@ ActiveRecord::Schema.define(:version => 20130828080407) do t.integer "project_id" end + add_index "project_statuses", ["changesets_count"], :name => "index_project_statuses_on_changesets_count" + add_index "project_statuses", ["watchers_count"], :name => "index_project_statuses_on_watchers_count" + create_table "project_tags", :force => true do |t| t.integer "project_id" t.integer "tag_id" @@ -578,6 +609,13 @@ ActiveRecord::Schema.define(:version => 20130828080407) do t.datetime "updated_at", :null => false end + create_table "students_for_courses", :force => true do |t| + t.integer "student_id" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" @@ -595,6 +633,16 @@ ActiveRecord::Schema.define(:version => 20130828080407) do t.string "name" end + create_table "teachers", :force => true do |t| + t.string "tea_name" + t.string "location" + t.integer "couurse_time" + t.integer "course_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "extra" + end + create_table "time_entries", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false @@ -645,6 +693,8 @@ ActiveRecord::Schema.define(:version => 20130828080407) do t.integer "zip_code" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "identity" + t.string "technical_title" end create_table "user_preferences", :force => true do |t| diff --git a/lib/redmine.rb b/lib/redmine.rb index 8da5b5336..e8ac1c486 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -218,6 +218,8 @@ end Redmine::MenuManager.map :bid_menu do |menu| menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response menu.push :project, { :controller => 'bids', :action => 'show_project' }, :caption => :label_bidding_project + # menu.push :result, { :controller => 'bids', :action => 'show_results' }, + # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } end Redmine::MenuManager.map :application_menu do |menu| # Empty From 09fb972c96d1e37d30e5185bac02015a6bd26417 Mon Sep 17 00:00:00 2001 From: william Date: Tue, 24 Sep 2013 09:05:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=86=E6=94=AF=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/bids_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index f1c0ca35e..68462fcc9 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -45,5 +45,4 @@ module BidsHelper def get_prize(b_project) b_project.get_reward end - end \ No newline at end of file