summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/call_forwards_controller.rb48
-rw-r--r--app/controllers/calls_controller.rb24
-rw-r--r--app/controllers/conference_invitees_controller.rb2
-rw-r--r--app/controllers/fax_documents_controller.rb10
-rw-r--r--app/controllers/groups_controller.rb2
-rw-r--r--app/controllers/gs_parameters_controller.rb12
-rw-r--r--app/controllers/intruders_controller.rb3
-rw-r--r--app/controllers/softkeys_controller.rb8
-rw-r--r--app/controllers/trigger_controller.rb18
9 files changed, 83 insertions, 44 deletions
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index 34fb77a..b30ee9e 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -1,7 +1,10 @@
class CallForwardsController < ApplicationController
load_resource :phone_number
load_resource :sip_account
- load_and_authorize_resource :call_forward, :through => [:phone_number, :sip_account]
+ load_resource :automatic_call_distributor
+ load_resource :hunt_group
+
+ load_and_authorize_resource :call_forward, :through => [:phone_number, :sip_account, :automatic_call_distributor, :hunt_group]
before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
@@ -81,7 +84,7 @@ class CallForwardsController < ApplicationController
private
private
def set_and_authorize_parent
- @parent = @sip_account || @phone_number
+ @parent = @phone_number || @sip_account || @automatic_call_distributor || @hunt_group
authorize! :read, @parent
end
@@ -90,27 +93,30 @@ class CallForwardsController < ApplicationController
if @parent.class == PhoneNumber && @parent.phone_numberable_type == 'SipAccount'
@sip_account = @parent.phone_numberable
end
- if @sip_account.sip_accountable_type == 'User'
- @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)
+
+ if @sip_account
+ if @sip_account.sip_accountable_type == 'User'
+ @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
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
-
+
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?
diff --git a/app/controllers/calls_controller.rb b/app/controllers/calls_controller.rb
index 5534b1b..9d85a10 100644
--- a/app/controllers/calls_controller.rb
+++ b/app/controllers/calls_controller.rb
@@ -3,6 +3,7 @@ class CallsController < ApplicationController
load_resource :call
before_filter :set_and_authorize_parent
+ before_filter :spread_breadcrumbs
def index
if @parent
@@ -17,11 +18,11 @@ class CallsController < ApplicationController
protocol, separator, phone_number = params[:url].partition(':')
if ! phone_number.blank?
@call = @parent.calls.new()
- @call.dest = phone_number
+ @call.destination = phone_number
end
elsif !params[:number].blank?
@call = @parent.calls.new()
- @call.dest = params[:number]
+ @call.destination = params[:number]
end
end
@@ -30,8 +31,7 @@ class CallsController < ApplicationController
end
def create
- params[:call][:sip_account] = @sip_account
- @call = Call.create(params[:call])
+ @call = @sip_account.calls.create(params[:call])
if @call && @call.call
m = method( :"#{@parent.class.name.underscore}_calls_url" )
@@ -55,4 +55,20 @@ class CallsController < ApplicationController
def set_and_authorize_parent
@parent = @sip_account
end
+
+ def spread_breadcrumbs
+ if @parent.class == SipAccount
+ if @sip_account.sip_accountable.class == User
+ add_breadcrumb t('users.name'), tenant_users_path(@sip_account.sip_accountable.current_tenant)
+ add_breadcrumb @sip_account.sip_accountable, tenant_user_path(@sip_account.sip_accountable.current_tenant, @sip_account.sip_accountable)
+ add_breadcrumb t('sip_accounts.index.page_title'), user_sip_accounts_path(@sip_account.sip_accountable)
+ add_breadcrumb @sip_account, user_sip_account_path(@sip_account.sip_accountable, @sip_account)
+ add_breadcrumb t('calls.index.page_title'), sip_account_calls_path(@sip_account)
+ elsif @sip_account.sip_accountable.class == Tenant
+ add_breadcrumb t('sip_accounts.index.page_title'), tenant_sip_accounts_path(@sip_account.sip_accountable)
+ add_breadcrumb @sip_account, tenant_sip_account_path(@sip_account.sip_accountable, @sip_account)
+ add_breadcrumb t('calls.index.page_title'), sip_account_calls_path(@sip_account)
+ end
+ end
+ end
end
diff --git a/app/controllers/conference_invitees_controller.rb b/app/controllers/conference_invitees_controller.rb
index ce55b5a..e891ebc 100644
--- a/app/controllers/conference_invitees_controller.rb
+++ b/app/controllers/conference_invitees_controller.rb
@@ -58,7 +58,7 @@ class ConferenceInviteesController < ApplicationController
def destroy
@conference_invitee.destroy
- redirect_to conference_invitees_url, :notice => t('conference_invitees.controller.successfuly_destroyed')
+ redirect_to conference_conference_invitees_url(@conference), :notice => t('conference_invitees.controller.successfuly_destroyed')
end
private
diff --git a/app/controllers/fax_documents_controller.rb b/app/controllers/fax_documents_controller.rb
index c2b3083..43852c6 100644
--- a/app/controllers/fax_documents_controller.rb
+++ b/app/controllers/fax_documents_controller.rb
@@ -61,8 +61,14 @@ class FaxDocumentsController < ApplicationController
@fax_document = @fax_account.fax_documents.build(params[:fax_document])
@fax_document.retry_counter = @fax_account.retries
if @fax_document.save
- @fax_document.queue_for_sending!
- redirect_to fax_account_fax_document_path(@fax_document.fax_account, @fax_document), :notice => t('fax_documents.controller.successfuly_created')
+ if @fax_document.tiff.blank?
+ @fax_document.destroy
+ @fax_document.errors.add(:document, t('fax_documents.controller.tiff_not_created'))
+ render :new
+ else
+ @fax_document.queue_for_sending!
+ redirect_to fax_account_fax_document_path(@fax_document.fax_account, @fax_document), :notice => t('fax_documents.controller.successfuly_created')
+ end
else
render :new
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 74ad7c8..d48707c 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -11,7 +11,7 @@ class GroupsController < ApplicationController
end
def new
- @group = Group.new
+ @group.active = true;
end
def create
diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb
index bd8b44b..106ce76 100644
--- a/app/controllers/gs_parameters_controller.rb
+++ b/app/controllers/gs_parameters_controller.rb
@@ -4,9 +4,15 @@ class GsParametersController < ApplicationController
before_filter :spread_breadcrumbs
def index
- @gs_parameters_unordered = GsParameter.scoped
- @gs_parameters = GsParameter.order([:section, :name])
- @sections = @gs_parameters.pluck(:section).uniq.sort
+ @gs_parameters = GsParameter.order([:entity, :section, :name])
+
+ @entities = Hash.new()
+ @gs_parameters.each do |parameter|
+ if !@entities[parameter.entity]
+ @entities[parameter.entity] = Hash.new()
+ end
+ @entities[parameter.entity][parameter.section] = true
+ end
end
def show
diff --git a/app/controllers/intruders_controller.rb b/app/controllers/intruders_controller.rb
index d3c767e..bdda230 100644
--- a/app/controllers/intruders_controller.rb
+++ b/app/controllers/intruders_controller.rb
@@ -2,7 +2,8 @@ class IntrudersController < ApplicationController
load_and_authorize_resource :intruder
def index
- @intruders = Intruder.order('list_type ASC, contact_last DESC').all
+ @intruders = Intruder.order('list_type ASC, contact_last DESC')
+ @list_types = @intruders.pluck(:list_type).uniq.sort
spread_breadcrumbs
end
diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb
index c9e8c20..9179d8c 100644
--- a/app/controllers/softkeys_controller.rb
+++ b/app/controllers/softkeys_controller.rb
@@ -2,7 +2,7 @@ class SoftkeysController < ApplicationController
load_and_authorize_resource :sip_account, :except => [:sort]
load_and_authorize_resource :softkey, :through => [:sip_account], :except => [:sort]
- before_filter :set_available_call_forwards_and_softkey_functions, :only => [ :new, :edit, :update ]
+ before_filter :set_available_softkey_functions, :only => [ :new, :edit, :update ]
before_filter :spread_breadcrumbs, :except => [:sort]
def index
@@ -54,12 +54,8 @@ class SoftkeysController < ApplicationController
render nothing: true
end
-
private
-
- def set_available_call_forwards_and_softkey_functions
- @available_call_forwards = @softkey.possible_blf_call_forwards
-
+ def set_available_softkey_functions
@softkey_functions = []
SoftkeyFunction.accessible_by(current_ability, :read).each do |softkey_function|
if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", current_user)
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index 64a5f91..5e836c4 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -62,12 +62,14 @@ class TriggerController < ApplicationController
def fax
if !params[:fax_account_id].blank?
fax_account = FaxAccount.where(:id => params[:fax_account_id].to_i).first
+ errors = Array.new()
if fax_account
fax_account.fax_documents.where(:state => 'received').each do |fax_document|
pdf_file = fax_document.tiff_to_pdf
if !pdf_file
+ errors << "#{fax_document.tiff} cound not be converted"
fax_document.state = 'unsuccessful'
fax_document.save
next
@@ -84,20 +86,26 @@ class TriggerController < ApplicationController
fax_document.state = 'successful'
if fax_document.save
+ Notifications.new_fax(fax_document).deliver
begin
File.delete(pdf_file)
rescue => e
logger.error "PDF fax file could not be deleted: #{pdf_file} => #{e.inspect}"
+ errors << "#{pdf_file} cound not be deleted"
end
- fax_document.tiff = nil
fax_document.save
fax_document.render_thumbnails
else
+ errors << "#{fax_document.id} cound not be saved"
fax_document.state = 'unsuccessful'
fax_document.save
end
end
-
+ else
+ errors << "fax_account=#{params[:fax_account_id]} not found"
+ end
+
+ if errors.count == 0
render(
:status => 200,
:layout => false,
@@ -105,11 +113,11 @@ class TriggerController < ApplicationController
:text => "<!-- OK -->",
)
else
- render(
- :status => 404,
+ render(
+ :status => 501,
:layout => false,
:content_type => 'text/plain',
- :text => "<!-- Account not found -->",
+ :text => "<!-- ERRORS: #{errors.join(', ')} -->",
)
end
end