Skip to content

Commit

Permalink
remove broadcast tab from campaign page, add launch button to danglin…
Browse files Browse the repository at this point in the history
…g ask. need to fix the broadcast route.
  • Loading branch information
Willa committed Nov 15, 2012
1 parent e71e660 commit 76772a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
11 changes: 8 additions & 3 deletions lib/crowdring/crowdring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ def process_request(service_name, request, response_type)
message = params[:campaign][:message]
ask = Ask.create(type: ask_name, message: message)

campaign.asks.last.triggered_ask = ask
if trigger_by == 'previous'
campaign.asks.last.triggered_ask = ask
end
campaign.asks << ask
if campaign.save
flash[:notice] = "New Ask Add"
Expand Down Expand Up @@ -387,12 +389,15 @@ def process_request(service_name, request, response_type)
campaign = Campaign.get(params[:id])
from = params[:from] || campaign.sms_number.raw_number
message = params[:message]
unless message
flash[:errors] = "Ask needs a prompt to launch"
redirect to("/campaigns##{campaign.id}")
end

rings = Filter.create(params[:filter]).filter(Campaign.get(params[:id]).rings)
to = rings.map(&:ringer).map(&:phone_number)

Server.service_handler.broadcast(from, message, to)
campaign.most_recent_broadcast = DateTime.now
campaign.save

flash[:notice] = "Message broadcast"
redirect to("/campaigns##{campaign.id}")
Expand Down
28 changes: 11 additions & 17 deletions lib/views/campaign.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
%a{href: "#campaign-overview"}
%span Campaign Details
%li
%a{href: "#broadcast"}
%span BroadCast
%a{href: "#basic-chart"}
%span Statistic Analysis
%li
%a{href: "#export"}
%span Export To CSV
Expand Down Expand Up @@ -49,23 +49,15 @@
#asks
%h2= "ASKS"
-@campaign.asks.each do |ask|
-if @campaign.asks.select{|n| n.triggered_ask && n.triggered_ask == ask}.empty?
%form{action: "/campaign/#{@campaign.id}/broadcast", method: "post"}
%input{type: 'hidden', name: 'message', value: "#{ask.message}"}
%button{type:'submit'} Launch the Ask

=haml :ask, locals: {ask: ask, type: ask.class.typesym}
%form{action: "/campaign/#{@campaign.id}/add_new_ask", method: 'get'}
%form{action: "/campaign/#{@campaign.id}/add_new_ask", method: 'get'}
%button Add new ask

#broadcast.form-box
%h3 Broadcast
%form{name: 'broadcast', action: "/campaign/#{@campaign.id}/broadcast", method: 'post'}
#filter-container
#broadcast-filter.filter-buttons
%input#all1{type: 'radio', name: 'filter', value: 'all', checked: 'checked'}
%label.all-label{for: 'all1'}= "All #{@ringer_count}"
%input#country1{type: 'radio', name: 'filter', value: 'country:'}
%label{for: 'country1'} Country
#filter-options{style: 'display:none'}
%textarea#broadcast-text-area.msg-text-area{name: 'message', placeholder: 'Hello ringers...'}
%button#broadcastbutton{disabled: 'disabled'} Broadcast

#export.form-box
%h3 Export to CSV
%form{name: 'export', action: "/campaign/#{@campaign.id}/csv", method: 'get'}
Expand All @@ -80,7 +72,9 @@
%input{type: 'checkbox', name: "fields[#{field.id}]", value: 'yes', checked:field.default? && 'checked'}= field.display_name
%button#exportbutton Export

#basic-chart= high_chart("basic-chart", @basic_chart)
#basic-chart
%h3 Statistic Analysis
= high_chart("basic-chart", @basic_chart)

#country-options{style: 'display:none'}
%form
Expand Down

0 comments on commit 76772a1

Please sign in to comment.