From a634e8b158dac11250181d7cae35a08afbea96d4 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:31:08 +0100 Subject: create voicemail account for newly crested users --- app/controllers/users_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/controllers/users_controller.rb') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 584d08c..ea8ed69 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -22,6 +22,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') -- cgit v1.2.3 From 9d9bf18ab11aa67e967b09f774af5c651f6064ce Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:11:02 +0200 Subject: pagination and sorting added --- app/controllers/users_controller.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/controllers/users_controller.rb') 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 -- cgit v1.2.3 From f7ecf4866953cbfb0bc2a092b8547192f2943242 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:40:13 +0200 Subject: list users of specified parent only --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/users_controller.rb') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 99e2fc5..971ce4b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -9,7 +9,7 @@ class UsersController < ApplicationController helper_method :sort_column, :sort_descending def index - @users = User.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + @users = @parent.users.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) -- cgit v1.2.3 From 2e4a23d6d51ee564386c1bf2b0df8d9869cc3b7c Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 13 May 2013 09:51:39 +0200 Subject: pagination fixed --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/users_controller.rb') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 971ce4b..b4ef180 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,7 +10,7 @@ class UsersController < ApplicationController def index @users = @parent.users.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( - :page => @pagination_page_number, + :page => params[:page], :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) end -- cgit v1.2.3