summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/users_controller.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index ea8ed69..99e2fc5 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -5,8 +5,14 @@ class UsersController < ApplicationController
before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
+
+ helper_method :sort_column, :sort_descending
def index
+ @users = User.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate(
+ :page => @pagination_page_number,
+ :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE')
+ )
end
def show
@@ -88,4 +94,12 @@ class UsersController < ApplicationController
end
end
+ def sort_descending
+ params[:desc].to_s == 'true'
+ end
+
+ def sort_column
+ User.column_names.include?(params[:sort]) ? params[:sort] : 'id'
+ end
+
end