优化用户搜索
This commit is contained in:
parent
8f216a6723
commit
dd6563cf8c
|
@ -67,9 +67,6 @@ class Project < ActiveRecord::Base
|
|||
#ADDED BY NIE
|
||||
has_many :project_infos, :dependent => :destroy
|
||||
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
|
||||
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
|
||||
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
|
||||
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
|
||||
has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy
|
||||
#end
|
||||
|
||||
|
|
|
@ -152,6 +152,15 @@ class User < Principal
|
|||
}
|
||||
scope :sorted, lambda { order(*User.fields_for_order_statement)}
|
||||
|
||||
scope :like, lambda {|arg|
|
||||
if arg.blank?
|
||||
where(nil)
|
||||
else
|
||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||
where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern)
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
###添加留言 fq
|
||||
def add_jour(user, notes, reference_user_id = 0)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
<label for='name'><%= l(:label_user) %>:</label>
|
||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||
<%= submit_tag l(:label_search), :class => "small", :name => nil %><!--Modified by young-->
|
||||
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
@ -66,75 +66,54 @@
|
|||
<% html_title(l(:label_user_plural)) -%>
|
||||
|
||||
<% else %>
|
||||
<!-- <div class="contextual">
|
||||
<%= link_to l(:label_user_new), new_user_path, :class => 'icon icon-add' %>
|
||||
</div> -->
|
||||
|
||||
<div class="project-search-block">
|
||||
<span><%= l(:label_user_plural)%></span>
|
||||
|
||||
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
|
||||
<!-- <fieldset>
|
||||
<legend>
|
||||
<%= l(:label_filter_plural) %>
|
||||
</legend> -->
|
||||
<div class="project-search">
|
||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||
<%= submit_tag l(:label_search), :class => "small", :name => nil %><!--Modified by young-->
|
||||
<!-- </fieldset> -->
|
||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="pagination" style="border-bottom: 1px solid rgb(223,223,223); width: 95%; margin-left: 2%; margin-top: 0px">
|
||||
<ul style="margin-right:0px">
|
||||
<li>
|
||||
<%= link_to l(:label_sort_by_time), users_path(:user_sort_type => '0') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to l(:label_sort_by_active), users_path(:user_sort_type => '1') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to l(:label_sort_by_influence), users_path(:user_sort_type => '2') %>
|
||||
</li>
|
||||
</ul>
|
||||
</div> -->
|
||||
|
||||
|
||||
<div class="autoscroll">
|
||||
<% for user in @users -%>
|
||||
<% unless user.id == 1%>
|
||||
<div class="well">
|
||||
|
||||
<%= content_tag "p", "#{format_date(user.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||
<%= image_tag "/images/time_member.png", :class => "img_member_time"%>
|
||||
<!-- <%= get_avatar?(user) ? (link_to image_tag(avatar_image(user), :class => 'avatar'), user_path(user), :class => "avatar") : (link_to image_tag("/images/12_50.png", :class => 'avatar'), user_path(user), :class => "avatar") %> -->
|
||||
<div>
|
||||
<%= image_tag(url_to_avatar(user), :class => 'avatar') %>
|
||||
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
|
||||
</div>
|
||||
<div style="margin-top: 20px;margin-left:66px">
|
||||
<%= l(:label_has_fans,:count=>user.watcher_users.count)%>
|
||||
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
|
||||
</div>
|
||||
<% if @users.size > 0 %>
|
||||
<% @users.each do |user| -%>
|
||||
<% unless user.id == 1%>
|
||||
<div class="well">
|
||||
<%= content_tag "p", "#{format_date(user.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||
<%= image_tag "/images/time_member.png", :class => "img_member_time"%>
|
||||
<div>
|
||||
<%= image_tag(url_to_avatar(user), :class => 'avatar') %>
|
||||
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
|
||||
</div>
|
||||
<div style="margin-top: 20px;margin-left:66px">
|
||||
<%= l(:label_has_fans,:count=>user.watcher_users.count)%>
|
||||
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
|
||||
</div>
|
||||
|
||||
<div class="user-bottom">
|
||||
<% unless user.memberships.empty? %>
|
||||
<%= l(:label_contribute_to, :project_count => "#{user.memberships.count}") %>
|
||||
<%= l(:label_contribute_to, :project_count => "#{user.memberships.count}") %>
|
||||
<% for member in user.memberships %>
|
||||
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %>
|
||||
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= user.changesets.count == 0 ? '' : ",#{l(:label_total_commit, :total_commit => user.changesets.count)}" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% else %>
|
||||
<div style="width: 400px; height: 60px; margin-left: 22px;color:#6c5524; background-color: #FFD9BF; vertical-align: center;">如果没有搜到希望的结果,请清除用户姓和名之间的空格,或者重新输入搜索关键词!</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @user_pages, @user_count %>
|
||||
<ul>
|
||||
<ul>
|
||||
</div>
|
||||
<% html_title(l(:label_user_plural)) -%>
|
||||
<% end -%>
|
||||
|
|
Loading…
Reference in New Issue