Skip to content
Browse files

add sms number to campaign creation views

  • Loading branch information...
1 parent 423cfe4 commit c3c99ebb818125cd787af8fcbe73ee7f74a547a4 Willa committed Nov 13, 2012
View
9 lib/crowdring/crowdring.rb
@@ -63,6 +63,11 @@ def to_attributes(options)
def content_tag(type, content, options={})
"<#{type}#{to_attributes(options)}>#{content}</#{type}>"
end
+
+ def pretty_phone_number(phone_number)
+ PhoneNumberFields.pretty_number(phone_number)
+ end
+
end
before /^((?!((voice|sms)response)|reports|login|resetpassword|voicemails|progress-embed).)*$/ do
@@ -177,8 +182,8 @@ def process_request(service_name, request, response_type)
res[:region] = region if region
res
end
- numbers = NumberPool.find_numbers(regions).map {|n| Phoner::Phone.parse n}
- @number_summary = numbers.zip(regions).map {|s| {number: s.first, region: s.last}}
+ numbers = NumberPool.find_numbers(regions)
+ @number_summary = numbers.zip(regions).map {|number, region| {number: number, region: region}}
@sms_number = NumberPool.find_number(regions.first, :sms)
case params[:init_ask]
View
2 lib/crowdring/number_pool.rb
@@ -63,7 +63,7 @@ def find_numbers(opts, type)
region = find_matching(opt, avail_numbers)
found_number = region && region[:numbers].first
found_numbers << found_number
- region[:numbers].delete(found_number)
+ region[:numbers].delete(found_number) if region
end
found_numbers
end
View
10 lib/crowdring/phone_number_fields.rb
@@ -31,8 +31,18 @@ def number
Phoner::Phone.parse phone_number
end
+ module_function
+
+ def pretty_number(number_str)
+ PrettyNumber.new(number_str).pretty_phone_number
+ end
+
private
+ class PrettyNumber < Struct.new(:phone_number)
+ include PhoneNumberFields
+ end
+
def valid_phone_number?
if Phoner::Phone.valid? @phone_number
true
View
6 lib/views/campaign_new_missed_call.haml
@@ -1,9 +1,13 @@
#new-campaign.rounded-box
%h2= "Campaign Settings for #{@title}"
%form{action: '/campaign/create/missed_call', method: 'post'}
+ %h3
+ SMSes for this campaign will be sent from
+ %b= pretty_phone_number(@sms_number)
+ %hr
%input{type: 'hidden', name: 'campaign[title]', value: @title}
-@number_summary.each do |entry|
- %h3= entry[:number].format "+%c (%a) %f-%l" + " [" + entry[:number].country.char_3_code + "]"
+ %h3= pretty_phone_number(entry[:number])
%h3= "#{entry[:region][:country]} - #{entry[:region][:region] || 'General'}"
%h4 Add a description for the number
%input{type: 'hidden', name: 'campaign[voice_numbers][][phone_number]', value: entry[:number]}
View
6 lib/views/campaign_new_sms_back.haml
@@ -2,8 +2,12 @@
%h2= "Campaign Settings for #{@title}"
%form{action: '/campaign/create/sms_back', method: 'post'}
%input{type: 'hidden', name: 'campaign[title]', value: @title}
+ %h3
+ SMSes for this campaign will be sent from
+ %b= pretty_phone_number(@sms_number)
+ %hr
-@number_summary.each do |entry|
- %h3= entry[:number].format "+%c (%a) %f-%l" + " [" + entry[:number].country.char_3_code + "]"
+ %h3= pretty_phone_number(entry[:number])
%h3= "#{entry[:region][:country]} - #{entry[:region][:region] || 'General'}"
%h4 Add a description for the number
%input{type: 'hidden', name: 'campaign[voice_numbers][][phone_number]', value: entry[:number]}
View
7 lib/views/message.haml
@@ -9,6 +9,7 @@
%label Then:
.message
= "\"#{fm.message_text}\""
- %label Default:
- .message
- = "\"#{message.default_message}\""
+ -if message.default_message && !message.default_message.empty?
+ %label Default:
+ .message
+ = "\"#{message.default_message}\""

0 comments on commit c3c99eb

Please sign in to comment.
Something went wrong with that request. Please try again.