blythedunham-sms_on_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/Manifest +101 -0
- data/README +163 -0
- data/README.rdoc +211 -0
- data/Rakefile +76 -0
- data/app/controllers/admin/sms_on_rails/base_controller.rb +11 -0
- data/app/controllers/admin/sms_on_rails/drafts_controller.rb +75 -0
- data/app/controllers/admin/sms_on_rails/outbounds_controller.rb +117 -0
- data/app/controllers/admin/sms_on_rails/phone_carriers_controller.rb +85 -0
- data/app/controllers/admin/sms_on_rails/phone_numbers_controller.rb +101 -0
- data/app/controllers/sms_on_rails/creation_support.rb +99 -0
- data/app/controllers/sms_on_rails_controller.rb +14 -0
- data/app/helpers/admin/sms_on_rails/drafts_helper.rb +2 -0
- data/app/helpers/admin/sms_on_rails/phone_carriers_helper.rb +2 -0
- data/app/helpers/sms_on_rails/phone_numbers_helper.rb +9 -0
- data/app/helpers/sms_on_rails/sms_helper.rb +44 -0
- data/app/models/sms_on_rails/draft.rb +9 -0
- data/app/models/sms_on_rails/outbound.rb +17 -0
- data/app/models/sms_on_rails/phone_carrier.rb +14 -0
- data/app/models/sms_on_rails/phone_number.rb +8 -0
- data/app/views/admin/sms_on_rails/base/index.html.erb +5 -0
- data/app/views/admin/sms_on_rails/drafts/_show.html.erb +34 -0
- data/app/views/admin/sms_on_rails/drafts/edit.html.erb +36 -0
- data/app/views/admin/sms_on_rails/drafts/index.html.erb +32 -0
- data/app/views/admin/sms_on_rails/drafts/new.html.erb +34 -0
- data/app/views/admin/sms_on_rails/drafts/send_sms.html.erb +3 -0
- data/app/views/admin/sms_on_rails/drafts/show.html.erb +4 -0
- data/app/views/admin/sms_on_rails/outbounds/edit.html.erb +68 -0
- data/app/views/admin/sms_on_rails/outbounds/index.html.erb +37 -0
- data/app/views/admin/sms_on_rails/outbounds/new.html.erb +54 -0
- data/app/views/admin/sms_on_rails/outbounds/show.html.erb +69 -0
- data/app/views/admin/sms_on_rails/phone_carriers/edit.html.erb +24 -0
- data/app/views/admin/sms_on_rails/phone_carriers/index.html.erb +24 -0
- data/app/views/admin/sms_on_rails/phone_carriers/new.html.erb +22 -0
- data/app/views/admin/sms_on_rails/phone_carriers/show.html.erb +24 -0
- data/app/views/admin/sms_on_rails/phone_numbers/edit.html.erb +33 -0
- data/app/views/admin/sms_on_rails/phone_numbers/index.html.erb +28 -0
- data/app/views/admin/sms_on_rails/phone_numbers/new.html.erb +31 -0
- data/app/views/admin/sms_on_rails/phone_numbers/show.html.erb +32 -0
- data/app/views/layouts/sms_on_rails/basic.html.erb +26 -0
- data/app/views/sms_on_rails/_phone_carrier_form_item.html.erb +6 -0
- data/app/views/sms_on_rails/_send_sms.html.erb +33 -0
- data/app/views/sms_on_rails/index.html.erb +8 -0
- data/app/views/sms_on_rails/send_sms.html.erb +3 -0
- data/app/views/sms_on_rails/show.html.erb +29 -0
- data/config/routes.rb +19 -0
- data/db/data/fixtures/sms_phone_carriers.yml +110 -0
- data/db/migrate/sms_on_rails_carrier_tables.rb +9 -0
- data/db/migrate/sms_on_rails_model_tables.rb +48 -0
- data/db/migrate/sms_on_rails_phone_number_tables.rb +11 -0
- data/db/seed_data.rb +16 -0
- data/generators/sms_on_rails/USAGE +31 -0
- data/generators/sms_on_rails/commands/inserts.rb +63 -0
- data/generators/sms_on_rails/commands/timestamps.rb +33 -0
- data/generators/sms_on_rails/runners/add_all_models.rb +6 -0
- data/generators/sms_on_rails/runners/dependencies.rb +1 -0
- data/generators/sms_on_rails/runners/remove_all_models.rb +5 -0
- data/generators/sms_on_rails/runners/sms_on_rails_routes.rb +14 -0
- data/generators/sms_on_rails/sms_on_rails_generator.rb +255 -0
- data/generators/sms_on_rails/templates/configuration/clickatell.rb +6 -0
- data/generators/sms_on_rails/templates/configuration/email_gateway.rb +7 -0
- data/generators/sms_on_rails/templates/migrate/schema_migration.rb +15 -0
- data/generators/sms_on_rails/templates/migrate/sms_on_rails_update_phone_numbers.rb +40 -0
- data/generators/sms_on_rails/templates/phone_number_collision.rb +2 -0
- data/init.rb +3 -0
- data/install.rb +1 -0
- data/lib/sms_on_rails.rb +8 -0
- data/lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb +92 -0
- data/lib/sms_on_rails/activerecord_extensions/acts_as_substitutable.rb +80 -0
- data/lib/sms_on_rails/activerecord_extensions/has_a_sms_service_provider.rb +101 -0
- data/lib/sms_on_rails/activerecord_extensions/lockable_record.rb +186 -0
- data/lib/sms_on_rails/all_models.rb +3 -0
- data/lib/sms_on_rails/model_support/draft.rb +178 -0
- data/lib/sms_on_rails/model_support/outbound.rb +136 -0
- data/lib/sms_on_rails/model_support/phone_carrier.rb +77 -0
- data/lib/sms_on_rails/model_support/phone_number.rb +248 -0
- data/lib/sms_on_rails/model_support/phone_number_associations.rb +13 -0
- data/lib/sms_on_rails/schema_helper.rb +51 -0
- data/lib/sms_on_rails/service_providers/base.rb +222 -0
- data/lib/sms_on_rails/service_providers/clickatell.rb +52 -0
- data/lib/sms_on_rails/service_providers/dummy.rb +19 -0
- data/lib/sms_on_rails/service_providers/email_gateway.rb +68 -0
- data/lib/sms_on_rails/service_providers/email_gateway_support/errors.rb +20 -0
- data/lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer.rb +21 -0
- data/lib/sms_on_rails/service_providers/email_gateway_support/sms_mailer/sms_through_gateway.erb +6 -0
- data/lib/sms_on_rails/util/sms_error.rb +12 -0
- data/lib/smsonrails.rb +1 -0
- data/public/images/sms_on_rails/railsYoDawg.jpg +0 -0
- data/public/stylesheets/sms_on_rails.css +137 -0
- data/sms_on_rails.gemspec +32 -0
- data/tasks/sms_on_rails_tasks.rake +67 -0
- data/test/active_record_extensions/delivery_and_locking_test.rb +84 -0
- data/test/models/draft_test.rb +72 -0
- data/test/models/outbound_test.rb +89 -0
- data/test/models/phone_number_test.rb +131 -0
- data/test/run.rb +18 -0
- data/test/service_providers/abstract_test_support.rb +104 -0
- data/test/service_providers/clickatell_test.rb +39 -0
- data/test/service_providers/email_gateway_test.rb +30 -0
- data/test/test_helper.rb +24 -0
- data/uninstall.rb +1 -0
- metadata +187 -0
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'echoe'
|
5
|
+
|
6
|
+
desc 'Default: run unit tests.'
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
desc "Create test database. Run with root permissions. (sudo)"
|
10
|
+
task :create_test_database do
|
11
|
+
system "mysqladmin create sms_on_rails_test"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Prepares the test database"
|
15
|
+
task :prepare_test do
|
16
|
+
require File.dirname(__FILE__) + '/test/run'
|
17
|
+
|
18
|
+
migration_dir = File.dirname(__FILE__), ""
|
19
|
+
#ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
20
|
+
|
21
|
+
require File.dirname(__FILE__) + '/lib/sms_on_rails/schema_helper'
|
22
|
+
puts SmsOnRails::SchemaHelper.schema(:create, 'sms_on_rails_carrier_tables', 'sms_on_rails_phone_number_tables', 'sms_on_rails_model_tables' )
|
23
|
+
instance_eval SmsOnRails::SchemaHelper.schema(:create, 'sms_on_rails_carrier_tables', 'sms_on_rails_phone_number_tables', 'sms_on_rails_model_tables' )
|
24
|
+
puts "Seeding SMS tables..."
|
25
|
+
require File.dirname(__FILE__) + '/test/test_helper.rb'
|
26
|
+
load File.dirname(__FILE__) + '/db/seed_data.rb'
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Test the sms_on_rails plugin.'
|
31
|
+
task :test => [:prepare_test, :test_without_setup]
|
32
|
+
|
33
|
+
|
34
|
+
desc 'Test the sms_on_rails plugin without setup'
|
35
|
+
Rake::TestTask.new(:test_without_setup) do |t|
|
36
|
+
t.libs << 'lib'
|
37
|
+
t.pattern = 'test/**/*_test.rb'
|
38
|
+
t.verbose = true
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Generate documentation for the sms_on_rails plugin.'
|
42
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = 'SmsOnRails'
|
45
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
46
|
+
rdoc.rdoc_files.include('README')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
desc 'Copy templates from application files'
|
52
|
+
task :create_templates do
|
53
|
+
dest_dir = File.dirname(__FILE__) + '/generators/sms_on_rails/templates'
|
54
|
+
src_dir = File.dirname(__FILE__) + '/../../../app'
|
55
|
+
|
56
|
+
folders = %w( helpers/sms_on_rails helpers/admin/sms_on_rails controllers/admin/sms_on_rails views/layouts/admin/sms_on_rails views/admin/sms_on_rails )
|
57
|
+
folders.each do |f|
|
58
|
+
puts "Create: #{f}"
|
59
|
+
system("rm -r #{dest_dir}/#{f}")
|
60
|
+
FileUtils.mkdir_p File.dirname("#{dest_dir}/#{f}")
|
61
|
+
system("cp -r #{src_dir}/#{f} #{dest_dir}/#{f}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Echoe.new('sms_on_rails', '0.1.0') do |p|
|
66
|
+
p.description = "Integrate your application with SMS through Clickatell or the Email Gateways"
|
67
|
+
p.url = "http://github.com/blythedunham/smsonrails"
|
68
|
+
p.author = "Blythe Dunham"
|
69
|
+
p.email = "blythe@snowgiraffe.com"
|
70
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
71
|
+
p.development_dependencies = []
|
72
|
+
end
|
73
|
+
|
74
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
75
|
+
|
76
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class Admin::SmsOnRails::DraftsController < Admin::SmsOnRails::BaseController
|
2
|
+
include SmsOnRails::CreationSupport
|
3
|
+
|
4
|
+
# GET /admin/sms/drafts
|
5
|
+
# GET /admin/sms/drafts.xml
|
6
|
+
def index
|
7
|
+
@drafts = SmsOnRails::Draft.all
|
8
|
+
|
9
|
+
respond_to do |format|
|
10
|
+
format.html # index.html.erb
|
11
|
+
format.xml { render :xml => @drafts }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
# GET /admin/sms/drafts/new
|
17
|
+
# GET /admin/sms/drafts/new.xml
|
18
|
+
def new
|
19
|
+
@draft = SmsOnRails::Draft.new
|
20
|
+
|
21
|
+
respond_to do |format|
|
22
|
+
format.html # new.html.erb
|
23
|
+
format.xml { render :xml => @draft }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# GET /admin/sms/drafts/1/edit
|
28
|
+
def edit
|
29
|
+
@draft = SmsOnRails::Draft.find(params[:id])
|
30
|
+
end
|
31
|
+
|
32
|
+
def create
|
33
|
+
create_sms_draft
|
34
|
+
end
|
35
|
+
|
36
|
+
# PUT /admin/sms/drafts/1
|
37
|
+
# PUT /admin/sms/drafts/1.xml
|
38
|
+
def update
|
39
|
+
@draft = SmsOnRails::Draft.find(params[:id])
|
40
|
+
|
41
|
+
respond_to do |format|
|
42
|
+
if @draft.update_attributes(params[:draft])
|
43
|
+
flash[:notice] = 'Draft was successfully updated.'
|
44
|
+
format.html { redirect_to(sms_draft_url(:id => @draft)) }
|
45
|
+
format.xml { head :ok }
|
46
|
+
else
|
47
|
+
format.html { render :action => "edit" }
|
48
|
+
format.xml { render :xml => @draft.errors, :status => :unprocessable_entity }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# DELETE /admin/sms/drafts/1
|
54
|
+
# DELETE /admin/sms/drafts/1.xml
|
55
|
+
def destroy
|
56
|
+
@draft = SmsOnRails::Draft.find(params[:id])
|
57
|
+
@draft.destroy
|
58
|
+
|
59
|
+
respond_to do |format|
|
60
|
+
format.html { redirect_to(sms_drafts_url) }
|
61
|
+
format.xml { head :ok }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
|
67
|
+
|
68
|
+
# overwrite to use send_sms if created that or
|
69
|
+
# new for all the params
|
70
|
+
def render_send_sms_template
|
71
|
+
render :action => ((params[:previous_action]||params[:action] == 'send_sms') ? :send_sms : :new)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
class Admin::SmsOnRails::OutboundsController < Admin::SmsOnRails::BaseController
|
2
|
+
# GET /admin/sms/outbounds
|
3
|
+
# GET /admin/sms/outbounds.xml
|
4
|
+
def index
|
5
|
+
if params[:sms_draft_id]
|
6
|
+
@draft = SmsOnRails::Draft.find( params[:sms_draft_id], :include => :outbounds )
|
7
|
+
@outbounds = @draft.outbounds
|
8
|
+
end
|
9
|
+
|
10
|
+
@outbounds ||= SmsOnRails::Outbound.all
|
11
|
+
|
12
|
+
respond_to do |format|
|
13
|
+
format.html # index.html.erb
|
14
|
+
format.xml { render :xml => @outbounds }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /admin/sms/outbounds/1
|
19
|
+
# GET /admin/sms/outbounds/1.xml
|
20
|
+
def show
|
21
|
+
@outbound = SmsOnRails::Outbound.find(params[:id])
|
22
|
+
|
23
|
+
respond_to do |format|
|
24
|
+
format.html # show.html.erb
|
25
|
+
format.xml { render :xml => @outbound }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET /admin/sms/outbounds/new
|
30
|
+
# GET /admin/sms/outbounds/new.xml
|
31
|
+
def new
|
32
|
+
@outbound = SmsOnRails::Outbound.new(:sms_draft_id => params[:sms_draft_id])
|
33
|
+
|
34
|
+
respond_to do |format|
|
35
|
+
format.html # new.html.erb
|
36
|
+
format.xml { render :xml => @outbound }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# GET /admin/sms/outbounds/1/edit
|
41
|
+
def edit
|
42
|
+
@outbound = SmsOnRails::Outbound.find(params[:id])
|
43
|
+
end
|
44
|
+
|
45
|
+
# POST /admin/sms/outbounds
|
46
|
+
# POST /admin/sms/outbounds.xml
|
47
|
+
def create
|
48
|
+
@draft = SmsOnRails::Draft.find(params[:sms_draft_id]) if params[:sms_draft_id]
|
49
|
+
@outbound = SmsOnRails::Outbound.create_with_phone(params[:outbound], @draft)
|
50
|
+
|
51
|
+
respond_to do |format|
|
52
|
+
unless @outbound.errors.any?
|
53
|
+
flash[:notice] = 'Outbound was successfully created.'
|
54
|
+
format.html { redirect_to(sms_draft_outbound_path(@draft, @outbound))}
|
55
|
+
format.xml { render :xml => @outbound, :status => :created, :location => @outbound }
|
56
|
+
else
|
57
|
+
# evil hack as forms are rejected with an id value
|
58
|
+
@outbound.phone_number.id = nil if @outbound.phone_number
|
59
|
+
|
60
|
+
format.html { render :action => "new" }
|
61
|
+
format.xml { render :xml => @outbound.errors, :status => :unprocessable_entity }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# PUT /admin/sms/outbounds/1
|
67
|
+
# PUT /admin/sms/outbounds/1.xml
|
68
|
+
def update
|
69
|
+
@outbound = SmsOnRails::Outbound.find(params[:id])
|
70
|
+
|
71
|
+
if params[:outbound]
|
72
|
+
@outbound.update_attributes(params[:outbound])
|
73
|
+
end
|
74
|
+
|
75
|
+
if @outbound.errors.blank? && params[:send_immediately]
|
76
|
+
deliver_sms('Outbound message was updated and sent.')
|
77
|
+
end
|
78
|
+
|
79
|
+
respond_to do |format|
|
80
|
+
unless @outbound.errors.any?
|
81
|
+
flash[:notice] = 'Outbound was successfully updated.'
|
82
|
+
format.html { redirect_to(sms_draft_outbound_path(@outbound.draft, @outbound)) }
|
83
|
+
format.xml { head :ok }
|
84
|
+
else
|
85
|
+
format.html { render :action => "edit" }
|
86
|
+
format.xml { render :xml => @outbound.errors, :status => :unprocessable_entity }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# DELETE /admin/sms/outbounds/1
|
92
|
+
# DELETE /admin/sms/outbounds/1.xml
|
93
|
+
def destroy
|
94
|
+
@outbound = SmsOnRails::Outbound.find(params[:id])
|
95
|
+
@draft = @outbound.draft
|
96
|
+
@outbound.destroy
|
97
|
+
|
98
|
+
respond_to do |format|
|
99
|
+
format.html { redirect_to(sms_draft_outbounds_url(@draft)) }
|
100
|
+
format.xml { head :ok }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def deliver_sms(success_message = nil)
|
105
|
+
@outbound ||= SmsOnRails::Outbound.find(params[:id])
|
106
|
+
respond_to do |format|
|
107
|
+
if @outbound.deliver(:fatal_exception => nil)
|
108
|
+
flash[:notice] = success_message || 'Outbound SMS was successfully sent'
|
109
|
+
format.html { redirect_to(sms_draft_outbound_path(@outbound)) }
|
110
|
+
format.xml { head :ok }
|
111
|
+
else
|
112
|
+
format.html { render :action => :edit }
|
113
|
+
format.xml { render :xml => @outbound.errors, :status => :unprocessable_entity }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class Admin::SmsOnRails::PhoneCarriersController < Admin::SmsOnRails::BaseController
|
2
|
+
# GET /admin/sms/phone_carriers
|
3
|
+
# GET /admin/sms/phone_carriers.xml
|
4
|
+
def index
|
5
|
+
@phone_carriers = SmsOnRails::PhoneCarrier.all :group => :name
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.xml { render :xml => @phone_carriers }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /admin/sms/phone_carriers/1
|
14
|
+
# GET /admin/sms/phone_carriers/1.xml
|
15
|
+
def show
|
16
|
+
@phone_carrier = SmsOnRails::PhoneCarrier.find(params[:id])
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.xml { render :xml => @phone_carrier }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /admin/sms/phone_carriers/new
|
25
|
+
# GET /admin/sms/phone_carriers/new.xml
|
26
|
+
def new
|
27
|
+
@phone_carrier = SmsOnRails::PhoneCarrier.new
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.xml { render :xml => @phone_carrier }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /admin/sms/phone_carriers/1/edit
|
36
|
+
def edit
|
37
|
+
@phone_carrier = SmsOnRails::PhoneCarrier.find(params[:id])
|
38
|
+
end
|
39
|
+
|
40
|
+
# POST /admin/sms/phone_carriers
|
41
|
+
# POST /admin/sms/phone_carriers.xml
|
42
|
+
def create
|
43
|
+
@phone_carrier = SmsOnRails::PhoneCarrier.new(params[:phone_carrier])
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
if @phone_carrier.save
|
47
|
+
flash[:notice] = 'PhoneCarrier was successfully created.'
|
48
|
+
format.html { redirect_to(sms_phone_carrier_url(:id => @phone_carrier)) }
|
49
|
+
format.xml { render :xml => @phone_carrier, :status => :created, :location => @phone_carrier }
|
50
|
+
else
|
51
|
+
format.html { render :action => "new" }
|
52
|
+
format.xml { render :xml => @phone_carrier.errors, :status => :unprocessable_entity }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# PUT /admin/sms/phone_carriers/1
|
58
|
+
# PUT /admin/sms/phone_carriers/1.xml
|
59
|
+
def update
|
60
|
+
@phone_carrier = SmsOnRails::PhoneCarrier.find(params[:id])
|
61
|
+
|
62
|
+
respond_to do |format|
|
63
|
+
if @phone_carrier.update_attributes(params[:phone_carrier])
|
64
|
+
flash[:notice] = 'PhoneCarrier was successfully updated.'
|
65
|
+
format.html { redirect_to(sms_phone_carrier_url(:id => @phone_carrier)) }
|
66
|
+
format.xml { head :ok }
|
67
|
+
else
|
68
|
+
format.html { render :action => "edit" }
|
69
|
+
format.xml { render :xml => @phone_carrier.errors, :status => :unprocessable_entity }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# DELETE /admin/sms/phone_carriers/1
|
75
|
+
# DELETE /admin/sms/phone_carriers/1.xml
|
76
|
+
def destroy
|
77
|
+
@phone_carrier = SmsOnRails::PhoneCarrier.find(params[:id])
|
78
|
+
@phone_carrier.destroy
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
format.html { redirect_to(sms_phone_carriers_url) }
|
82
|
+
format.xml { head :ok }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
class Admin::SmsOnRails::PhoneNumbersController < Admin::SmsOnRails::BaseController
|
2
|
+
|
3
|
+
helper SmsOnRails::SmsHelper
|
4
|
+
|
5
|
+
# GET /admin/sms_on_rails_phone_numbers
|
6
|
+
# GET /admin/sms_on_rails_phone_numbers.xml
|
7
|
+
def index
|
8
|
+
|
9
|
+
if params[:sms_outbound_id]
|
10
|
+
@outbounds = SmsOnRails::Outbound.find( params[:sms_outbound_id] )
|
11
|
+
@phone_numbers = [@outbounds.phone_number]
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
@phone_numbers ||= SmsOnRails::PhoneNumber.all
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
format.html # index.html.erb
|
19
|
+
format.xml { render :xml => @phone_numbers }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /admin/sms_on_rails_phone_numbers/1
|
24
|
+
# GET /admin/sms_on_rails_phone_numbers/1.xml
|
25
|
+
def show
|
26
|
+
|
27
|
+
if params[:sms_outbound_id]
|
28
|
+
@outbounds = SmsOnRails::Outbound.find( params[:sms_outbound_id] )
|
29
|
+
@phone_number = @outbounds.phone_number
|
30
|
+
end
|
31
|
+
|
32
|
+
@phone_number ||= SmsOnRails::PhoneNumber.find(params[:id])
|
33
|
+
|
34
|
+
respond_to do |format|
|
35
|
+
format.html # show.html.erb
|
36
|
+
format.xml { render :xml => @phone_number }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# GET /admin/sms_on_rails_phone_numbers/new
|
41
|
+
# GET /admin/sms_on_rails_phone_numbers/new.xml
|
42
|
+
def new
|
43
|
+
@phone_number = SmsOnRails::PhoneNumber.new
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
format.html # new.html.erb
|
47
|
+
format.xml { render :xml => @phone_number }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# GET /admin/sms_on_rails_phone_numbers/1/edit
|
52
|
+
def edit
|
53
|
+
@phone_number = SmsOnRails::PhoneNumber.find(params[:id])
|
54
|
+
end
|
55
|
+
|
56
|
+
# POST /admin/sms_on_rails_phone_numbers
|
57
|
+
# POST /admin/sms_on_rails_phone_numbers.xml
|
58
|
+
def create
|
59
|
+
@phone_number = SmsOnRails::PhoneNumber.new(params[:phone_number])
|
60
|
+
|
61
|
+
respond_to do |format|
|
62
|
+
if @phone_number.save
|
63
|
+
flash[:notice] = 'PhoneNumber was successfully created.'
|
64
|
+
format.html { redirect_to(sms_phone_number_path(:id => @phone_number)) }
|
65
|
+
format.xml { render :xml => @phone_number, :status => :created, :location => @phone_number }
|
66
|
+
else
|
67
|
+
format.html { render :action => "new" }
|
68
|
+
format.xml { render :xml => @phone_number.errors, :status => :unprocessable_entity }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# PUT /admin/sms_on_rails_phone_numbers/1
|
74
|
+
# PUT /admin/sms_on_rails_phone_numbers/1.xml
|
75
|
+
def update
|
76
|
+
@phone_number = SmsOnRails::PhoneNumber.find(params[:id])
|
77
|
+
|
78
|
+
respond_to do |format|
|
79
|
+
if @phone_number.update_attributes(params[:phone_number])
|
80
|
+
flash[:notice] = 'PhoneNumber was successfully updated.'
|
81
|
+
format.html { redirect_to(sms_phone_number_path(:id => @phone_number)) }
|
82
|
+
format.xml { head :ok }
|
83
|
+
else
|
84
|
+
format.html { render :action => "edit" }
|
85
|
+
format.xml { render :xml => @phone_number.errors, :status => :unprocessable_entity }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# DELETE /admin/sms_on_rails_phone_numbers/1
|
91
|
+
# DELETE /admin/sms_on_rails_phone_numbers/1.xml
|
92
|
+
def destroy
|
93
|
+
@phone_number = SmsOnRails::PhoneNumber.find(params[:id])
|
94
|
+
@phone_number.destroy
|
95
|
+
|
96
|
+
respond_to do |format|
|
97
|
+
format.html { redirect_to(sms_phone_numbers_url) }
|
98
|
+
format.xml { head :ok }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|