From 4f89e10f2aaeeeb2696f8e456149e8f66e7bb02b Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Mon, 18 Feb 2013 11:19:06 +0100 Subject: change fax spool directory --- app/controllers/trigger_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 2b491be..9a03979 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -1,7 +1,7 @@ class TriggerController < ApplicationController TIFF_FUFFIX = ".tiff" PDF_SUFFIX = ".pdf" - TMP_DIR = "/tmp/" + TMP_DIR = "/var/spool/freeswitch/" def voicemail if !params[:sip_account_id].blank? -- cgit v1.2.3 From 45855989c9f1b9122d57f3328102730b49236432 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 18 Feb 2013 12:11:56 +0100 Subject: indent --- app/controllers/config_snom_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 76fa633..eb94038 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -799,7 +799,7 @@ AAAA' end phone_book_entry.phone_numbers.each do |phone_number| if phone_book_entry.phone_numbers.count > 1 - entry_name = " #{phone_number.name} #{phone_number.number}" + entry_name = "- #{phone_number.name} #{phone_number.number}" else entry_name = "#{phone_book_entry.to_s} #{phone_number.number}" end -- cgit v1.2.3 From 24208a654fe65a2016244f0ebb99af66ed0bd8d7 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 18 Feb 2013 12:13:30 +0100 Subject: received fax documents --- app/controllers/trigger_controller.rb | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 9a03979..7840498 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -1,7 +1,4 @@ class TriggerController < ApplicationController - TIFF_FUFFIX = ".tiff" - PDF_SUFFIX = ".pdf" - TMP_DIR = "/var/spool/freeswitch/" def voicemail if !params[:sip_account_id].blank? @@ -68,25 +65,9 @@ class TriggerController < ApplicationController if fax_account fax_account.fax_documents.where(:state => 'received').each do |fax_document| - tiff_file = File.basename(fax_document.tiff.to_s) + pdf_file, tiff_file = fax_document.tiff_to_pdf.blank? - if !File.exists?( "#{TMP_DIR}#{tiff_file}" ) - fax_document.state = 'unsuccessful' - fax_document.save - next - end - - paper_size = "letter" - pdf_file = "#{TMP_DIR}#{File.basename(tiff_file, TIFF_FUFFIX)}#{PDF_SUFFIX}" - - system "tiff2pdf \\ - -o \"#{pdf_file}\" \\ - -p #{paper_size} \\ - -a \"#{fax_document.remote_station_id}\" \\ - -c \"AMOOMA Gemeinschaft version #{GsParameter.get('GEMEINSCHAFT_VERSION')}\" \\ - -t \"#{fax_document.remote_station_id}\" \"#{TMP_DIR}#{tiff_file}\"" - - if !File.exists?( pdf_file ) + if !pdf_file fax_document.state = 'unsuccessful' fax_document.save next @@ -98,14 +79,14 @@ class TriggerController < ApplicationController if fax_document.save Notifications.new_fax(fax_document).deliver begin - File.delete("#{TMP_DIR}#{tiff_file}"); + File.delete(tiff_file) rescue => e - logger.error "Raw fax file could not be deleted: #{TMP_DIR}#{tiff_file} => #{e.inspect}" + logger.error "Raw fax file could not be deleted: #{tiff_file} => #{e.inspect}" end begin - File.delete(pdf_file); + File.delete(pdf_file) rescue => e - logger.error "PDF fax file could not be deleted: #{TMP_DIR}#{pdf_file} => #{e.inspect}" + logger.error "PDF fax file could not be deleted: #{pdf_file} => #{e.inspect}" end fax_document.tiff = nil fax_document.save -- cgit v1.2.3 From e0bd56db83104a2a38e88af2eadaefd389aa798b Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 18 Feb 2013 13:17:16 +0100 Subject: result fixed --- app/controllers/trigger_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 7840498..136c3d0 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -65,7 +65,7 @@ class TriggerController < ApplicationController if fax_account fax_account.fax_documents.where(:state => 'received').each do |fax_document| - pdf_file, tiff_file = fax_document.tiff_to_pdf.blank? + pdf_file, tiff_file = fax_document.tiff_to_pdf if !pdf_file fax_document.state = 'unsuccessful' -- cgit v1.2.3 From 2b3892ac24bb61c4814e0afe141bf53765fb1e4b Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 19 Feb 2013 13:16:12 +0100 Subject: fax storage directory --- app/controllers/trigger_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 136c3d0..894c18b 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -65,7 +65,7 @@ class TriggerController < ApplicationController if fax_account fax_account.fax_documents.where(:state => 'received').each do |fax_document| - pdf_file, tiff_file = fax_document.tiff_to_pdf + pdf_file = fax_document.tiff_to_pdf if !pdf_file fax_document.state = 'unsuccessful' -- cgit v1.2.3 From 22d581aa38ae4e015c654356fb61d110456e69ee Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 19 Feb 2013 14:05:11 +0100 Subject: preserve tiff file --- app/controllers/trigger_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 894c18b..64a5f91 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -73,16 +73,17 @@ class TriggerController < ApplicationController next end + working_path, tiff_file = File.split(fax_document.tiff) + if fax_document.store_dir != working_path + FileUtils.mkdir(fax_document.store_dir) + FileUtils.mv(fax_document.tiff, fax_document.store_dir) + fax_document.tiff = "#{fax_document.store_dir}/#{tiff_file}" + end + fax_document.document = File.open(pdf_file) fax_document.state = 'successful' if fax_document.save - Notifications.new_fax(fax_document).deliver - begin - File.delete(tiff_file) - rescue => e - logger.error "Raw fax file could not be deleted: #{tiff_file} => #{e.inspect}" - end begin File.delete(pdf_file) rescue => e -- cgit v1.2.3 From 4715082b46073d7ca4108b1093d2304eb5999e1b Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 19 Feb 2013 14:09:11 +0100 Subject: tiff download --- app/controllers/fax_documents_controller.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/fax_documents_controller.rb b/app/controllers/fax_documents_controller.rb index 5653683..c2b3083 100644 --- a/app/controllers/fax_documents_controller.rb +++ b/app/controllers/fax_documents_controller.rb @@ -31,6 +31,24 @@ class FaxDocumentsController < ApplicationController ) end } + format.tiff { + caller_number = @fax_document.caller_id_number.to_s.gsub(/[^0-9]/, '') + if caller_number.blank? + caller_number = 'anonymous' + end + + if @fax_document.tiff + send_file @fax_document.tiff, :type => "image/tiff", + :filename => "#{@fax_document.created_at.strftime('%Y%m%d-%H%M%S')}-#{caller_number}.tiff" + else + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + end + } end end -- cgit v1.2.3 From 2a9b798f9e122582abb36605a7d4a1da0e70eca9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 22 Feb 2013 07:08:23 -0500 Subject: pickup group permission model added --- app/controllers/group_memberships_controller.rb | 51 +++++++++++++++++++++++++ app/controllers/group_permissions_controller.rb | 48 +++++++++++++++++++++++ app/controllers/groups_controller.rb | 49 ++++++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 app/controllers/group_memberships_controller.rb create mode 100644 app/controllers/group_permissions_controller.rb create mode 100644 app/controllers/groups_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/group_memberships_controller.rb b/app/controllers/group_memberships_controller.rb new file mode 100644 index 0000000..df9f6b3 --- /dev/null +++ b/app/controllers/group_memberships_controller.rb @@ -0,0 +1,51 @@ +class GroupMembershipsController < ApplicationController + load_and_authorize_resource :group + load_and_authorize_resource :group_membership, :through => [:group] + + def index + end + + def show + end + + def new + end + + def create + if params[:group_membership][:item_type].blank? + params[:group_membership][:item_type] = @group.group_memberships.first.item_type + end + @group_membership = @group.group_memberships.new(params[:group_membership]) + if @group_membership.save + redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_created') + else + render :new + end + end + + def edit + end + + def update + if @group_membership.update_attributes(params[:group_membership]) + redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @group_membership.destroy + redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_destroyed') + end + + private + def spread_breadcrumbs + add_breadcrumb t("groups.index.page_title"), groups_path + add_breadcrumb @group, group_path(@group) + add_breadcrumb t("group_memberships.index.page_title"), group_group_memberships_path(@group) + if @group_membership && !@group_membership.new_record? + add_breadcrumb @group_membership, group_group_membership_path(@group, @group_membership) + end + end +end diff --git a/app/controllers/group_permissions_controller.rb b/app/controllers/group_permissions_controller.rb new file mode 100644 index 0000000..3abdc51 --- /dev/null +++ b/app/controllers/group_permissions_controller.rb @@ -0,0 +1,48 @@ +class GroupPermissionsController < ApplicationController + load_and_authorize_resource :group + load_and_authorize_resource :group_permission, :through => [:group] + + def index + end + + def show + end + + def new + end + + def create + @group_permission = @group.group_permissions.new(params[:group_permission]) + if @group_permission.save + redirect_to action: "index", :notice => t('group_permissions.controller.successfuly_created') + else + render :new + end + end + + def edit + end + + def update + if @group_permission.update_attributes(params[:group_permission]) + redirect_to action: "index", :notice => t('group_permissions.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @group_permission.destroy + redirect_to action: "index", :notice => t('group_permissions.controller.successfuly_destroyed') + end + + private + def spread_breadcrumbs + add_breadcrumb t("groups.index.page_title"), groups_path + add_breadcrumb @group, group_path(@group) + add_breadcrumb t("group_permissions.index.page_title"), group_group_permissions_path(@group) + if @group_permission && !@group_permission.new_record? + add_breadcrumb @group_permission, group_group_permission_path(@group, @group_permission) + end + end +end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb new file mode 100644 index 0000000..1ab7a4f --- /dev/null +++ b/app/controllers/groups_controller.rb @@ -0,0 +1,49 @@ +class GroupsController < ApplicationController + def index + @groups = Group.all + end + + def show + @group = Group.find(params[:id]) + end + + def new + @group = Group.new + end + + def create + @group = Group.new(params[:group]) + if @group.save + redirect_to @group, :notice => t('groups.controller.successfuly_created') + else + render :new + end + end + + def edit + @group = Group.find(params[:id]) + end + + def update + @group = Group.find(params[:id]) + if @group.update_attributes(params[:group]) + redirect_to @group, :notice => t('groups.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @group = Group.find(params[:id]) + @group.destroy + redirect_to groups_url, :notice => t('groups.controller.successfuly_destroyed') + end + + private + def spread_breadcrumbs + add_breadcrumb t("groups.index.page_title"), groups_path + if @group && !@group.new_record? + add_breadcrumb @group, @group + end + end +end -- cgit v1.2.3 From 0eb056b92e9eaf091146c13dcb3fdc9d7fb34baf Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 22 Feb 2013 13:08:46 -0500 Subject: breadcrumbs --- app/controllers/group_memberships_controller.rb | 2 ++ app/controllers/group_permissions_controller.rb | 2 ++ app/controllers/groups_controller.rb | 3 +++ 3 files changed, 7 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/group_memberships_controller.rb b/app/controllers/group_memberships_controller.rb index df9f6b3..e0f897b 100644 --- a/app/controllers/group_memberships_controller.rb +++ b/app/controllers/group_memberships_controller.rb @@ -2,6 +2,8 @@ class GroupMembershipsController < ApplicationController load_and_authorize_resource :group load_and_authorize_resource :group_membership, :through => [:group] + before_filter :spread_breadcrumbs + def index end diff --git a/app/controllers/group_permissions_controller.rb b/app/controllers/group_permissions_controller.rb index 3abdc51..dda800e 100644 --- a/app/controllers/group_permissions_controller.rb +++ b/app/controllers/group_permissions_controller.rb @@ -2,6 +2,8 @@ class GroupPermissionsController < ApplicationController load_and_authorize_resource :group load_and_authorize_resource :group_permission, :through => [:group] + before_filter :spread_breadcrumbs + def index end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 1ab7a4f..74ad7c8 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,4 +1,7 @@ class GroupsController < ApplicationController + load_and_authorize_resource :group + before_filter :spread_breadcrumbs + def index @groups = Group.all end -- cgit v1.2.3 From 3404cb248f32951aaf0508cfcfc87bfad533c6e5 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 23 Feb 2013 01:25:13 -0500 Subject: set target_group=group on new --- app/controllers/group_permissions_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/group_permissions_controller.rb b/app/controllers/group_permissions_controller.rb index dda800e..b6517b1 100644 --- a/app/controllers/group_permissions_controller.rb +++ b/app/controllers/group_permissions_controller.rb @@ -11,6 +11,7 @@ class GroupPermissionsController < ApplicationController end def new + @group_permission.target_group_id = @group_permission.group_id end def create -- cgit v1.2.3 From 0442cd19bc9383669b506185356227361a16e442 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 09:29:40 -0500 Subject: call_forwards - polymorphism added --- app/controllers/call_forwards_controller.rb | 58 +++++++++++++++++++--------- app/controllers/config_siemens_controller.rb | 4 +- 2 files changed, 41 insertions(+), 21 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb index b1ced87..cd72a38 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -1,7 +1,9 @@ class CallForwardsController < ApplicationController - load_and_authorize_resource :phone_number - load_and_authorize_resource :call_forward, :through => [:phone_number] + load_resource :phone_number + load_resource :sip_account + load_and_authorize_resource :call_forward, :through => [:phone_number, :sip_account] + before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs class CallForwardingDestination @@ -20,7 +22,7 @@ class CallForwardsController < ApplicationController end def new - @call_forward = @phone_number.call_forwards.build + @call_forward = @parent.call_forwards.build @call_forward.depth = GsParameter.get('DEFAULT_CALL_FORWARD_DEPTH') @call_forward.active = true @call_forwarding_destinations = call_forwarding_destination_types() @@ -33,7 +35,7 @@ class CallForwardsController < ApplicationController end end - if @phone_number.call_forwards.where( + if @parent.call_forwards.where( :call_forward_case_id => CallForwardCase.find_by_value('noanswer').id, :active => true ).count == 0 @@ -43,10 +45,11 @@ class CallForwardsController < ApplicationController end def create - @call_forward = @phone_number.call_forwards.build( params[:call_forward] ) + @call_forward = @parent.call_forwards.build( params[:call_forward] ) if @call_forward.save - redirect_to phone_number_call_forward_path( @phone_number, @call_forward ), :notice => t('call_forwards.controller.successfuly_created') + m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) + redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_created') else @available_call_forward_cases = CallForwardCase.all render :new @@ -61,7 +64,8 @@ class CallForwardsController < ApplicationController def update @available_call_forward_cases = CallForwardCase.all if @call_forward.update_attributes(params[:call_forward]) - redirect_to phone_number_call_forward_path( @phone_number, @call_forward ), :notice => t('call_forwards.controller.successfuly_updated') + m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) + redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_updated') else @call_forwarding_destinations = call_forwarding_destination_types() render :edit @@ -70,30 +74,46 @@ class CallForwardsController < ApplicationController def destroy @call_forward.destroy - redirect_to phone_number_call_forwards_path( @phone_number ), :notice => t('call_forwards.controller.successfuly_destroyed') + redirect_to :root, :notice => t('call_forwards.controller.successfuly_destroyed') end private + private + def set_and_authorize_parent + @parent = @sip_account || @phone_number + authorize! :read, @parent + end + def spread_breadcrumbs - if @phone_number && @phone_number.phone_numberable_type == 'SipAccount' - @sip_account = @phone_number.phone_numberable + if @parent + if @parent.class == PhoneNumber && @parent.phone_numberable_type == 'SipAccount' + @sip_account = @parent.phone_numberable + end if @sip_account.sip_accountable_type == 'User' - @user = @phone_number.phone_numberable.sip_accountable - add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant) - add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user) - add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user) - add_breadcrumb @sip_account, user_sip_account_path(@user, @sip_account) + @user = @sip_account.sip_accountable + if @parent.class == PhoneNumber + add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant) + add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user) + add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user) + add_breadcrumb @sip_account, user_sip_account_path(@user, @sip_account) + add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account) + add_breadcrumb @parent, sip_account_phone_number_path(@sip_account, @parent) + elsif @parent.class == SipAccount + add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant) + add_breadcrumb @user, tenant_users_path(@user.current_tenant, @user) + add_breadcrumb t("sip_accounts.index.page_title"), user_sip_accounts_path(@user) + end end if @sip_account.sip_accountable_type == 'Tenant' @tenant = @sip_account.sip_accountable add_breadcrumb t("sip_accounts.index.page_title"), tenant_sip_accounts_path(@tenant) add_breadcrumb @sip_account, tenant_sip_account_path(@tenant, @sip_account) end - add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account) - add_breadcrumb @phone_number, sip_account_phone_number_path(@sip_account, @phone_number) - add_breadcrumb t("call_forwards.index.page_title"), phone_number_call_forwards_path(@phone_number) + + add_breadcrumb t("call_forwards.index.page_title"), phone_number_call_forwards_path(@parent) if @call_forward && !@call_forward.new_record? - add_breadcrumb @call_forward, phone_number_call_forward_path(@phone_number, @call_forward) + m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) + add_breadcrumb @call_forward, m.(@parent, @call_forward) end end end diff --git a/app/controllers/config_siemens_controller.rb b/app/controllers/config_siemens_controller.rb index bbeba46..1966d49 100644 --- a/app/controllers/config_siemens_controller.rb +++ b/app/controllers/config_siemens_controller.rb @@ -1068,8 +1068,8 @@ class ConfigSiemensController < ApplicationController phone_numbers.push(phone_number.number) assistant_call_forwardings = phone_number.call_forwards.where(:call_forward_case_id => CallForwardCase.where(:value => 'assistant').first.id) assistant_call_forwardings.each do |assistant_call_forwarding| - if assistant_call_forwarding.call_forwardable_type == 'HuntGroup' && assistant_call_forwarding.call_forwardable_id.to_i > 0 - hunt_groups.push(assistant_call_forwarding.call_forwardable_id.to_i) + if assistant_call_forwarding.destinationable_type == 'HuntGroup' && assistant_call_forwarding.destinationable_id.to_i > 0 + hunt_groups.push(assistant_call_forwarding.destinationable_id.to_i) end end end -- cgit v1.2.3 From fd07b7b85d2d40d7d2999c2899cc890eda2095fd Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:41:55 -0500 Subject: more polymorphic objects --- app/controllers/call_forwards_controller.rb | 14 ++++++++------ app/controllers/ringtones_controller.rb | 11 ++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb index cd72a38..34fb77a 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -48,8 +48,8 @@ class CallForwardsController < ApplicationController @call_forward = @parent.call_forwards.build( params[:call_forward] ) if @call_forward.save - m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) - redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_created') + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_created') else @available_call_forward_cases = CallForwardCase.all render :new @@ -64,8 +64,8 @@ class CallForwardsController < ApplicationController def update @available_call_forward_cases = CallForwardCase.all if @call_forward.update_attributes(params[:call_forward]) - m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) - redirect_to m.( @parent, @call_forward ), :notice => t('call_forwards.controller.successfuly_updated') + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_updated') else @call_forwarding_destinations = call_forwarding_destination_types() render :edit @@ -74,7 +74,8 @@ class CallForwardsController < ApplicationController def destroy @call_forward.destroy - redirect_to :root, :notice => t('call_forwards.controller.successfuly_destroyed') + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_destroyed') end private @@ -110,7 +111,8 @@ class CallForwardsController < ApplicationController add_breadcrumb @sip_account, tenant_sip_account_path(@tenant, @sip_account) end - add_breadcrumb t("call_forwards.index.page_title"), phone_number_call_forwards_path(@parent) + m = method( :"#{@parent.class.name.underscore}_call_forwards_url" ) + add_breadcrumb t("call_forwards.index.page_title"), m.(@parent) if @call_forward && !@call_forward.new_record? m = method( :"#{@parent.class.name.underscore}_call_forward_path" ) add_breadcrumb @call_forward, m.(@parent, @call_forward) diff --git a/app/controllers/ringtones_controller.rb b/app/controllers/ringtones_controller.rb index 7ffe30e..f726650 100644 --- a/app/controllers/ringtones_controller.rb +++ b/app/controllers/ringtones_controller.rb @@ -1,7 +1,8 @@ class RingtonesController < ApplicationController load_resource :phone_number + load_resource :sip_account load_resource :boss_assistant_cooperation - load_and_authorize_resource :ringtone, :through => [:phone_number, :boss_assistant_cooperation] + load_and_authorize_resource :ringtone, :through => [:phone_number, :sip_account, :boss_assistant_cooperation] before_filter :set_parent before_filter :spread_breadcrumbs @@ -19,7 +20,7 @@ class RingtonesController < ApplicationController def create @ringtone = @parent.ringtones.build(params[:ringtone]) if @ringtone.save - redirect_to phone_number_ringtone_path(@parent, @ringtone), :notice => t('ringtones.controller.successfuly_created') + redirect_to method( :"#{@parent.class.name.underscore}_ringtones_url" ).(@parent), :notice => t('ringtones.controller.successfuly_created') else render :new end @@ -30,7 +31,7 @@ class RingtonesController < ApplicationController def update if @ringtone.update_attributes(params[:ringtone]) - redirect_to method( :"#{@parent.class.name.underscore}_ringtone_path" ).(@ringtone.ringtoneable, @ringtone), :notice => t('ringtones.controller.successfuly_updated') + redirect_to method( :"#{@parent.class.name.underscore}_ringtones_url" ).(@parent), :notice => t('ringtones.controller.successfuly_updated') else render :edit end @@ -38,12 +39,12 @@ class RingtonesController < ApplicationController def destroy @ringtone.destroy - redirect_to phone_number_ringtones_path(@parent), :notice => t('ringtones.controller.successfuly_destroyed') + redirect_to method( :"#{@parent.class.name.underscore}_ringtones_url" ).(@parent), :notice => t('ringtones.controller.successfuly_destroyed') end private def set_parent - @parent = @phone_number || @boss_assistant_cooperation + @parent = @phone_number || @boss_assistant_cooperation || @sip_account end def spread_breadcrumbs -- cgit v1.2.3 From dca264b22845b7875b9493c17cc185e809372cc1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:58:20 -0500 Subject: use dialplan ringtone as default --- app/controllers/ringtones_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/ringtones_controller.rb b/app/controllers/ringtones_controller.rb index f726650..e5a4f64 100644 --- a/app/controllers/ringtones_controller.rb +++ b/app/controllers/ringtones_controller.rb @@ -15,6 +15,7 @@ class RingtonesController < ApplicationController def new @ringtone = @parent.ringtones.build + @ringtone.bellcore_id = GsParameter.get('default_ringtone', 'dialplan', 'parameters') end def create -- cgit v1.2.3 From 387ce8f6694b41ab73d264190ce41dcd13484ede Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 18:03:42 -0500 Subject: icons --- app/controllers/intruders_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb index 147e06d..99cb023 100644 --- a/app/controllers/intruders_controller.rb +++ b/app/controllers/intruders_controller.rb @@ -1,6 +1,6 @@ class IntrudersController < ApplicationController def index - @intruders = Intruder.all + @intruders = Intruder.order('list_type ASC, contact_last DESC').all spread_breadcrumbs end -- cgit v1.2.3 From ad2121462a9ea9a776756a188779a9d504f078b7 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 18:11:50 -0500 Subject: authorization added --- app/controllers/intruders_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb index 99cb023..d3c767e 100644 --- a/app/controllers/intruders_controller.rb +++ b/app/controllers/intruders_controller.rb @@ -1,4 +1,6 @@ class IntrudersController < ApplicationController + load_and_authorize_resource :intruder + def index @intruders = Intruder.order('list_type ASC, contact_last DESC').all spread_breadcrumbs -- cgit v1.2.3 From ffaa80e8d46b3b6b7597af6f157724005f48bae4 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 26 Feb 2013 10:48:08 +0100 Subject: RestoreJob scaffold --- app/controllers/restore_jobs_controller.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/controllers/restore_jobs_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/restore_jobs_controller.rb b/app/controllers/restore_jobs_controller.rb new file mode 100644 index 0000000..1cccdc1 --- /dev/null +++ b/app/controllers/restore_jobs_controller.rb @@ -0,0 +1,24 @@ +class RestoreJobsController < ApplicationController + skip_before_filter :start_setup_if_new_installation, :only => [:new, :create, :show, :index] + + load_and_authorize_resource :restore_job + + def index + end + + def show + end + + def new + end + + def create + @restore_job.state = 'new' + + if @restore_job.save + redirect_to @restore_job, :notice => t('restore_jobs.controller.successfuly_created') + else + render :new + end + end +end -- cgit v1.2.3 From 36919fb419a40688daa97e36734f579488cb56e2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 26 Feb 2013 14:06:27 +0100 Subject: Restore and Backup fixes. --- app/controllers/restore_jobs_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers') diff --git a/app/controllers/restore_jobs_controller.rb b/app/controllers/restore_jobs_controller.rb index 1cccdc1..bfecc33 100644 --- a/app/controllers/restore_jobs_controller.rb +++ b/app/controllers/restore_jobs_controller.rb @@ -16,6 +16,7 @@ class RestoreJobsController < ApplicationController @restore_job.state = 'new' if @restore_job.save + session[:user_id] = nil redirect_to @restore_job, :notice => t('restore_jobs.controller.successfuly_created') else render :new -- cgit v1.2.3 From 0a976c6b463288df4a9516bbd08f6232a37d427c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Feb 2013 09:21:34 -0500 Subject: enable tel: handling for sip_accounts --- app/controllers/sip_accounts_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index b5c3ae4..2886c8b 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -10,6 +10,7 @@ class SipAccountsController < ApplicationController end def show + @register_tel_protocol = "#{request.protocol}#{request.host_with_port}/sip_accounts/#{@sip_account.try(:id)}/call?url=%s" end def new @@ -74,6 +75,10 @@ class SipAccountsController < ApplicationController redirect_to :root, :notice => t('sip_accounts.controller.successfuly_destroyed') end + def call + redirect_to(:back) + end + private def set_and_authorize_parent @parent = @user || @tenant -- cgit v1.2.3 From 0399b856c75b842f43bc5380f9c19a64c6418f11 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Feb 2013 10:00:36 -0500 Subject: call action added --- app/controllers/sip_accounts_controller.rb | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 2886c8b..022858c 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -1,6 +1,7 @@ class SipAccountsController < ApplicationController load_resource :user load_resource :tenant + #load_resource :sip_account load_and_authorize_resource :sip_account, :through => [:user, :tenant ] before_filter :set_and_authorize_parent @@ -76,7 +77,33 @@ class SipAccountsController < ApplicationController end def call - redirect_to(:back) + if !params[:url].blank? + protocol, separator, phone_number = params[:url].partition(':') + if ! phone_number.blank? + @sip_account.call(phone_number) + render( + :status => 200, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return; + end + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return; + end + + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) end private -- cgit v1.2.3 From df0bc9db9cdbf9bfbc92a5f1f00e57fc0e7d7792 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 26 Feb 2013 16:17:06 +0100 Subject: Search box in the top navigation bar. --- app/controllers/page_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb index ed48e3c..10ecf2c 100644 --- a/app/controllers/page_controller.rb +++ b/app/controllers/page_controller.rb @@ -7,6 +7,8 @@ class PageController < ApplicationController def index if current_user redirect_to [current_user.current_tenant, current_user] + else + redirect_to log_in_path end end -- cgit v1.2.3 From fc535da83c53f37fbc03caf72f61c01494ba6048 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 26 Feb 2013 17:31:13 +0100 Subject: load_resource :sip_account, :only => [:call] --- app/controllers/sip_accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 022858c..ef1aab8 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -1,7 +1,7 @@ class SipAccountsController < ApplicationController load_resource :user load_resource :tenant - #load_resource :sip_account + load_resource :sip_account, :only => [:call] load_and_authorize_resource :sip_account, :through => [:user, :tenant ] before_filter :set_and_authorize_parent -- cgit v1.2.3 From 41e17e9f3e184975e8b429d3fb06d822c49068bf Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 27 Feb 2013 10:43:17 +0100 Subject: load_and_authorize_resource :sip_account, :only => [:call] #213 --- app/controllers/sip_accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index ef1aab8..621bd3c 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -1,7 +1,7 @@ class SipAccountsController < ApplicationController load_resource :user load_resource :tenant - load_resource :sip_account, :only => [:call] + load_and_authorize_resource :sip_account, :only => [:call] load_and_authorize_resource :sip_account, :through => [:user, :tenant ] before_filter :set_and_authorize_parent -- cgit v1.2.3 From ed0117210837dd1d0d2dbf403799b70225caf0cd Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Feb 2013 06:04:50 -0500 Subject: calls views added --- app/controllers/calls_controller.rb | 54 ++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/calls_controller.rb b/app/controllers/calls_controller.rb index d5f3b42..5534b1b 100644 --- a/app/controllers/calls_controller.rb +++ b/app/controllers/calls_controller.rb @@ -1,6 +1,58 @@ class CallsController < ApplicationController + load_resource :sip_account + load_resource :call + before_filter :set_and_authorize_parent + def index - @calls = Call.all + if @parent + @calls = @parent.calls + else + @calls = Call.all + end + end + + def new + if !params[:url].blank? + protocol, separator, phone_number = params[:url].partition(':') + if ! phone_number.blank? + @call = @parent.calls.new() + @call.dest = phone_number + end + elsif !params[:number].blank? + @call = @parent.calls.new() + @call.dest = params[:number] + end + end + + def show + redirect_to :index + end + + def create + params[:call][:sip_account] = @sip_account + @call = Call.create(params[:call]) + + if @call && @call.call + m = method( :"#{@parent.class.name.underscore}_calls_url" ) + redirect_to m.( @parent ), :notice => t('calls.controller.successfuly_created') + else + render :new + end + end + + def destroy + @call.destroy + if @parent + m = method( :"#{@parent.class.name.underscore}_calls_url" ) + else + m = method( :"calls_url" ) + end + redirect_to m.(@parent), :notice => t('calls.controller.successfuly_destroyed') + end + + private + def set_and_authorize_parent + @parent = @sip_account end end -- cgit v1.2.3