Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorrandx <dmitriy.zaporozhets@gmail.com>2012-06-21 20:05:09 +0400
committerrandx <dmitriy.zaporozhets@gmail.com>2012-06-21 20:05:09 +0400
commit1903f6ade027df0f10ef96b9439495eeda07482c (patch)
treef2b99b34c1dd3232281191dfb64e7f807d5dcf57 /app
parent98a45ce6ee50ced19a22e6a9153bb778de8fa001 (diff)
admin area -> search for users
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/users_controller.rb1
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/admin/users/index.html.haml3
3 files changed, 8 insertions, 0 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index bbb1990c8a7..79838665336 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -6,6 +6,7 @@ class Admin::UsersController < ApplicationController
def index
@admin_users = User.scoped
@admin_users = @admin_users.filter(params[:filter])
+ @admin_users = @admin_users.search(params[:name]) if params[:name].present?
@admin_users = @admin_users.order("updated_at DESC").page(params[:page])
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 50854bf9e50..69d5ec71e68 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -83,6 +83,10 @@ class User < ActiveRecord::Base
)
end
end
+
+ def self.search query
+ where("name like :query or email like :query", :query => "%#{query}%")
+ end
end
# == Schema Information
#
diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml
index ea7b3130917..481bf37bb0b 100644
--- a/app/views/admin/users/index.html.haml
+++ b/app/views/admin/users/index.html.haml
@@ -3,6 +3,9 @@
= link_to 'New User', new_admin_user_path, :class => "btn small right"
%br
+= form_tag admin_users_path, :method => :get do
+ = text_field_tag :name, params[:name], :class => "xlarge"
+ = submit_tag "Search", :class => "btn submit primary"
%ul.nav.nav-pills
%li{:class => "#{'active' unless params[:filter]}"}
= link_to "Active", admin_users_path