make language for email-invitation available

This commit is contained in:
Lennart Prelle 2011-10-16 17:13:21 +02:00
parent aaafeb27e4
commit f2123d942d
9 changed files with 93 additions and 38 deletions

View file

@ -23,7 +23,9 @@ class InvitationsController < Devise::InvitationsController
#NOTE should we try and find users by email here? probs
aspect = current_user.aspects.find(aspect_id)
invites = Invitation.batch_invite(emails, :message => message, :sender => current_user, :aspect => aspect, :service => 'email')
language = params[:user][:language]
invites = Invitation.batch_invite(emails, :message => message, :sender => current_user, :aspect => aspect, :service => 'email', :language => language)
flash[:notice] = extract_messages(invites)

View file

@ -8,7 +8,7 @@ class Invitation < ActiveRecord::Base
belongs_to :recipient, :class_name => 'User'
belongs_to :aspect
attr_accessible :sender, :recipient, :aspect, :service, :identifier, :admin, :message
attr_accessible :sender, :recipient, :aspect, :language, :service, :identifier, :admin, :message
before_validation :set_email_as_default_service
@ -48,6 +48,7 @@ class Invitation < ActiveRecord::Base
emails
end
# Downcases the incoming service identifier and assigns it
#
# @param ident [String] Service identifier

View file

@ -9,8 +9,10 @@ module Jobs
@queue = :mail
def self.perform(invite_id)
invite = Invitation.find(invite_id)
I18n.with_locale(invite.language) do
invite.send!
end
end
end
end
end

View file

