Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add double opt in ask for campaign creation

  • Loading branch information...
commit abcb6f51c8e9823e9a4cba7835f848fafaf7db99 1 parent c3c99eb
Willa authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 lib/crowdring/crowdring.rb
View
22 lib/crowdring/crowdring.rb
@@ -191,6 +191,8 @@ def process_request(service_name, request, response_type)
haml :campaign_new_missed_call
when 'sms_back'
haml :campaign_new_sms_back
+ when 'double_opt_in'
+ haml :campaign_new_double_opt_in
end
end
@@ -224,6 +226,26 @@ def process_request(service_name, request, response_type)
end
end
end
+
+ post '/campaign/create/double_opt_in' do
+ campaign = Campaign.new(params[:campaign])
+ if campaign.save
+ filtered_messages = params[:sms_responses].zip(campaign.voice_numbers).map do |msg, number|
+ FilteredMessage.new(tags: [number.tag], message_text: msg)
+ end
+ message = Message.create(filtered_messages: filtered_messages)
+ join_ask = JoinAsk.create(message: message)
+ campaign.asks.first.triggered_ask = join_ask
+ campaign.asks << join_ask
+ if campaign.save
+ flash[:notice] = "Campaign created"
+ redirect to("/campaigns##{campaign.id}")
+ else
+ flash[:errors] = campaign.all_errors.map(&:full_messages).flatten.join('|')
+ redirect to('/campaign/new')
+ end
+ end
+ end
get '/campaign/:id/assign_voice_number' do
@campaign = Campaign.get(params[:id])
Please sign in to comment.
Something went wrong with that request. Please try again.