diff --git a/app/models/project.rb b/app/models/project.rb index eec60cdde..c64dd5060 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 4196b3030..40e142e92 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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) diff --git a/app/views/users/search.html.erb b/app/views/users/search.html.erb index 0349ebcab..5596acd96 100644 --- a/app/views/users/search.html.erb +++ b/app/views/users/search.html.erb @@ -20,7 +20,7 @@ <%= text_field_tag 'name', params[:name], :size => 30 %> - <%= submit_tag l(:label_search), :class => "small", :name => nil %> + <%= submit_tag l(:label_search), :class => "small", :name => nil %> <% end %>   @@ -66,75 +66,54 @@ <% html_title(l(:label_user_plural)) -%> <% else %> - +
<%= l(:label_user_plural)%> <%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %> -
- - - -
- <% for user in @users -%> - <% unless user.id == 1%> -
- - <%= 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"%> - -
- <%= image_tag(url_to_avatar(user), :class => 'avatar') %> - <%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %> -
-
- <%= l(:label_has_fans,:count=>user.watcher_users.count)%> - <%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %> -
+ <% if @users.size > 0 %> + <% @users.each do |user| -%> + <% unless user.id == 1%> +
+ <%= 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"%> +
+ <%= image_tag(url_to_avatar(user), :class => 'avatar') %> + <%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %> +
+
+ <%= l(:label_has_fans,:count=>user.watcher_users.count)%> + <%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %> +
<% 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)}" %>
- <% end -%> - <% end -%> + <% end -%> + <% end -%> + <% else %> +
如果没有搜到希望的结果,请清除用户姓和名之间的空格,或者重新输入搜索关键词!
+ <% end %>
<% html_title(l(:label_user_plural)) -%> <% end -%>