Skip to content
Extraits de code Groupes Projets
Valider 066f8d12 rédigé par Dan Hansen's avatar Dan Hansen
Parcourir les fichiers

Mention the person who invited a user on first message

parent 3118f7a0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -11,11 +11,21 @@ module InterimStreamHackinessHelper ...@@ -11,11 +11,21 @@ module InterimStreamHackinessHelper
end end
##### These methods need to go away once we pass publisher object into the partial ###### ##### These methods need to go away once we pass publisher object into the partial ######
def publisher_prefill_text def publisher_formatted_text
if params[:prefill].present? if params[:prefill].present?
params[:prefill] params[:prefill]
elsif defined?(@stream) elsif defined?(@stream)
@stream.publisher.prefill @stream.publisher.text
else
nil
end
end
def publisher_hidden_text
if params[:prefill].present?
params[:prefill]
elsif defined?(@stream)
@stream.publisher.prefill
else else
nil nil
end end
......
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
#publisher_textarea_wrapper #publisher_textarea_wrapper
= link_to( image_tag('deletelabel.png'), "#", :id => "hide_publisher", :title => t('.discard_post')) = link_to( image_tag('deletelabel.png'), "#", :id => "hide_publisher", :title => t('.discard_post'))
%ul#photodropzone %ul#photodropzone
= status.text_area :fake_text, :rows => 2, :value => h(publisher_prefill_text), :tabindex => 1, :placeholder => t('.whats_on_your_mind'), = status.text_area :fake_text, :rows => 2, :value => h(publisher_formatted_text), :tabindex => 1, :placeholder => t('.whats_on_your_mind'),
:title => "1. #{t('shared.public_explain.share')}", 'data-content' => t('shared.public_explain.new_user_welcome_message') :title => "1. #{t('shared.public_explain.share')}", 'data-content' => t('shared.public_explain.new_user_welcome_message')
= status.hidden_field :text, :value => '', :class => 'clear_on_submit' = status.hidden_field :text, :value => h(publisher_hidden_text), :class => 'clear_on_submit'
#file-upload{:title => t('.upload_photos')} #file-upload{:title => t('.upload_photos')}
= image_tag 'icons/camera.svg', :height => 14 = image_tag 'icons/camera.svg', :height => 14
......
...@@ -742,7 +742,8 @@ en: ...@@ -742,7 +742,8 @@ en:
discard_post: "Discard post" discard_post: "Discard post"
new_user_prefill: new_user_prefill:
hello: "Hey everyone, I'm #%{new_user_tag}. " hello: "Hey everyone, I'm #%{new_user_tag}. "
i_like: "I'm interested in %{tags}." i_like: "I'm interested in %{tags}. "
invited_by: "Thanks for the invite, "
add_contact: add_contact:
enter_a_diaspora_username: "Enter a Diaspora username:" enter_a_diaspora_username: "Enter a Diaspora username:"
your_diaspora_username_is: "Your Diaspora username is: %{diaspora_handle}" your_diaspora_username_is: "Your Diaspora username is: %{diaspora_handle}"
......
...@@ -3,10 +3,14 @@ class Publisher ...@@ -3,10 +3,14 @@ class Publisher
def initialize(user, opts={}) def initialize(user, opts={})
self.user = user self.user = user
self.open = (opts[:open] == true)? true : false self.open = opts[:open]
self.prefill = opts[:prefill] self.prefill = opts[:prefill]
self.public = (opts[:public] == true)? true : false self.public = opts[:public]
self.explain = (opts[:explain] == true)? true : false self.explain = opts[:explain]
end
def text
formatted_message
end end
def open? def open?
...@@ -20,4 +24,12 @@ class Publisher ...@@ -20,4 +24,12 @@ class Publisher
def explain? def explain?
self.explain self.explain
end end
private
def formatted_message
if self.prefill.present?
StatusMessage.new(:text => self.prefill).
format_mentions(self.prefill, :plain_text => true)
end
end
end end
...@@ -55,6 +55,11 @@ class Stream::Multi < Stream::Base ...@@ -55,6 +55,11 @@ class Stream::Multi < Stream::Base
prefill << I18n.t("shared.publisher.new_user_prefill.i_like", :tags => tag_string) prefill << I18n.t("shared.publisher.new_user_prefill.i_like", :tags => tag_string)
end end
if inviter = self.user.invited_by.try(:person)
prefill << I18n.t("shared.publisher.new_user_prefill.invited_by")
prefill << "@{#{inviter.name} ; #{inviter.diaspora_handle}}!"
end
prefill prefill
end end
......
...@@ -489,7 +489,10 @@ var Publisher = { ...@@ -489,7 +489,10 @@ var Publisher = {
}); });
Publisher.autocompletion.initialize(); Publisher.autocompletion.initialize();
Publisher.hiddenInput().val(Publisher.input().val());
if(Publisher.hiddenInput().val() === "") {
Publisher.hiddenInput().val(Publisher.input().val());
}
Publisher.input().autoResize(); Publisher.input().autoResize();
Publisher.input().keydown(Publisher.autocompletion.keyDownHandler); Publisher.input().keydown(Publisher.autocompletion.keyDownHandler);
Publisher.input().keyup(Publisher.autocompletion.keyUpHandler); Publisher.input().keyup(Publisher.autocompletion.keyUpHandler);
......
...@@ -9,8 +9,6 @@ describe Publisher do ...@@ -9,8 +9,6 @@ describe Publisher do
@publisher = Publisher.new(alice) @publisher = Publisher.new(alice)
end end
describe "#prefill" do describe "#prefill" do
it 'defaults to nothing' do it 'defaults to nothing' do
@publisher.prefill.should be_blank @publisher.prefill.should be_blank
...@@ -21,6 +19,13 @@ describe Publisher do ...@@ -21,6 +19,13 @@ describe Publisher do
end end
end end
describe '#text' do
it 'is a formatted version of the prefill' do
p = Publisher.new(alice, :prefill => "@{ alice ; alice@pod.com }")
p.text.should == "alice"
end
end
["open", "public", "explain"].each do |property| ["open", "public", "explain"].each do |property|
describe "##{property}?" do describe "##{property}?" do
......
...@@ -44,11 +44,25 @@ describe Stream::Multi do ...@@ -44,11 +44,25 @@ describe Stream::Multi do
end end
it 'returns includes new user hashtag' do it 'returns includes new user hashtag' do
@stream.send(:publisher_prefill).include?("#NewHere").should be_true @stream.send(:publisher_prefill).should include("#NewHere")
end end
it 'includes followed hashtags' do it 'includes followed hashtags' do
@stream.send(:publisher_prefill).include?("#cats").should be_true @stream.send(:publisher_prefill).should include("#cats")
end
context 'when invited by another user' do
before do
@user = Factory(:user, :invited_by => alice)
@inviter = alice.person
@stream = Stream::Multi.new(@user)
end
it 'includes a mention of the inviter' do
mention = "@{#{@inviter.name} ; #{@inviter.diaspora_handle}}"
@stream.send(:publisher_prefill).should include(mention)
end
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter