calls_controller.rb - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
(HTM) git clone git://jay.scot/warvox
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
calls_controller.rb (2764B)
---
1 class CallsController < ApplicationController
2 # GET /calls
3 # GET /calls.xml
4 def index
5 @jobs = @project.jobs.order('id DESC').where('task = ? AND completed_at IS NOT NULL', 'dialer').paginate(
6 page: params[:page],
7 per_page: 30
8 )
9
10 respond_to do |format|
11 format.html # index.html.erb
12 format.xml { render xml: @calls }
13 end
14 end
15
16 # GET /calls/1/view
17 # GET /calls/1/view.xml
18 def view
19 @calls = Call.order('id DESC').where(job_id: params[:id]).paginate(
20 page: params[:page],
21 per_page: 30
22 )
23
24 unless @calls && !@calls.empty?
25 redirect_to action: :index
26 return
27 end
28
29 @call_results = {
30 Timeout: Call.count(conditions: ['job_id = ? and answered = ?', params[:id], false]),
31 Busy: Call.count(conditions: ['job_id = ? and busy = ?', params[:id], true]),
32 Answered: Call.count(conditions: ['job_id = ? and answered = ?', params[:id], true])
33 }
34
35 respond_to do |format|
36 format.html # index.html.erb
37 format.xml { render xml: @calls }
38 end
39 end
40
41 # GET /calls/1
42 # GET /calls/1.xml
43 def show
44 @call = Call.find(params[:id])
45
46 unless @call
47 redirect_to action: :index
48 return
49 end
50
51 respond_to do |format|
52 format.html # show.html.erb
53 format.xml { render xml: @call }
54 end
55 end
56
57 # GET /calls/new
58 # GET /calls/new.xml
59 def new
60 @call = Call.new
61
62 respond_to do |format|
63 format.html # new.html.erb
64 format.xml { render xml: @call }
65 end
66 end
67
68 # GET /calls/1/edit
69 def edit
70 @call = Call.find(params[:id])
71 end
72
73 # POST /calls
74 # POST /calls.xml
75 def create
76 @call = Call.new(params[:call])
77
78 respond_to do |format|
79 if @call.save
80 flash[:notice] = 'Call was successfully created.'
81 format.html { redirect_to(@call) }
82 format.xml { render xml: @call, status: :created, location: @call }
83 else
84 format.html { render action: 'new' }
85 format.xml { render xml: @call.errors, status: :unprocessable_entity }
86 end
87 end
88 end
89
90 # PUT /calls/1
91 # PUT /calls/1.xml
92 def update
93 @call = Call.find(params[:id])
94
95 respond_to do |format|
96 if @call.update_attributes(params[:call])
97 flash[:notice] = 'Call was successfully updated.'
98 format.html { redirect_to(@call) }
99 format.xml { head :ok }
100 else
101 format.html { render action: 'edit' }
102 format.xml { render xml: @call.errors, status: :unprocessable_entity }
103 end
104 end
105 end
106
107 # DELETE /calls/1
108 # DELETE /calls/1.xml
109 def destroy
110 @job = Job.find(params[:id])
111 @job.destroy
112
113 respond_to do |format|
114 format.html { redirect_to action: 'index' }
115 format.xml { head :ok }
116 end
117 end
118 end