summaryrefslogtreecommitdiff
path: root/app/controllers/users_controller.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-06-20 19:06:19 +0200
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-06-20 19:06:19 +0200
commiteb0e1cc5c26275ff3e5c341404e8bc558f8312b8 (patch)
tree71f449ccd6f15422717de3ac24f87d5e888ddd79 /app/controllers/users_controller.rb
parentdf6e17e48995f25e72509986f30700d778b179b6 (diff)
parent3b27a5d45b12f6bac65da2a8e17387bfda42a2f1 (diff)
Merge branch 'develop'
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r--app/controllers/users_controller.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 584d08c..b4ef180 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 = @parent.users.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate(
+ :page => params[:page],
+ :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE')
+ )
end
def show
@@ -22,6 +28,12 @@ class UsersController < ApplicationController
def create
@user = @parent.users.build(params[:user])
if @user.save
+ if VoicemailAccount.where(:name => "user_#{@user.user_name}").count == 0
+ @user.voicemail_accounts.create(:name => "user_#{@user.user_name}", :active => true )
+ else
+ @user.voicemail_accounts.create(:active => true)
+ end
+
if @parent.class == Tenant
@parent.tenant_memberships.create(:user => @user)
if @parent.user_groups.exists?(:name => 'Users')
@@ -82,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