diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index d07b069..2cd293c 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -110,7 +110,7 @@ class AccountController < ApplicationController check_join_in_community(@user) go_to_signup_initial_page else - redirect_to :controller => :home, :action => :welcome + redirect_to :controller => :home, :action => :welcome, :template_id => @user.person.template.id end end end @@ -442,7 +442,7 @@ class AccountController < ApplicationController when 'user_control_panel' redirect_to user.admin_url when 'welcome_page' - redirect_to :controller => :home, :action => :welcome + redirect_to :controller => :home, :action => :welcome, :template_id => user.template.id else redirect_back_or_default(default) end diff --git a/app/controllers/public/home_controller.rb b/app/controllers/public/home_controller.rb index 7ed1c94..e34e754 100644 --- a/app/controllers/public/home_controller.rb +++ b/app/controllers/public/home_controller.rb @@ -21,6 +21,8 @@ class HomeController < PublicController def welcome self.class.no_design_blocks @display_confirmation_tips = !user.present? && !environment.enabled?(:skip_new_user_email_confirmation) + @person_template = Person.find(params[:template_id]) + @template_welcome_page = @person_template.welcome_page && @person_template.welcome_page.published ? @person_template.welcome_page.body : nil end end diff --git a/app/views/home/welcome.html.erb b/app/views/home/welcome.html.erb index 58b36b0..9bb55c4 100644 --- a/app/views/home/welcome.html.erb +++ b/app/views/home/welcome.html.erb @@ -1,8 +1,8 @@
+

<%= _("Welcome to %s!") % environment.name %>

<% if environment.has_custom_welcome_screen? %> <%= environment.settings[:signup_welcome_screen_body].html_safe %> <% else %> -

<%= _("Welcome to %s!") % environment.name %>

<%= _("Thanks for signing up, we're thrilled to have you on our social network!") %>

<%= _("Firstly, some tips for getting started:") %>

<% if @display_confirmation_tips %> @@ -16,4 +16,8 @@

<%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %>

<%= _("Start exploring and have fun!") %>

<% end %> + <% if @template_welcome_page.present? %> +

<%= _("What can I do as a %s?") % @person_template.name %>

+ <%= @template_welcome_page.html_safe %> + <% end %>
diff --git a/test/functional/home_controller_test.rb b/test/functional/home_controller_test.rb index 855c61e..e2e80bb 100644 --- a/test/functional/home_controller_test.rb +++ b/test/functional/home_controller_test.rb @@ -130,4 +130,34 @@ class HomeControllerTest < ActionController::TestCase assert_no_tag :tag => 'a', :attributes => {:href => '/account/signup'} end + should 'display template welcome page' do + template = create_user('template').person + template.is_template = true + welcome_page = TinyMceArticle.create!(:name => 'Welcome page', :profile => template, :published => true, :body => 'Template welcome page') + template.welcome_page = welcome_page + template.save! + get :welcome, :template_id => template.id + assert_equal welcome_page.body, assigns(:template_welcome_page) + assert_match /#{welcome_page.body}/, @response.body + end + + should 'not display template welcome page if it is not published' do + template = create_user('template').person + template.is_template = true + welcome_page = TinyMceArticle.create!(:name => 'Welcome page', :profile => template, :published => false) + template.welcome_page = welcome_page + template.save! + get :welcome, :template_id => template.id + assert_nil assigns(:template_welcome_page) + end + + should 'not crash template doess not have a welcome page' do + template = create_user('template').person + template.is_template = true + template.save! + assert_nothing_raised do + get :welcome, :template_id => template.id + end + end + end -- libgit2 0.21.2