@ -3,7 +3,7 @@
<head>
<title><%=invite_email_title %></title>
</head>
<p style="background-color: rgb(255, 255, 255); text-align: center; font-size: 11px;">Email not displaying correctly? <a href="<%=invite_email_url(:invitation_token => @resource.invitation_token) %>" style="color: #3F8FBA; text-decoration: none;">View it</a> in your browser</p>
<p style="background-color: rgb(255, 255, 255); text-align: center; font-size: 11px;"><%= t('.displaying_correctly', :link => link_to(t('.view_in'), invite_email_url(:invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: none;")).html_safe %> </p>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td style="padding: 30px 15px 0pt; background-color: rgb(221, 221, 221);">
<table style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 16px; color: rgb(51, 51, 51);" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
@ -20,7 +20,7 @@
<tr>
<td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
Finally - it's here.<br>
<%= t('.finally') %><br>
</td>
</tr>
@ -30,10 +30,10 @@
<tr><td style="padding: 0pt 30px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: 20px;">
The social network you have been waiting for has arrived. Revamped, more secure, and more fun, <strong>DIASPORA*</strong> is ready to help you share and explore the web in a whole new way.
<%= t('.arrived', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<br>
<a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="<%= accept_invitation_url(@resource, :invitation_token => @resource.invitation_token)%>" target="_blank">Sign up now &rarr;</a>
<%= link_to(t('.sign_up_now').html_safe, accept_invitation_url(@resource, :invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
</td></tr>
@ -43,7 +43,7 @@
<tr>
<td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 24px; font-weight: bold; color: rgb(0, 0, 0);">
<br>
What your friends are saying...<br>
<%= t('.friends_saying') %><br>
</td>
</tr>
@ -59,7 +59,7 @@
<tr>
<td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 24px; font-weight: bold; color: rgb(0, 0, 0);">
<br>
Even more people are excited to see you!<br>
<%= t('.more_people') %><br>
</td>
</tr>
@ -77,7 +77,7 @@
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
1. Get Connected</td></tr>
1. <%= t('.get_connected') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
@ -85,7 +85,7 @@
<a href="<%=accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %>" target="_blank"><img style="border: 0pt none ; padding: 0pt 10px 0px 5px; display: block;" src="https://joindiaspora.s3.amazonaws.com/uploads/images/scaled_full_c7506ec0b3ae6694c64d.gif" height="156" width="200"></a>
</td>
<td style="line-height: 20px; width: 360px;">
An international movement with a shared vision for a better web, DIASPORA*'s #1 feature is its community. Meet new people, connect with friends, and join the fun.
<%= t('.get_connected_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="https://joindiaspora.com/channels" target="_blank">Tune in to your favorite Channels</a>-->
</td>
@ -94,14 +94,14 @@
</td></tr>
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
2. Be Yourself</td></tr>
2. <%= t('.be_yourself') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
<td style="line-height: 20px; width: 360px;">
The Internet has created unique new ways for us to express ourselves.
<strong>DIASPORA*</strong> lets you be yourself and share however you want, with or without your real name.
<%= t('.be_yourself_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>-->
</td>
@ -115,7 +115,7 @@
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
3. Have Fun</td></tr>
3. <%= t('.have_fun') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
@ -123,11 +123,8 @@
<a href="<%= accept_invitation_url(@resource, :invitation_token => @resource.invitation_token)%>" target="_blank"><img style="border: 0pt none ; padding: 0pt 5px; display: block;" src="http://joindiaspora.com/images/cubbies_screenshot2.png" height="151" width="200"></a>
</td>
<td style="line-height: 20px; width: 360px;">
<strong>DIASPORA*</strong> is all about discovering amazing new content and people online.
<a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="https://cubbi.es" target="_blank">Cubbi.es</a>,
the world's first <strong>DIASPORA*</strong> application is just the begining.
Collect and share the web in all of its glory.
<%= t('.have_fun_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :link => link_to(t('.cubbies'), "https://cubbi.es", :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank")).html_safe %>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>-->
</td>
</tr>
@ -139,7 +136,7 @@
<tbody>
<tr>
<td style="padding: 40px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="<%=accept_invitation_url(@resource, :invitation_token => @resource.invitation_token)%>" target="_blank">Sign up now &rarr;</a>
<%= link_to(t('.sign_up_now').html_safe, accept_invitation_url(@resource, :invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
</td>
</tr>
</tbody>
@ -151,9 +148,8 @@
<tbody>
<tr>
<td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<strong>DIASPORA*</strong> is made by people who love the Internet as much as you do.
<a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;" href="https://github.com/diaspora/diaspora/wiki/Become-a-Contributor" target="_blank">Join our team</a>, or
<a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG4L6VYD8YGPU" target="_blank">help fund Diaspora</a>!
<%= t('.made_by_people', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :jointeam => link_to(t('.join_team'), "https://github.com/diaspora/diaspora/wiki/Become-a-Contributor", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank"), :helpfund => link_to(t('.help_fund'), "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG4L6VYD8YGPU", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank")).html_safe %>
</td>
</tr>
</tbody>
@ -161,12 +157,14 @@
</td></tr>
<tr><td style="padding: 35px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
Love,<br>
Team Diaspora<br>
<%= t('.love') %><br>
<%= t('.team_diaspora') %><br>
</td></tr>
<tr><td style="padding: 35px 40px; font-size: 11px; color: rgb(102, 102, 102); line-height: 16px;">
To unsubscribe please click <a style="color: #3F8FBA; text-decoration: none;" href="http://joindiaspora.us1.list-manage.com/unsubscribe?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b">here</a>.
For general inquiries or support with your Diaspora account, please email us at <a style="color: #3F8FBA; text-decoration: none;" href="mailto:questions@joindiaspora.com">questions@joindiaspora.com</a>.
<% if AppConfig[:pod_uri].host.match(/joindiaspora.com/) %>
<%= t('.unsubscribe', :link => link_to(t('.here'), "http://joindiaspora.us1.list-manage.com/unsubscribe?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
<% end %>
<%= t('.email_us', :email => link_to(t('.email_address'), "mailto:questions@joindiaspora.com", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
</td></tr>
</tbody>
</table>

View file

@ -23,6 +23,13 @@
%br
%br
%h4
= t('.language')
= invite.select(:language, available_language_options, :selected => current_user.language)
%br
%br
%h4
= t('.personal_message')
= invite.text_area :invite_messages, :rows => 3, :value => ""

View file

@ -73,6 +73,30 @@ en:
click_to_unlock: "Click the link below to unlock your account:"
unlock: "Unlock my account"
invitation_instructions:
displaying_correctly: "Email not displaying correctly? %{link} in your browser"
view_in: "View in"
finally: "Finally - it's here"
arrived: "The social network you have been waiting for has arrived. Revamped, more secure, and more fun, %{strong_diaspora} is ready to help you share and explore the web in a whole new way."
sign_up_now: "Sign up now &rarr;"
friends_saying: "What your friends are saying..."
more_people: "Even more people are excited to see you!"
get_connected: "Get Connected"
get_connected_paragraph: "An international movement with a shared vision for a better web, %{strong_diaspora}'s #1 feature is its community. Meet new people, connect with friends, and join the fun."
be_yourself: "Be Yourself"
be_yourself_paragraph: "The Internet has created unique new ways for us to express ourselves. %{strong_diaspora} lets you be yourself and share however you want, with or without your real name."
have_fun: "Have Fun"
cubbies: "Cubbi.es"
have_fun_paragraph: "%{strong_diaspora} is all about discovering amazing new content and people online. %{link}, the world's first %{strong_diaspora} application is just the begining. Collect and share the web in all of its glory."
made_by_people: "%{strong_diaspora} is made by people who love the Internet as much as you do. %{jointeam}, or %{helpfund}!"
join_team: "Join our Team"
or: "or"
help_fund: "help fund Diaspora"
unsubscribe: "To unsubscribe please click %{link}."
here: "here"
love: "Love,"
team_diaspora: "Team Diaspora"
email_us: "For general inquiries or support with your Diaspora account, please email us at %{email}."
email_address: "questions@joindiaspora.com"
subject: "You've been invited to join Diaspora!"
accept: "Accept invitation"
ignore: "If you don't want to accept the invitation, please ignore this email."

View file

@ -318,6 +318,7 @@ en:
already_contacts: "You are already connected with this person"
own_address: "You can't send an invitation to your own address."
new:
language: "Language"
invite_someone_to_join: "Invite someone to join Diaspora!"
if_they_accept_info: "if they accept, they will be added to the aspect you invited them."
comma_seperated_plz: "You can enter multiple email addresses separated by commas."

View file

@ -0,0 +1,9 @@
class AddLanguageToInvitations < ActiveRecord::Migration
def self.up
add_column :invitations, :language, :string, :default => "en"
end
def self.down
remove_column :invitations, :language
end
end

View file

@ -13,13 +13,14 @@ describe Invitation do
end
describe 'validations' do
before do
@invitation = Factory.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first)
@invitation = Factory.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first, :language => "de")
end
it 'is valid' do
@invitation.sender.should == user
@invitation.recipient.should == nil
@invitation.aspect.should == user.aspects.first
@invitation.language.should == "de"
@invitation.should be_valid
end
@ -29,20 +30,30 @@ describe Invitation do
end
end
it 'has a message' do
describe '#language' do
it 'returns the correct language if the language is set' do
@invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => "de")
@invitation.language.should == "de"
end
it 'returns en if no language is set' do
@invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first)
@invitation.language.should == "en"
end
end
it 'has a message' do
@invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => user.language)
@invitation.message = "!"
@invitation.message.should == "!"
end
describe 'the invite process' do
before do
end
it 'works for a new user' do
invite = Invitation.new(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'foo@bar.com')
invite = Invitation.new(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'foo@bar.com', :language => alice.language)
lambda {
invite.save
invite.send!
@ -50,7 +61,7 @@ describe Invitation do
end
it 'works for a current user(with the right email)' do
invite = Invitation.create(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => bob.email)
invite = Invitation.create(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => bob.email, :language => alice.language)
lambda {
invite.send!
}.should_not change(User, :count)
@ -80,7 +91,7 @@ describe Invitation do
describe '.batch_invite' do
before do
@emails = ['max@foo.com', 'bob@mom.com']
@opts = {:aspect => eve.aspects.first, :sender => eve, :service => 'email'}
@opts = {:aspect => eve.aspects.first, :sender => eve, :service => 'email', :language => eve.language}
end
it 'returns an array of invites based on the emails passed in' do
@ -102,7 +113,7 @@ describe Invitation do
describe 'send' do
before do
@invitation = Factory(:invitation, :sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'a@a.com')
@invitation = Factory(:invitation, :sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'a@a.com' , :language => alice.language)
end
it 'sends an email' do
@ -133,7 +144,7 @@ describe Invitation do
describe '#recipient_identifier' do
it 'calls email if the invitation_service is email' do
email = 'abc@abc.com'
invitation = Factory(:invitation, :sender => alice, :service => 'email', :identifier => email, :aspect => alice.aspects.first)
invitation = Factory(:invitation, :sender => alice, :service => 'email', :identifier => email, :aspect => alice.aspects.first, :language => alice.language)
invitation.recipient_identifier.should == email
end