Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

per-state configs for email and pdf instructions, use values in pdf a…

…nd email generation, refactor emails to have a longer list of html_safe variables available in the template
  • Loading branch information...
commit 150382009011af198c6d3b56d0c5f73c3d55811c 1 parent 0c3f553
Alex Mekelburg authored
View
3  app/assets/stylesheets/nvra.css.scss
@@ -120,6 +120,9 @@ span.smaller_prompt {
}
}
padding:2.5%;
+ .state_instructions p {
+ font-size: .6 * $fs;
+ }
}
}
View
13 app/mailers/notifier.rb
@@ -72,12 +72,19 @@ def setup_registrant_email(registrant, kind)
def message_body(registrant, kind)
@pdf_url = "http://#{default_url_options[:host]}#{registrant.pdf_path}?source=email"
- @cancel_reminders_url = registrant_finish_url(registrant, :protocol => "https", :reminders => "stop")
+ @cancel_reminders_url = registrant_finish_url(registrant, :protocol => "https", :reminders => "stop").to_s.html_safe
@locale = registrant.locale.to_sym
- @registrar_phone = registrant.home_state.registrar_phone
+ @registrar_phone = registrant.home_state.registrar_phone.to_s.html_safe
@registrar_address = registrant.home_state.registrar_address.to_s.html_safe
- @registrar_url = registrant.home_state.registrar_url
+ @registrar_url = registrant.home_state.registrar_url.to_s.html_safe
@registrant = registrant
+ @registrant_first_name = registrant.first_name.to_s.html_safe
+ @registrant_last_name = registrant.last_name.to_s.html_safe
+ @registrant_rtv_and_partner_name = registrant.rtv_and_partner_name.to_s.html_safe
+ @registrant_home_state_name = registrant.home_state_name.to_s.html_safe
+ @registrant_home_state_abbrev = registrant.home_state_abbrev.to_s.html_safe
+ @rtv_link = '<strong><a href="http://register.rockthevote.com/">register.rockthevote.com</a></strong>'.html_safe
+ @home_state_email_instructions = registrant.home_state_email_instructions.blank? ? '' : (registrant.home_state_email_instructions + "<br/><br/>").to_s.html_safe
partner = registrant.partner
custom_template = partner && partner.whitelabeled? && EmailTemplate.get(partner, "#{kind}.#{registrant.locale}")
View
6 app/models/registrant.rb
@@ -721,6 +721,12 @@ def registration_deadline
localization.registration_deadline
end
+ [:pdf_instructions, :email_instructions].each do |state_data|
+ define_method("home_state_#{state_data}") do
+ localization.send(state_data)
+ end
+ end
+
def registration_instructions_url
RockyConf.pdf.nvra.page1.other_block.instructions_url.gsub(
"<LOCALE>",locale
View
18 app/views/notifier/confirmation.html.erb
@@ -1,4 +1,3 @@
-<% rtv_link = '<strong><a href="http://register.rockthevote.com/">register.rockthevote.com</a></strong>' %>
<style type="text/css">
<!--
.boxtext {
@@ -12,28 +11,29 @@
-->
</style>
-<%= I18n.t('email.confirmation.body.greeting', :registrant_first_name=>@registrant.first_name, :registrant_last_name=>@registrant.last_name, :locale => @registrant.locale.to_sym).html_safe %> <br><br>
+<%= I18n.t('email.confirmation.body.greeting', :registrant_first_name=>@registrant_first_name, :registrant_last_name=>@registrant_last_name, :locale => @locale).html_safe %> <br><br>
<table style="float: right; margin: 0 0 15px 15px; width: 275px; border: 8px solid #cc0000;color:black" width="275" cellspacing="0" cellpadding="10">
<tr>
- <td align="center" valign="middle" class="boxtext"><%=I18n.t('email.confirmation.body.reminder', :locale => @registrant.locale.to_sym).html_safe %></td>
+ <td align="center" valign="middle" class="boxtext"><%=I18n.t('email.confirmation.body.reminder', :locale => @locale).html_safe %></td>
</tr>
</table>
<%= I18n.t('email.confirmation.body.main',
:pdf_url=>@pdf_url,
- :registrar_address=>@registrar_address.to_s.html_safe,
+ :home_state_email_instructions => @home_state_email_instructions,
+ :registrar_address=>@registrar_address,
:cancel_reminders_url=>@cancel_reminders_url,
- :registrar_phone=>@registrar_phone.to_s.html_safe,
- :registrar_url=>@registrar_url.to_s.html_safe, :locale => @registrant.locale.to_sym).html_safe %>
+ :registrar_phone=>@registrar_phone,
+ :registrar_url=>@registrar_url, :locale => @locale).html_safe %>
<hr size="3" align="left" width="100%" color="black"><br><br>
<%= I18n.t('email.confirmation.body.send_to_friends',
- :rtv_link=>rtv_link.to_s.html_safe,
- :registrant_first_name=>@registrant.first_name, :registrant_last_name=>@registrant.last_name, :locale => @registrant.locale.to_sym).html_safe %>
+ :rtv_link=>@rtv_link,
+ :registrant_first_name=>@registrant_first_name, :registrant_last_name=>@registrant_last_name, :locale => @locale).html_safe %>
<hr size="3" align="left" width="100%" color="black"><br><br>
-<%= I18n.t('email.confirmation.body.footer', :locale => @registrant.locale.to_sym).html_safe %>
+<%= I18n.t('email.confirmation.body.footer', :locale => @locale).html_safe %>
View
22 app/views/notifier/reminder.html.erb
@@ -1,4 +1,3 @@
-<% rtv_link = '<strong><a href="http://register.rockthevote.com/">register.rockthevote.com</a></strong>' %>
<style type="text/css">
<!--
.boxtext {
@@ -12,32 +11,33 @@
-->
</style>
-<%= I18n.t('email.reminder.body.greeting', :registrant_first_name=>@registrant.first_name, :registrant_last_name=>@registrant.last_name, :locale => @registrant.locale.to_sym).html_safe %><br><br>
+<%= I18n.t('email.reminder.body.greeting', :registrant_first_name=>@registrant_first_name, :registrant_last_name=>@registrant_last_name, :locale => @locale).html_safe %><br><br>
<table style="float: right; margin: 0 0 15px 15px; width: 275px; border: 8px solid #cc0000;color:black" width="275" cellspacing="0" cellpadding="10">
<tr>
- <td align="center" valign="middle" class="boxtext"><%= I18n.t('email.reminder.body.reminder', :locale => @registrant.locale.to_sym).html_safe %></td>
+ <td align="center" valign="middle" class="boxtext"><%= I18n.t('email.reminder.body.reminder', :locale => @locale).html_safe %></td>
</tr>
</table>
<%= I18n.t('email.reminder.body.main',
- :pdf_url=>@pdf_url,
- :registrar_address=>@registrar_address.to_s.html_safe,
+ :pdf_url=>@pdf_url,
+ :home_state_email_instructions => @home_state_email_instructions,
+ :registrar_address=>@registrar_address,
:cancel_reminders_url =>@cancel_reminders_url,
- :registrar_phone=> @registrar_phone.to_s.html_safe ,
- :registrar_url=>@registrar_url.to_s.html_safe,
- :rtv_link=>rtv_link.to_s.html_safe, :locale => @registrant.locale.to_sym
+ :registrar_phone=> @registrar_phone,
+ :registrar_url=>@registrar_url,
+ :rtv_link=>@rtv_link, :locale => @locale
).html_safe %>
<hr size="3" align="left" width="100%" color="black"><br><br>
<%= I18n.t('email.reminder.body.send_to_friends',
- :rtv_link=>rtv_link.to_s.html_safe,
- :registrant_first_name=>@registrant.first_name, :registrant_last_name=>@registrant.last_name, :locale => @registrant.locale.to_sym).html_safe %>
+ :rtv_link=>@rtv_link,
+ :registrant_first_name=>@registrant_first_name, :registrant_last_name=>@registrant_last_name, :locale => @locale).html_safe %>
<hr size="3" align="left" width="100%" color="black"><br><br>
-<%= I18n.t('email.reminder.body.footer', :locale => @registrant.locale.to_sym).html_safe %>
+<%= I18n.t('email.reminder.body.footer', :locale => @locale).html_safe %>
View
23 app/views/notifier/thank_you_external.html.erb
@@ -1,4 +1,3 @@
-<% rtv_link = '<strong><a href="http://register.rockthevote.com/">register.rockthevote.com</a></strong>' %>
<style type="text/css">
<!--
.boxtext {
@@ -13,23 +12,23 @@
</style>
<%= I18n.t('email.thank_you_external.body.main',
- :registrant_first_name=>@registrant.first_name,
- :registrant_last_name=>@registrant.last_name,
- :rtv_and_partner_name=>@registrant.rtv_and_partner_name.to_s.html_safe,
- :state_name=>@registrant.home_state_name.to_s.html_safe,
- :state_abbr=> @registrant.home_state_abbrev.to_s.html_safe,
- :registrar_phone=>@registrar_phone.to_s.html_safe,
- :registrar_url=>@registrar_url.to_s.html_safe, :locale => @registrant.locale.to_sym
+ :registrant_first_name=>@registrant_first_name,
+ :registrant_last_name=>@registrant_last_name,
+ :rtv_and_partner_name=>@registrant_rtv_and_partner_name,
+ :state_name=>@registrant_home_state_name,
+ :state_abbr=> @registrant_home_state_abbrev,
+ :registrar_phone=>@registrar_phone,
+ :registrar_url=>@registrar_url, :locale => @locale
).html_safe %>
<hr size="3" align="left" width="100%" color="black"><br><br>
<%= I18n.t('email.thank_you_external.body.send_to_friends',
- :rtv_link=>rtv_link.to_s.html_safe,
- :registrant_first_name=>@registrant.first_name,
- :registrant_last_name=>@registrant.last_name, :locale => @registrant.locale.to_sym
+ :rtv_link=>@rtv_link,
+ :registrant_first_name=>@registrant_first_name,
+ :registrant_last_name=>@registrant_last_name, :locale => @locale
).html_safe %>
<hr size="3" align="left" width="100%" color="black"><br><br>
-<%= I18n.t('email.thank_you_external.body.footer', :locale => @registrant.locale.to_sym).html_safe %>
+<%= I18n.t('email.thank_you_external.body.footer', :locale => @locale).html_safe %>
View
4 app/views/registrants/registrant_pdf.html.haml
@@ -19,6 +19,10 @@
%li= I18n.t('pdf.nvra.page1.instructions_block.step4' ).html_safe
%li= I18n.t('pdf.nvra.page1.instructions_block.step5' ).html_safe
%td.submit_block
+ - if !@registrant.home_state_pdf_instructions.blank?
+ .state_instructions
+ %p= @registrant.home_state_pdf_instructions.html_safe
+
%h4.title= I18n.t('pdf.nvra.page1.submit_block.title' ).html_safe
%p= @state.registrar_address.to_s.html_safe
%tr
View
2  config/deploy/staging2.rb
@@ -29,4 +29,4 @@
set :rails_env, "staging2"
-set :branch, "master"
+set :branch, "per_state_pdf_and_emails"
View
4 config/locales/email/en.yml
@@ -14,7 +14,8 @@ en:
<strong>Your registration is not yet complete. You are not registered until
you have turned in your form to your state election officials.</strong><br><br>
-
+
+ %{home_state_email_instructions}
If you have not already done so, <strong>please make sure to PRINT, SIGN,
STAMP, and MAIL your form to the address provided on the form and shown
@@ -93,6 +94,7 @@ en:
the Vote. You can download your application <a href="%{pdf_url}">by clicking
here</a>.<br><br>
+ %{home_state_email_instructions}
Just a reminder, if you have not already done so, <strong>please make sure
to PRINT, SIGN, STAMP, and MAIL your form to the address provided on the
View
9 config/locales/states/en.yml
@@ -481,4 +481,11 @@ en:
received_30_days: received 30 days before the election
received_at_least_30_days: received at least 30 days before the election
thirty_days_before: 30 days before the election
-
+ pdf_instructions:
+ blank: ''
+ arizona: ! '<b>Note for First Time Voter Registration Applicatns And Recent Movers: You must ALSO submit proof of citizenship to vote in state elections!</b><br/><i>If this is your first time registering in Arizona or you have moved to another county, your voter registration form must also include proof of citizenship to vote in state elections (ie. Governor, Secretary of State, &amp; state legislature). Otherwise you will ONLY be eleigible to vote in federal elections. If you have an AZ driver license or state ID card issued after 10/1/1996, that is suffient "proof of citizenship" and no other documentation is needed. If not, you must submit "proof of citizenship" along with your voter registration application. The most common "proof" is a photocopy of your birth certificate or passport. A full list of acceptable documentation can be found online.</i>'
+ kansas: ! '<b>Note for First Time Voter Registration Applicatns And Recent Movers: You must ALSO submit proof of citizenship to vote in state elections!</b><br/><i>If this is your first time registering in Kansas or you have moved to another county, your voter registration form must also include proof of citizenship to vote in state elections (ie. Governor, Secretary of State, &amp; state legislature). Otherwise you will ONLY be eleigible to vote in federal elections. If you have an KS driver license or state ID card issued after 10/1/1996, that is suffient "proof of citizenship" and no other documentation is needed. If not, you must submit "proof of citizenship" along with your voter registration application. The most common "proof" is a photocopy of your birth certificate or passport. A full list of acceptable documentation can be found online.</i>'
+ email_instructions:
+ blank: ''
+ arizona: ! '<b>Note for First Time Voter Registration Applicatns And Recent Movers: You must ALSO submit proof of citizenship to vote in state elections!</b><br/><i>If this is your first time registering in Arizona or you have moved to another county, your voter registration form must also include proof of citizenship to vote in state elections (ie. Governor, Secretary of State, &amp; state legislature). Otherwise you will ONLY be eleigible to vote in federal elections. If you have an AZ driver license or state ID card issued after 10/1/1996, that is suffient "proof of citizenship" and no other documentation is needed. If not, you must submit "proof of citizenship" along with your voter registration application. The most common "proof" is a photocopy of your birth certificate or passport. A full list of acceptable documentation can be found online.</i>'
+ kansas: ! '<b>Note for First Time Voter Registration Applicatns And Recent Movers: You must ALSO submit proof of citizenship to vote in state elections!</b><br/><i>If this is your first time registering in Kansas or you have moved to another county, your voter registration form must also include proof of citizenship to vote in state elections (ie. Governor, Secretary of State, &amp; state legislature). Otherwise you will ONLY be eleigible to vote in federal elections. If you have an KS driver license or state ID card issued after 10/1/1996, that is suffient "proof of citizenship" and no other documentation is needed. If not, you must submit "proof of citizenship" along with your voter registration application. The most common "proof" is a photocopy of your birth certificate or passport. A full list of acceptable documentation can be found online.</i>'
View
6 db/bootstrap/import/states.yml
@@ -16,6 +16,8 @@ defaults:
id_length_max: '60'
sub_18: turn_by_next_election
registration_deadline: postmarked_29_days
+ pdf_instructions: blank
+ email_instructions: blank
record_0:
abbreviation: AL
@@ -56,6 +58,8 @@ record_2:
sub_18: turn_by_next_general_election_november
online_registration_url: https://servicearizona.com/webapp/evoter/selectLanguage
registration_deadline: received_29_days
+ pdf_instructions: arizona
+ email_instructions: arizona
record_3:
abbreviation: AR
@@ -233,6 +237,8 @@ record_16:
sos_url: http://www.kssos.org/elections/elections.html
sub_18: be_by_next_general_election_november
registration_deadline: kansas
+ pdf_instructions: kansas
+ email_instructions: kansas
record_17:
View
2  db/fixtures/state_localizations.yml
@@ -131,6 +131,7 @@ arizona_en:
- None
no_party: Decline to State
sub_18: if you will turn 18 by the next election
+ email_instructions: arizona-email-instructions
arizona_es:
state_id: 3
locale: es
@@ -139,6 +140,7 @@ arizona_es:
- Coal
no_party: Se niega a declarar
sub_18: si va a cumplir 18 años de las próximas elecciones
+
nevada_en:
state_id: 29
locale: en
View
5 db/migrate/20140124151534_add_pdf_instructions_to_state_localizations.rb
@@ -0,0 +1,5 @@
+class AddPdfInstructionsToStateLocalizations < ActiveRecord::Migration
+ def change
+ add_column :state_localizations, :pdf_instructions, :string
+ end
+end
View
5 db/migrate/20140124153314_add_email_instructions_to_state_localizations.rb
@@ -0,0 +1,5 @@
+class AddEmailInstructionsToStateLocalizations < ActiveRecord::Migration
+ def change
+ add_column :state_localizations, :email_instructions, :string
+ end
+end
View
4 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140123131546) do
+ActiveRecord::Schema.define(:version => 20140124153314) do
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0
@@ -216,6 +216,8 @@
t.string "party_tooltip", :limit => 1024
t.string "sub_18"
t.string "registration_deadline"
+ t.string "pdf_instructions"
+ t.string "email_instructions"
end
add_index "state_localizations", ["state_id"], :name => "index_state_localizations_on_state_id"
View
2  lib/state_importer.rb
@@ -42,7 +42,7 @@ def self.state_settings
#list of conf_keys with values that are I18n key-parts
def self.state_localizations
- %w(not_participating_tooltip race_tooltip party_tooltip no_party id_number_tooltip sub_18 registration_deadline)
+ %w(not_participating_tooltip race_tooltip party_tooltip no_party id_number_tooltip sub_18 registration_deadline pdf_instructions email_instructions)
end
#list of conf_keys with values that are arrays
View
BIN  rocky_development
Binary file not shown
View
21 spec/lib/state_importer_spec.rb
@@ -44,6 +44,9 @@
id_length_min: '6'
id_length_max: '60'
sub_18: turn_by_next_election
+ registration_deadline: postmarked_29_days
+ pdf_instructions: blank
+ email_instructions: blank
record_0:
abbreviation: AL
name: Alabama
@@ -59,6 +62,8 @@
sos_address: sos_address
sos_phone: sos_phone
sos_url: sos_url
+ registration_deadline: postmarked_30_days
+ email_instructions: alabama
record_1:
abbreviation: AK
name: Alaska
@@ -70,6 +75,7 @@
sos_address: sos_address
sos_phone: sos_phone
sos_url: sos_url
+ pdf_instructions: arkansas
record_2:
abbreviation: AZ
name: Arizona
@@ -105,11 +111,13 @@
assert_equal "sos_address", state.registrar_address
assert_equal "sos_phone", state.registrar_phone
assert_equal "sos_url", state.registrar_url
+
state = GeoState['AK']
assert_equal false, state.participating
assert_equal 10, state.id_length_min
assert_equal 13, state.id_length_max
+
state = GeoState['AZ']
assert_equal true, state.participating
@@ -152,11 +160,24 @@
assert_equal I18n.t('states.tooltips.not_participating.new_hampshire').strip, en.not_participating_tooltip
assert_equal I18n.t('states.tooltips.race.virginia').strip, en.race_tooltip
assert_equal %w(Independent Green), en.parties
+ assert_equal I18n.t('states.registration_deadline.postmarked_30_days'), en.registration_deadline
+ assert_equal I18n.t('states.pdf_instructions.blank'), en.pdf_instructions
+ assert_equal I18n.t('states.email_instructions.alabama'), en.email_instructions
es = state.localizations.find_by_locale!('es')
assert_equal I18n.t('states.tooltips.not_participating.new_hampshire', :locale=>:es).strip, es.not_participating_tooltip
assert_equal I18n.t('states.tooltips.race.virginia', :locale=>:es).strip, es.race_tooltip
assert_equal %w(Independiente Verde), es.parties
+ assert_equal I18n.t('states.registration_deadline.postmarked_30_days', :locale=>:es), es.registration_deadline
+ assert_equal I18n.t('states.pdf_instructions.blank', :locale=>:es), es.pdf_instructions
+ assert_equal I18n.t('states.email_instructions.alabama', :locale=>:es), es.email_instructions
+
+ state = GeoState['AK']
+ en = state.localizations.find_by_locale!('en')
+ assert_equal I18n.t('states.registration_deadline.postmarked_29_days'), en.registration_deadline
+ assert_equal I18n.t('states.pdf_instructions.arkansas'), en.pdf_instructions
+ assert_equal I18n.t('states.email_instructions.blank'), en.email_instructions
+
end
View
10 spec/mailers/notifier_spec.rb
@@ -68,6 +68,7 @@
email.body.should include("this-is-the-phone")
email.body.should include("this-is-the-address")
email.body.should include("this-is-the-url")
+
end
it "includes cancel reminders link" do
@@ -80,6 +81,15 @@
email.from.should include(RockyConf.from_address)
end
+
+ it "includes state-specific note" do
+ registrant = FactoryGirl.create(:maximal_registrant, :home_state=>GeoState['AZ'])
+ assert_difference('ActionMailer::Base.deliveries.size', 1) do
+ Notifier.confirmation(registrant).deliver
+ end
+ email = ActionMailer::Base.deliveries.last
+ email.body.should include("arizona-email-instructions")
+ end
it "uses partner template" do
partner = FactoryGirl.create(:partner, :whitelabeled => true)
View
12 spec/models/registrant_spec.rb
@@ -229,6 +229,18 @@
assert_nil Registrant.new(:home_state_id => 1).localization
assert_nil Registrant.new(:locale => "en").localization
end
+
+ [:pdf_instructions, :email_instructions].each do |state_data|
+ describe "home_state_#{state_data}" do
+ it "reads #{state_data} from the locatlization" do
+ reg = Registrant.new
+ mock_localization = mock(StateLocalization)
+ mock_localization.should_receive(state_data).and_return "a value"
+ reg.stub(:localization).and_return(mock_localization)
+ reg.send("home_state_#{state_data}").should == "a value"
+ end
+ end
+ end
end
describe "any step" do
View
1  spec/models/state_localization_spec.rb
@@ -40,4 +40,5 @@
assert_equal kilo_chars, loc.id_number_tooltip
end
end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.