Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added ability to add talking points to message body for issues in mes…

…sage builder
  • Loading branch information...
commit de7f5227adcdc8b209daedb9abedc19c1c5d12b6 1 parent 3dad789
@aross aross authored
View
9 app/controllers/contact_congress_letters_controller.rb
@@ -49,7 +49,14 @@ def new
@subject = "#{@bill.typenumber} #{@bill.title_common}"
@contactable_query = "contactable_type=Bill&contactable_id=#{@bill.id}"
elsif @issue
- message_start = "I am tracking legislation in the issue area of #{@issue.term} using OpenCongress.org, the free public resource website for government transparency and accountability."
+ if @issue.talking_points.where("talking_points.include_in_message_body='t'").any?
+ message_start = ""
+ @issue.talking_points.where("talking_points.include_in_message_body='t'").order("talking_points.created_at ASC").each do |tp|
+ message_start += "#{tp.talking_point}\n\n"
+ end
+ else
+ message_start = "I am tracking legislation in the issue area of #{@issue.term} using OpenCongress.org, the free public resource website for government transparency and accountability."
+ end
@subject = @issue.term
@contactable_query = "contactable_type=Subject&contactable_id=#{@issue.id}"
end
View
4 app/views/admin/talking_points/_form.html.haml
@@ -9,6 +9,10 @@
%p
= f.label :talking_point
= f.text_field :talking_point
+
+ %p
+ = f.label :include_in_message_body
+ = f.check_box :include_in_message_body
= f.hidden_field :talking_pointable_id
= f.hidden_field :talking_pointable_type
View
2  app/views/admin/talking_points/index.html.haml
@@ -1,5 +1,5 @@
.padding
- %h1 PPF Talking Points for #{@talking_pointable}
+ %h1 PPF Talking Points for #{@talking_pointable.class.name == 'Bill' ? @talking_pointable.typenumber : @talking_pointable.term}
%table
%tr
View
37 app/views/contact_congress_letters/_message_builder_issue_contribution_data.html.haml
@@ -4,24 +4,27 @@
%p.behave
Using all publicly-available data, the campaign contributions shown here are the ones OpenCongress automatically determines most-likely to be relevant to this issue.
- %table
- %thead
- %tr
- %th.topleft
- - (@sens + @reps).each do |p|
- %th= p.lastname
- %tbody
- - @issue.pvs_categories.each do |pvs|
- - pvs.crp_industries.each do |ind|
- %tr
- %th.group_column= ind.name
- - (@sens + @reps).each do |p|
- - contribution_amount = ind.contrib_for_person(p)
- %td
- %span.message_builder_clickable
- = "$#{number_with_delimiter(contribution_amount)}"
- = render 'will_add_text_box', :text => "#{p.title} #{p.lastname}, campaign contribution data shows that you received $#{number_with_delimiter(contribution_amount)} in the #{Settings.current_opensecrets_cycle} election cycle from the #{ind.name.downcase} industry, which is relevant to this issue area."
+ - if @issue.pvs_categories.any?
+ %table
+ %thead
+ %tr
+ %th.topleft
+ - (@sens + @reps).each do |p|
+ %th= p.lastname
+ %tbody
+ - @issue.pvs_categories.each do |pvs|
+ - pvs.crp_industries.each do |ind|
+ %tr
+ %th.group_column= ind.name
+ - (@sens + @reps).each do |p|
+ - contribution_amount = ind.contrib_for_person(p)
+ %td
+ %span.message_builder_clickable
+ = "$#{number_with_delimiter(contribution_amount)}"
+ = render 'will_add_text_box', :text => "#{p.title} #{p.lastname}, campaign contribution data shows that you received $#{number_with_delimiter(contribution_amount)} in the #{Settings.current_opensecrets_cycle} election cycle from the #{ind.name.downcase} industry, which is relevant to this issue area."
+ - else
+ %p This data is not available at this time.
- if trigger_js
:javascript
$j(".contribution_data .message_builder_clickable").hover(function(){ mbHoverIn(this) }, function(){ mbHoverOut(this) });
View
4 app/views/contact_congress_letters/new.html.haml
@@ -54,11 +54,11 @@
= "#{@bill.typenumber} has been viewed #{number_with_delimiter(@bill.page_views_count)} times"
= render 'will_add_text_box', :text => "#{@bill.typenumber} has been viewed #{number_with_delimiter(@bill.page_views_count)} times on OpenCongress.org, a free, non-partisan resource."
- - unless @bill.talking_points.empty?
+ - unless @bill.talking_points.where("talking_points.include_in_message_body='f'").empty?
.section
%h3 PPF Talking Points
%ul
- - @bill.talking_points.each do |tp|
+ - @bill.talking_points.where("talking_points.include_in_message_body='f'").each do |tp|
%li.message_builder_clickable
= tp.talking_point
= render 'will_add_text_box', :text => tp.talking_point
View
11 db/migrate/20120418060145_talking_points_message_body.rb
@@ -0,0 +1,11 @@
+class TalkingPointsMessageBody < ActiveRecord::Migration
+ def self.up
+ add_column :talking_points, :include_in_message_body, :boolean, :default => false
+
+ execute "UPDATE talking_points SET include_in_message_body='f'"
+ end
+
+ def self.down
+ remove_column :talking_points, :include_in_message_body
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.