diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 64f139c31..e5af4ac85 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -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] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index cc4fda9fe..e8b25b338 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cf31d33a9..04e0b5f2b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e99ff4eee..5204788cf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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)) diff --git a/app/views/bids/index.html.erb b/app/views/bids/index.html.erb index 32ab5e1b1..091ef31c2 100644 --- a/app/views/bids/index.html.erb +++ b/app/views/bids/index.html.erb @@ -28,6 +28,21 @@ <% end %> + + +
<%= render :partial => 'bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
diff --git a/db/migrate/20130828080407_add_index_to_user_statuses.rb b/db/migrate/20130828080407_add_index_to_user_statuses.rb new file mode 100644 index 000000000..842eff453 --- /dev/null +++ b/db/migrate/20130828080407_add_index_to_user_statuses.rb @@ -0,0 +1,6 @@ +class AddIndexToUserStatuses < ActiveRecord::Migration + def change + add_index :user_statuses, :changesets_count + add_index :user_statuses, :watchers_count + end +end diff --git a/db/schema.rb b/db/schema.rb index bc3ecca3c..ddd0ce85c 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 => 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" diff --git a/public/images/avatars/Project/6408 b/public/images/avatars/Project/6408 new file mode 100644 index 000000000..bf740e537 Binary files /dev/null and b/public/images/avatars/Project/6408 differ