diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index e3cc685a7..1042c8809 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -24,7 +24,7 @@ class BidsController < ApplicationController # elsif # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) else - @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 1, 2) + @bids = Bid.visible.where('reward_type = ?', 1) end @bids = @bids.like(params[:name]) if params[:name].present? @@ -76,6 +76,64 @@ class BidsController < ApplicationController #end end + def contest + @project_type = params[:project_type] + # Modified by nie + # @requirement_title = "4" + @offset, @limit = api_offset_and_limit({:limit => 10}) + + @bids = Bid.visible.where('reward_type = ?', 2) + + # elsif + # @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'] + + @offset ||= @bid_pages.reverse_offset + #added by nie + if params[:bid_sort_type].present? + case params[:bid_sort_type] + when '0' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(limit).all.reverse + end + @s_state = 0 + when '1' + 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 + when '2' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + end + @s_state = 0 + 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 + end + end + def fork @courses = [] @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @@ -307,6 +365,36 @@ class BidsController < ApplicationController @bid = Bid.new @bid.safe_attributes = params[:bid] end + + #huang + def create_contest + @bid = Bid.new + @bid.name = params[:bid][:name] + @bid.description = params[:bid][:description] + @bid.reward_type = params[:bid_reward_type] + @bid.budget = params[:bid][:budget] + @bid.deadline = params[:bid][:deadline] + @bid.author_id = User.current.id + @bid.commit = 0 + if @bid.save + unless @bid.watched_by?(User.current) + if @bid.add_watcher(User.current) + flash[:notice] = l(:label_bid_succeed) + end + end + redirect_to respond_path(@bid) + else + @bid.safe_attributes = params[:bid] + render :action => 'new_bid' + end + end + + + #huang + def new_contest + @bid = Bid.new + @bid.safe_attributes = params[:bid] + end def create_bid @bid = Bid.new diff --git a/app/views/bids/_form.html.erb b/app/views/bids/_form.html.erb index 4b1530714..70fec0960 100644 --- a/app/views/bids/_form.html.erb +++ b/app/views/bids/_form.html.erb @@ -1,5 +1,5 @@ - +<% else %> - <%= error_messages_for 'bid' %>
<%= l(:label_bids_form_new_description) %>
@@ -34,4 +33,5 @@<%= 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/_form_contest.html.erb b/app/views/bids/_form_contest.html.erb new file mode 100644 index 000000000..d41f4f880 --- /dev/null +++ b/app/views/bids/_form_contest.html.erb @@ -0,0 +1,34 @@ + + +<%= error_messages_for 'bid' %> + +<%= l(:label_bids_form_contest_new_description) %>
+<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_name)}" %>
+ +<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_description)}" %>
+<%= 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')%>
diff --git a/app/views/bids/contest.html.erb b/app/views/bids/contest.html.erb new file mode 100644 index 000000000..c5a97f0b9 --- /dev/null +++ b/app/views/bids/contest.html.erb @@ -0,0 +1,53 @@ + +<%= form_tag(calls_path, :method => :get) do %> ++ 竞赛列表 + | +<% if User.current.logged? %> + + + <%= link_to(l(:label_newtype_contest), {:controller => 'bids', :action => 'new_contest'}, :class => 'icon icon-add') %> + + + <% end %> | + +
+
+ <%= text_field_tag 'name', params[:name], :size => 30 %>
+
+ <%= submit_tag l(:label_search), :class => "small", :name => nil %>
+
+ |
+
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> | +<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: + <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> + <%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> | |||||
diff --git a/app/views/users/_my_homework.html.erb b/app/views/users/_my_homework.html.erb index e00e84691..5ffdffba4 100644 --- a/app/views/users/_my_homework.html.erb +++ b/app/views/users/_my_homework.html.erb @@ -11,7 +11,10 @@ |
|