summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJan-Willem van der Meer <mail@jewilmeer.nl>2014-10-13 17:07:53 +0200
committerJan-Willem van der Meer <mail@jewilmeer.nl>2014-10-13 17:07:53 +0200
commit6c0994a3b3197fe177ac804b0cd25096ff478263 (patch)
tree978e407ffcedf5a14737c1826160103c7a5619fa /app
parente1cf9c15eb38cd830a52de41b9c242add0b76767 (diff)
parent05fca6bfc2d045e7e144baec28a6596e618ecb4b (diff)
downloadgitlab-ce-6c0994a3b3197fe177ac804b0cd25096ff478263.tar.gz
Merge remote-tracking branch 'origin/master' into feature-multiple-ldap-servers
Conflicts: app/controllers/omniauth_callbacks_controller.rb
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/users_controller.rb1
-rw-r--r--app/finders/snippets_finder.rb22
-rw-r--r--app/models/user.rb10
-rw-r--r--app/views/admin/users/index.html.haml20
4 files changed, 42 insertions, 11 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index f63df27eebd..baad9095b70 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -4,6 +4,7 @@ class Admin::UsersController < Admin::ApplicationController
def index
@users = User.filter(params[:filter])
@users = @users.search(params[:name]) if params[:name].present?
+ @users = @users.sort(@sort = params[:sort])
@users = @users.alphabetically.page(params[:page])
end
diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb
index fda375aca2f..b29ab6cf40b 100644
--- a/app/finders/snippets_finder.rb
+++ b/app/finders/snippets_finder.rb
@@ -30,18 +30,18 @@ class SnippetsFinder
snippets = user.snippets.fresh.non_expired
if user == current_user
- snippets = case scope
- when 'are_internal' then
- snippets.are_internal
- when 'are_private' then
- snippets.are_private
- when 'are_public' then
- snippets.are_public
- else
- snippets
- end
+ case scope
+ when 'are_internal' then
+ snippets.are_internal
+ when 'are_private' then
+ snippets.are_private
+ when 'are_public' then
+ snippets.are_public
+ else
+ snippets
+ end
else
- snippets = snippets.public_and_internal
+ snippets.public_and_internal
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 5abaa5495bc..42faea0070e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -195,6 +195,16 @@ class User < ActiveRecord::Base
end
end
+ def sort(method)
+ case method.to_s
+ when 'recent_sign_in' then reorder('users.last_sign_in_at DESC')
+ when 'oldest_sign_in' then reorder('users.last_sign_in_at ASC')
+ when 'recently_created' then reorder('users.created_at DESC')
+ when 'late_created' then reorder('users.created_at ASC')
+ else reorder("users.name ASC")
+ end
+ end
+
def find_for_commit(email, name)
# Prefer email match over name match
User.where(email: email).first ||
diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml
index 5c2664e14fe..92c619738a2 100644
--- a/app/views/admin/users/index.html.haml
+++ b/app/views/admin/users/index.html.haml
@@ -32,6 +32,26 @@
.panel-heading
Users (#{@users.total_count})
.panel-head-actions
+ .dropdown.inline
+ %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
+ %span.light sort:
+ - if @sort.present?
+ = @sort.humanize
+ - else
+ Name
+ %b.caret
+ %ul.dropdown-menu
+ %li
+ = link_to admin_users_path(sort: nil) do
+ Name
+ = link_to admin_users_path(sort: 'recent_sign_in') do
+ Recent sign in
+ = link_to admin_users_path(sort: 'oldest_sign_in') do
+ Oldest sign in
+ = link_to admin_users_path(sort: 'recently_created') do
+ Recently created
+ = link_to admin_users_path(sort: 'late_created') do
+ Late created
= link_to 'New User', new_admin_user_path, class: "btn btn-new"
%ul.well-list
- @users.each do |user|