Skip to content
This repository
Browse code

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

…sage builder
  • Loading branch information...
commit de7f5227adcdc8b209daedb9abedc19c1c5d12b6 1 parent 3dad789
aross authored April 17, 2012
9  app/controllers/contact_congress_letters_controller.rb
@@ -49,7 +49,14 @@ def new
49 49
       @subject = "#{@bill.typenumber} #{@bill.title_common}"
50 50
       @contactable_query = "contactable_type=Bill&contactable_id=#{@bill.id}"
51 51
     elsif @issue
52  
-      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."
  52
+      if @issue.talking_points.where("talking_points.include_in_message_body='t'").any?
  53
+        message_start = ""
  54
+        @issue.talking_points.where("talking_points.include_in_message_body='t'").order("talking_points.created_at ASC").each do |tp|
  55
+          message_start += "#{tp.talking_point}\n\n"
  56
+        end
  57
+      else
  58
+        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."
  59
+      end
53 60
       @subject = @issue.term
54 61
       @contactable_query = "contactable_type=Subject&contactable_id=#{@issue.id}"
55 62
     end
4  app/views/admin/talking_points/_form.html.haml
@@ -9,6 +9,10 @@
9 9
   %p
10 10
     = f.label :talking_point
11 11
     = f.text_field :talking_point
  12
+    
  13
+  %p
  14
+    = f.label :include_in_message_body
  15
+    = f.check_box :include_in_message_body
12 16
   
13 17
   = f.hidden_field :talking_pointable_id
14 18
   = f.hidden_field :talking_pointable_type
2  app/views/admin/talking_points/index.html.haml
... ...
@@ -1,5 +1,5 @@
1 1
 .padding
2  
-  %h1 PPF Talking Points for #{@talking_pointable}
  2
+  %h1 PPF Talking Points for #{@talking_pointable.class.name == 'Bill' ? @talking_pointable.typenumber : @talking_pointable.term}
3 3
 
4 4
   %table
5 5
     %tr
37  app/views/contact_congress_letters/_message_builder_issue_contribution_data.html.haml
@@ -4,24 +4,27 @@
4 4
   %p.behave
5 5
     Using all publicly-available data, the campaign contributions shown here are the ones OpenCongress automatically determines most-likely to be relevant to this issue.
6 6
 
7  
-  %table
8  
-    %thead
9  
-      %tr
10  
-        %th.topleft
11  
-        - (@sens + @reps).each do |p|
12  
-          %th= p.lastname
13  
-    %tbody
14  
-      - @issue.pvs_categories.each do |pvs|
15  
-        - pvs.crp_industries.each do |ind|
16  
-          %tr
17  
-            %th.group_column= ind.name
18  
-            - (@sens + @reps).each do |p|
19  
-              - contribution_amount = ind.contrib_for_person(p)
20  
-              %td
21  
-                %span.message_builder_clickable
22  
-                  = "$#{number_with_delimiter(contribution_amount)}"
23  
-                  = 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."
  7
+  - if @issue.pvs_categories.any?
  8
+    %table
  9
+      %thead
  10
+        %tr
  11
+          %th.topleft
  12
+          - (@sens + @reps).each do |p|
  13
+            %th= p.lastname
  14
+      %tbody
  15
+        - @issue.pvs_categories.each do |pvs|
  16
+          - pvs.crp_industries.each do |ind|
  17
+            %tr
  18
+              %th.group_column= ind.name
  19
+              - (@sens + @reps).each do |p|
  20
+                - contribution_amount = ind.contrib_for_person(p)
  21
+                %td
  22
+                  %span.message_builder_clickable
  23
+                    = "$#{number_with_delimiter(contribution_amount)}"
  24
+                    = 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."
24 25
 
  26
+  - else
  27
+    %p This data is not available at this time.
25 28
 - if trigger_js
26 29
   :javascript
27 30
     $j(".contribution_data .message_builder_clickable").hover(function(){ mbHoverIn(this) }, function(){ mbHoverOut(this) });
4  app/views/contact_congress_letters/new.html.haml
@@ -54,11 +54,11 @@
54 54
           = "#{@bill.typenumber} has been viewed #{number_with_delimiter(@bill.page_views_count)} times"      
55 55
           = 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."
56 56
 
57  
-      - unless @bill.talking_points.empty?
  57
+      - unless @bill.talking_points.where("talking_points.include_in_message_body='f'").empty?
58 58
         .section
59 59
           %h3 PPF Talking Points
60 60
           %ul
61  
-            - @bill.talking_points.each do |tp|
  61
+            - @bill.talking_points.where("talking_points.include_in_message_body='f'").each do |tp|
62 62
               %li.message_builder_clickable
63 63
                 = tp.talking_point
64 64
                 = render 'will_add_text_box', :text => tp.talking_point
11  db/migrate/20120418060145_talking_points_message_body.rb
... ...
@@ -0,0 +1,11 @@
  1
+class TalkingPointsMessageBody < ActiveRecord::Migration
  2
+  def self.up
  3
+    add_column :talking_points, :include_in_message_body, :boolean, :default => false
  4
+    
  5
+    execute "UPDATE talking_points SET include_in_message_body='f'"
  6
+  end
  7
+
  8
+  def self.down
  9
+    remove_column :talking_points, :include_in_message_body
  10
+  end
  11
+end

0 notes on commit de7f522

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