增加需求描述

This commit is contained in:
nieguanghui 2013-08-28 20:16:40 +08:00
parent 574362dcf6
commit 03415891f5
8 changed files with 126 additions and 58 deletions

View File

@ -15,15 +15,49 @@ class BidsController < ApplicationController
@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 = @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]
when '0'
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
when '1'
unless @offset == 0
@bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
@bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
end
when '2'
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
end
else
limit = @bid_count % @limit
@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
end
#end
# @limit = api_offset_and_limit({:limit => 5})
# @bids = Bid.visible
# @bids = @bids.like(params[:name]) if params[:name].present?
@ -187,39 +221,39 @@ 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
# 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
@bid = Bid.new
@bid.name = params[:bid][:name]

View File

@ -113,6 +113,9 @@ class ProjectsController < ApplicationController
@projects = @projects.offset(@offset).limit(@limit).all.reverse
else
limit = @project_count % @limit
if limit == 0
limit = @limit
end
@projects = @projects.offset(@offset).limit(limit).all.reverse
end
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
@ -123,6 +126,9 @@ class ProjectsController < ApplicationController
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(@limit).all.reverse
else
limit = @project_count % @limit
if limit == 0
limit = @limit
end
@projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(limit).all.reverse
end
@ -133,6 +139,9 @@ class ProjectsController < ApplicationController
@projects = @projects.includes(:project_status).reorder('project_statuses.watchers_count').offset(@offset).limit(@limit).all.reverse
else
limit = @project_count % @limit
if limit == 0
limit = @limit
end
@projects = @projects.includes(:project_status).reorder('project_statuses.watchers_count').offset(@offset).limit(limit).all.reverse
end
end
@ -142,6 +151,9 @@ class ProjectsController < ApplicationController
@projects = @projects.offset(@offset).limit(@limit).all.reverse
else
limit = @project_count % @limit
if limit == 0
limit = @limit
end
@projects = @projects.offset(@offset).limit(limit).all.reverse
end
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }

View File

@ -174,6 +174,9 @@ class UsersController < ApplicationController
@users = scope.offset(@offset).limit(@limit).all.reverse
else
limit = @user_count % @limit
if limit == 0
limit = @limit
end
@users = scope.offset(@offset).limit(limit).all.reverse
end
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
@ -184,6 +187,9 @@ class UsersController < ApplicationController
@users = scope.includes(:user_status).reorder('user_statuses.changesets_count').offset(@offset).limit(@limit).all.reverse
else
limit = @user_count % @limit
if limit == 0
limit = @limit
end
@users = scope.includes(:user_status).reorder('user_statuses.changesets_count').offset(@offset).limit(limit).all.reverse
end
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
@ -194,6 +200,9 @@ class UsersController < ApplicationController
@users = scope.includes(:user_status).reorder('user_statuses.watchers_count').offset(@offset).limit(@limit).all.reverse
else
limit = @user_count % @limit
if limit == 0
limit = @limit
end
@users = scope.includes(:user_status).reorder('user_statuses.watchers_count').offset(@offset).limit(limit).all.reverse
end
#@users = @users[@offset, @limit]
@ -204,6 +213,9 @@ class UsersController < ApplicationController
@users = scope.offset(@offset).limit(@limit).all.reverse
else
limit = @user_count % @limit
if limit == 0
limit = @limit
end
@users = scope.offset(@offset).limit(limit).all.reverse
end
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }

View File

@ -219,7 +219,8 @@ module ApplicationHelper
if projects.any?
ancestors = []
original_project = @project
projects.sort_by(&:lft).each do |project|
#modified by nie
projects.each do |project|
# set the project environment to please macros.
@project = project
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))

View File

@ -28,6 +28,21 @@
</div>
<% end %>
<div class="pagination" style="border-bottom: 1px solid rgb(223,223,223); width: 95%; margin-left: 2%; margin-top: 15px" >
<ul style="margin-right:0px">
<li>
<%= link_to l(:label_sort_by_time), calls_path(:bid_sort_type => '0') %>
</li>
<li>
<%= link_to l(:label_sort_by_active), calls_path(:bid_sort_type => '1') %>
</li>
<!-- <li>
<%= link_to l(:label_sort_by_influence), calls_path(:bid_sort_type => '2') %>
</li> -->
</ul>
</div>
<div id="bid-show">
<%= render :partial => 'bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
</div>

View File

@ -0,0 +1,6 @@
class AddIndexToUserStatuses < ActiveRecord::Migration
def change
add_index :user_statuses, :changesets_count
add_index :user_statuses, :watchers_count
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130828004955) do
ActiveRecord::Schema.define(:version => 20130828080407) do
create_table "a_user_watchers", :force => true do |t|
t.string "name"
@ -445,23 +445,6 @@ ActiveRecord::Schema.define(:version => 20130828004955) do
t.string "salt", :null => false
end
create_table "permissions", :force => true do |t|
t.string "controller", :limit => 30, :default => "", :null => false
t.string "action", :limit => 30, :default => "", :null => false
t.string "description", :limit => 60, :default => "", :null => false
t.boolean "is_public", :default => false, :null => false
t.integer "sort", :default => 0, :null => false
t.boolean "mail_option", :default => false, :null => false
t.boolean "mail_enabled", :default => false, :null => false
end
create_table "permissions_roles", :id => false, :force => true do |t|
t.integer "permission_id", :default => 0, :null => false
t.integer "role_id", :default => 0, :null => false
end
add_index "permissions_roles", ["role_id"], :name => "permissions_roles_role_id"
create_table "praise_tread_caches", :force => true do |t|
t.integer "object_id", :null => false
t.string "object_type"
@ -515,6 +498,7 @@ ActiveRecord::Schema.define(:version => 20130828004955) do
t.integer "lft"
t.integer "rgt"
t.boolean "inherit_members", :default => false, :null => false
t.integer "project_type"
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"
@ -581,10 +565,11 @@ ActiveRecord::Schema.define(:version => 20130828004955) do
t.string "title"
t.string "share_type"
t.string "url"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "project_id"
t.integer "user_id"
t.string "description"
end
create_table "students", :force => true do |t|
@ -679,6 +664,9 @@ ActiveRecord::Schema.define(:version => 20130828004955) do
t.datetime "updated_at", :null => false
end
add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count"
add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count"
create_table "user_tags", :force => true do |t|
t.integer "user_id"
t.integer "tag_id"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB