Commit 806ee6d5c2586e153cc9839d68226c42442fa16f

Authored by Rodrigo Souto
1 parent 182685eb

[template-welcome-page] Display person template welcome page

(ActionItem3075)
app/controllers/public/account_controller.rb
... ... @@ -110,7 +110,7 @@ class AccountController < ApplicationController
110 110 check_join_in_community(@user)
111 111 go_to_signup_initial_page
112 112 else
113   - redirect_to :controller => :home, :action => :welcome
  113 + redirect_to :controller => :home, :action => :welcome, :template_id => @user.person.template.id
114 114 end
115 115 end
116 116 end
... ... @@ -442,7 +442,7 @@ class AccountController < ApplicationController
442 442 when 'user_control_panel'
443 443 redirect_to user.admin_url
444 444 when 'welcome_page'
445   - redirect_to :controller => :home, :action => :welcome
  445 + redirect_to :controller => :home, :action => :welcome, :template_id => user.template.id
446 446 else
447 447 redirect_back_or_default(default)
448 448 end
... ...
app/controllers/public/home_controller.rb
... ... @@ -21,6 +21,8 @@ class HomeController < PublicController
21 21 def welcome
22 22 self.class.no_design_blocks
23 23 @display_confirmation_tips = !user.present? && !environment.enabled?(:skip_new_user_email_confirmation)
  24 + @person_template = Person.find(params[:template_id])
  25 + @template_welcome_page = @person_template.welcome_page && @person_template.welcome_page.published ? @person_template.welcome_page.body : nil
24 26 end
25 27  
26 28 end
... ...
app/views/home/welcome.html.erb
1 1 <div id='thanks-for-signing'>
  2 + <h1><%= _("Welcome to %s!") % environment.name %></h1>
2 3 <% if environment.has_custom_welcome_screen? %>
3 4 <%= environment.settings[:signup_welcome_screen_body].html_safe %>
4 5 <% else %>
5   - <h1><%= _("Welcome to %s!") % environment.name %></h1>
6 6 <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3>
7 7 <p><%= _("Firstly, some tips for getting started:") %></p>
8 8 <% if @display_confirmation_tips %>
... ... @@ -16,4 +16,8 @@
16 16 <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p>
17 17 <p><%= _("Start exploring and have fun!") %></p>
18 18 <% end %>
  19 + <% if @template_welcome_page.present? %>
  20 + <h1><%= _("What can I do as a %s?") % @person_template.name %></h1>
  21 + <%= @template_welcome_page.html_safe %>
  22 + <% end %>
19 23 </div>
... ...
test/functional/home_controller_test.rb
... ... @@ -130,4 +130,34 @@ class HomeControllerTest &lt; ActionController::TestCase
130 130 assert_no_tag :tag => 'a', :attributes => {:href => '/account/signup'}
131 131 end
132 132  
  133 + should 'display template welcome page' do
  134 + template = create_user('template').person
  135 + template.is_template = true
  136 + welcome_page = TinyMceArticle.create!(:name => 'Welcome page', :profile => template, :published => true, :body => 'Template welcome page')
  137 + template.welcome_page = welcome_page
  138 + template.save!
  139 + get :welcome, :template_id => template.id
  140 + assert_equal welcome_page.body, assigns(:template_welcome_page)
  141 + assert_match /#{welcome_page.body}/, @response.body
  142 + end
  143 +
  144 + should 'not display template welcome page if it is not published' do
  145 + template = create_user('template').person
  146 + template.is_template = true
  147 + welcome_page = TinyMceArticle.create!(:name => 'Welcome page', :profile => template, :published => false)
  148 + template.welcome_page = welcome_page
  149 + template.save!
  150 + get :welcome, :template_id => template.id
  151 + assert_nil assigns(:template_welcome_page)
  152 + end
  153 +
  154 + should 'not crash template doess not have a welcome page' do
  155 + template = create_user('template').person
  156 + template.is_template = true
  157 + template.save!
  158 + assert_nothing_raised do
  159 + get :welcome, :template_id => template.id
  160 + end
  161 + end
  162 +
133 163 end
... ...