diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 6b8c03661..8ef719241 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -15,6 +15,7 @@ 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
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index ab05474fe..ccfeccd68 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -7,6 +7,7 @@ class TagsController < ApplicationController
include UsersHelper
include BidsHelper
include ActsAsTaggableOn::TagsHelper
+ helper :projects
$selected_tags = Array.new
$related_tags = Array.new
@@ -21,23 +22,56 @@ class TagsController < ApplicationController
@users_tags_num = User.tag_counts.size
@bids_tags_num = Bid.tag_counts.size
- @issues_results = get_issues_by_tag($selected_tags)
- @projects_results = get_projects_by_tag($selected_tags)
- @users_results = get_users_by_tag($selected_tags)
- @bids_results = get_bids_by_tag($selected_tags)
+ # 这里为了提高系统的响应速度 把搜索结果放到case中去了
+ @users_results = nil
+ @projects_results = nil
+ @issues_results = nil
+ @bids_results = nil
+ @obj_pages = nil
@obj_id = params[:obj_id]
@obj_flag = params[:object_flag]
+ @numbers = Setting.tags_show_search_results
case @obj_flag
when '1' then
+ @users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @users_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @users_results = @users_results.offset(@offset).limit(@limit).all
when '2' then
+ @projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @projects_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all
+
when '3' then
+ @issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @issues_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4'
+ @bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id)
+
+ @offset, @limit = api_offset_and_limit({:limit => @numbers})
+ @project_count = @bids_results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ @bids_results = @bids_results.offset(@offset).limit(@limit).all
+
else
@obj = nil
end
@@ -83,4 +117,12 @@ class TagsController < ApplicationController
end
+ def for_pagination(results)
+ @offset, @limit = api_offset_and_limit({:limit => 2})
+ @project_count = results.count
+ @obj_pages = Paginator.new @project_count, @limit, params['page']
+ @offset ||= @obj_pages.offset
+ results = results.offset(@offset).limit(@limit).order('lft').all
+ end
+
end
diff --git a/app/models/user.rb b/app/models/user.rb
index e27c6a782..ae672b53a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -99,7 +99,9 @@ class User < Principal
acts_as_taggable
scope :by_join_date, order("created_at DESC")
############################# added by liuping 关注
- acts_as_watchable
+ acts_as_watchable
+ has_one :user_extensions
+ ## end
attr_accessor :password, :password_confirmation
attr_accessor :last_before_login_on
diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb
index f70cddad8..47578e66f 100644
--- a/app/models/user_extensions.rb
+++ b/app/models/user_extensions.rb
@@ -1,4 +1,5 @@
class UserExtensions < ActiveRecord::Base
+ belongs_to :user
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code
#this method was used to update the table user_extensions
def update_user_extensions(birthday=nil,brief_introduction=nil,
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 9a75481ad..2143dee68 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -5,8 +5,6 @@
<%= l(:label_my_account)%>
-
-
@@ -70,6 +68,15 @@
<%= render :partial => 'users/preferences' %>
+
+
+
+ <%= l(:label_user_extensions)%>
+
+
+ <%= render :partial => 'users/user_extensions' %>
+
+
<%= submit_tag l(:button_save) %>
<% end %>
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index 4435727fc..8f4852ef5 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -25,7 +25,7 @@
diff --git a/app/views/tags/_related_tags.html.erb b/app/views/tags/_related_tags.html.erb
index 84fb06923..42b3c010f 100644
--- a/app/views/tags/_related_tags.html.erb
+++ b/app/views/tags/_related_tags.html.erb
@@ -1,5 +1,5 @@
<% if related_tags %>
-
+
<% for rt in related_tags %>
<%= link_to image_tag("/images/sidebar/add.png"),:action => "add_tag",:remote => true,:tag => rt,:show_flag => show_flag %>
diff --git a/app/views/tags/_selected_tags.html.erb b/app/views/tags/_selected_tags.html.erb
index f3afa4d8e..78f963744 100644
--- a/app/views/tags/_selected_tags.html.erb
+++ b/app/views/tags/_selected_tags.html.erb
@@ -1,5 +1,5 @@
<% if selected_tags %>
-
+
<% for sg in selected_tags %>
<%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",:remote=>true,:tag => sg,:show_flag => show_flag %>
diff --git a/app/views/tags/_show_bids.html.erb b/app/views/tags/_show_bids.html.erb
index fd46f87f1..4e808829f 100644
--- a/app/views/tags/_show_bids.html.erb
+++ b/app/views/tags/_show_bids.html.erb
@@ -10,4 +10,9 @@
<% end %>
<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/tags/_show_issues.html.erb b/app/views/tags/_show_issues.html.erb
index e29edb305..32654e402 100644
--- a/app/views/tags/_show_issues.html.erb
+++ b/app/views/tags/_show_issues.html.erb
@@ -12,3 +12,8 @@
<% end %>
+
diff --git a/app/views/tags/_show_projects.html.erb b/app/views/tags/_show_projects.html.erb
index aa9f58741..7e706ddde 100644
--- a/app/views/tags/_show_projects.html.erb
+++ b/app/views/tags/_show_projects.html.erb
@@ -11,6 +11,10 @@
<% end %>
-
<% end %>
+
\ No newline at end of file
diff --git a/app/views/tags/_show_users.html.erb b/app/views/tags/_show_users.html.erb
index 7ce8328f7..552b7b6ba 100644
--- a/app/views/tags/_show_users.html.erb
+++ b/app/views/tags/_show_users.html.erb
@@ -11,4 +11,9 @@
<% end %>
<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb
index 8c2c3d90a..123e9ef33 100644
--- a/app/views/tags/_tag.html.erb
+++ b/app/views/tags/_tag.html.erb
@@ -41,7 +41,7 @@
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
:update => "tags_show",
:complete => '$("#put-tag-form").hide();' do |f| %>
- <%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => 25,:minlength=>1 %>
+ <%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit "add"%>
diff --git a/app/views/tags/_tag_search_results.html.erb b/app/views/tags/_tag_search_results.html.erb
index 9e816af8a..bb584c919 100644
--- a/app/views/tags/_tag_search_results.html.erb
+++ b/app/views/tags/_tag_search_results.html.erb
@@ -3,7 +3,7 @@
<% case %>
<% when show_flag == '1' %>
<%=l(:label_user)%>
- <%= render :partial => "show_users",:locals => {:users_results => users_results }%>
+ <%= render :partial => "show_users",:locals => {:users_results => users_results}%>
<% when show_flag == '2'%>
<%=l(:label_project)%>
<%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%>
@@ -12,7 +12,7 @@
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
<% when show_flag == '4'%>
<%= l(:label_requirement)%>
- <%= render :partial => "show_bids",:locals => {:bids_results => bids_results }%>
+ <%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% else %>
<%= l(:label_tags_all_objects)%>
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb
index 4fabfcf09..8e65d92eb 100644
--- a/app/views/tags/index.html.erb
+++ b/app/views/tags/index.html.erb
@@ -1,10 +1,11 @@
<% content_for :sidebar do %>
-
Selected Tags
+
Selected Tags
<%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%>
-
Related Tags
+
+
Related Tags
<%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%>
@@ -13,7 +14,7 @@
<% content_for :content do %>
Search Results
-