Commit 3dc53d33a5e6309c6a07de0f7f47bc68acd33f09
1 parent
c5257df0
Exists in
master
and in
29 other branches
[template-welcome-page] Community template welcome page
Showing
3 changed files
with
27 additions
and
4 deletions
Show diff stats
app/controllers/my_profile/memberships_controller.rb
@@ -20,9 +20,22 @@ class MembershipsController < MyProfileController | @@ -20,9 +20,22 @@ class MembershipsController < MyProfileController | ||
20 | @community.environment = environment | 20 | @community.environment = environment |
21 | @back_to = params[:back_to] || url_for(:action => 'index') | 21 | @back_to = params[:back_to] || url_for(:action => 'index') |
22 | if request.post? && @community.valid? | 22 | if request.post? && @community.valid? |
23 | - @community = Community.create_after_moderation(user, params[:community].merge({:environment => environment})) | ||
24 | - redirect_to @back_to | 23 | + begin |
24 | + # Community was created | ||
25 | + @community = Community.create_after_moderation(user, params[:community].merge({:environment => environment})) | ||
26 | + @community.reload | ||
27 | + redirect_to :action => 'welcome', :community_id => @community.id, :back_to => @back_to | ||
28 | + rescue ActiveRecord::RecordNotFound | ||
29 | + # Community pending approval | ||
30 | + session[:notice] = _('Your community creation request is waiting approval of the administrator.') | ||
31 | + redirect_to @back_to | ||
32 | + end | ||
25 | return | 33 | return |
26 | end | 34 | end |
27 | end | 35 | end |
36 | + | ||
37 | + def welcome | ||
38 | + @community = Community.find(params[:community_id]) | ||
39 | + @back_to = params[:back_to] | ||
40 | + end | ||
28 | end | 41 | end |
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +<h1><%= __('Community created') %></h1> | ||
2 | +<p><%= __("Your community (%s) was successfully created.") % @community.name %></p> | ||
3 | +<p><%= link_to __('You can manage your community now.'), @community.admin_url %></p> | ||
4 | + | ||
5 | +<%= render :partial => 'shared/template_welcome_page', :locals => {:template => @community.template, :header => _("What can I do with a community?")} %> | ||
6 | + | ||
7 | +<% button_bar do%> | ||
8 | + <%= button :back, _('Back'), @back_to %> | ||
9 | +<% end %> |
test/functional/memberships_controller_test.rb
@@ -35,7 +35,6 @@ class MembershipsControllerTest < ActionController::TestCase | @@ -35,7 +35,6 @@ class MembershipsControllerTest < ActionController::TestCase | ||
35 | assert_difference 'Community.count' do | 35 | assert_difference 'Community.count' do |
36 | post :new_community, :profile => profile.identifier, :community => { :name => 'My shiny new community', :description => 'This is a community devoted to anything interesting we find in the internet '} | 36 | post :new_community, :profile => profile.identifier, :community => { :name => 'My shiny new community', :description => 'This is a community devoted to anything interesting we find in the internet '} |
37 | assert_response :redirect | 37 | assert_response :redirect |
38 | - assert_redirected_to :action => 'index' | ||
39 | 38 | ||
40 | assert Community.find_by_identifier('my-shiny-new-community').members.include?(profile), "Creator user should be added as member of the community just created" | 39 | assert Community.find_by_identifier('my-shiny-new-community').members.include?(profile), "Creator user should be added as member of the community just created" |
41 | end | 40 | end |
@@ -238,8 +237,10 @@ class MembershipsControllerTest < ActionController::TestCase | @@ -238,8 +237,10 @@ class MembershipsControllerTest < ActionController::TestCase | ||
238 | assert_tag :tag => 'input', :attributes => {:id => 'community_plugin2', :type => 'hidden', :value => 'Plugin 2'} | 237 | assert_tag :tag => 'input', :attributes => {:id => 'community_plugin2', :type => 'hidden', :value => 'Plugin 2'} |
239 | end | 238 | end |
240 | 239 | ||
241 | - should 'redirect to back_to parameter when create a new community' do | 240 | + should 'redirect to back_to parameter when community needs admin approval' do |
242 | back_to = '/' | 241 | back_to = '/' |
242 | + environment = Environment.default | ||
243 | + environment.enable('admin_must_approve_new_communities') | ||
243 | post :new_community, :profile => profile.identifier, :community => { :name => 'My shiny new community', :description => 'This is a community devoted to anything interesting we find in the internet '}, :back_to => back_to | 244 | post :new_community, :profile => profile.identifier, :community => { :name => 'My shiny new community', :description => 'This is a community devoted to anything interesting we find in the internet '}, :back_to => back_to |
244 | assert_response :redirect | 245 | assert_response :redirect |
245 | assert_redirected_to back_to | 246 | assert_redirected_to back_to |