diff --git a/app/controllers/my_profile/memberships_controller.rb b/app/controllers/my_profile/memberships_controller.rb index 85928a3..2cfe19b 100644 --- a/app/controllers/my_profile/memberships_controller.rb +++ b/app/controllers/my_profile/memberships_controller.rb @@ -20,9 +20,22 @@ class MembershipsController < MyProfileController @community.environment = environment @back_to = params[:back_to] || url_for(:action => 'index') if request.post? && @community.valid? - @community = Community.create_after_moderation(user, params[:community].merge({:environment => environment})) - redirect_to @back_to + begin + # Community was created + @community = Community.create_after_moderation(user, params[:community].merge({:environment => environment})) + @community.reload + redirect_to :action => 'welcome', :community_id => @community.id, :back_to => @back_to + rescue ActiveRecord::RecordNotFound + # Community pending approval + session[:notice] = _('Your community creation request is waiting approval of the administrator.') + redirect_to @back_to + end return end end + + def welcome + @community = Community.find(params[:community_id]) + @back_to = params[:back_to] + end end diff --git a/app/views/memberships/welcome.html.erb b/app/views/memberships/welcome.html.erb new file mode 100644 index 0000000..e6c04ab --- /dev/null +++ b/app/views/memberships/welcome.html.erb @@ -0,0 +1,9 @@ +
<%= __("Your community (%s) was successfully created.") % @community.name %>
+<%= link_to __('You can manage your community now.'), @community.admin_url %>
+ +<%= render :partial => 'shared/template_welcome_page', :locals => {:template => @community.template, :header => _("What can I do with a community?")} %> + +<% button_bar do%> + <%= button :back, _('Back'), @back_to %> +<% end %> diff --git a/test/functional/memberships_controller_test.rb b/test/functional/memberships_controller_test.rb index dbaa697..ad3599a 100644 --- a/test/functional/memberships_controller_test.rb +++ b/test/functional/memberships_controller_test.rb @@ -35,7 +35,6 @@ class MembershipsControllerTest < ActionController::TestCase assert_difference 'Community.count' do 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 '} assert_response :redirect - assert_redirected_to :action => 'index' assert Community.find_by_identifier('my-shiny-new-community').members.include?(profile), "Creator user should be added as member of the community just created" end @@ -238,8 +237,10 @@ class MembershipsControllerTest < ActionController::TestCase assert_tag :tag => 'input', :attributes => {:id => 'community_plugin2', :type => 'hidden', :value => 'Plugin 2'} end - should 'redirect to back_to parameter when create a new community' do + should 'redirect to back_to parameter when community needs admin approval' do back_to = '/' + environment = Environment.default + environment.enable('admin_must_approve_new_communities') 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 assert_response :redirect assert_redirected_to back_to -- libgit2 0.21.2