summaryrefslogtreecommitdiff
path: root/app/controllers/calls_controller.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-27 12:22:29 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-27 12:22:29 +0100
commit67c1a0a951403a546250ea860a3e3d199cae2fce (patch)
treef86ec6cedf081a1a57005eca1661e9bead34e4de /app/controllers/calls_controller.rb
parent5d8ce5f4775ac8bc5f523964e6e36f63ff3c4683 (diff)
parent211f558a86ae30cdd5b392ab1376e1393f97e22c (diff)
Merge branch 'develop'5.1-beta6
Diffstat (limited to 'app/controllers/calls_controller.rb')
-rw-r--r--app/controllers/calls_controller.rb54
1 files changed, 53 insertions, 1 deletions
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