diff --git a/app/controllers/public/enterprise_registration_controller.rb b/app/controllers/public/enterprise_registration_controller.rb index 31b2281..289bee4 100644 --- a/app/controllers/public/enterprise_registration_controller.rb +++ b/app/controllers/public/enterprise_registration_controller.rb @@ -15,14 +15,16 @@ class EnterpriseRegistrationController < ApplicationController if params[:create_enterprise] && params[:create_enterprise][:target_id] @create_enterprise.target = Profile.find(params[:create_enterprise][:target_id]) end - elsif @validation == :admin + elsif @validation == :admin || @validation == :none @create_enterprise.target = @create_enterprise.environment end @create_enterprise.requestor = current_user.person the_action = if request.post? if @create_enterprise.valid_before_selecting_target? - if @create_enterprise.valid? || @validation == :admin + if @create_enterprise.valid? && @validation == :none + :creation + elsif @create_enterprise.valid? || @validation == :admin :confirmation else :select_validator @@ -63,4 +65,11 @@ class EnterpriseRegistrationController < ApplicationController @create_enterprise.save! end + # Records the enterprise and presents a confirmation message + # saying to the user that the enterprise was created. + def creation + @create_enterprise.perform + @enterprise = @create_enterprise.target.profiles.find_by_identifier(@create_enterprise.identifier) + end + end diff --git a/app/helpers/features_helper.rb b/app/helpers/features_helper.rb index 98a79bb..25c6ac8 100644 --- a/app/helpers/features_helper.rb +++ b/app/helpers/features_helper.rb @@ -3,6 +3,7 @@ module FeaturesHelper choices = [ [ _('Administrator must approve all new organizations'), 'admin'], [ _('Administrator assigns validator organizations per region.'), 'region'], + [ _('All new organizations are approve by default'), 'none'], ] value = instance_variable_get("@#{object}").send(method).to_s select_tag("#{object}[#{method}]", options_for_select(choices, value)) diff --git a/app/models/environment.rb b/app/models/environment.rb index af3280b..977a1f0 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -275,6 +275,7 @@ class Environment < ActiveRecord::Base # * :region: organization registering must be approved by some other # organization asssigned as validator to the Region the new organization # belongs to. + # * :none: organization registration is approved by default. # # Trying to set organization_approval_method to any other value will raise an # ArgumentError. @@ -287,6 +288,7 @@ class Environment < ActiveRecord::Base accepted_values = %w[ admin region + none ].map(&:to_sym) raise ArgumentError unless accepted_values.include?(actual_value) diff --git a/app/views/enterprise_registration/creation.rhtml b/app/views/enterprise_registration/creation.rhtml new file mode 100644 index 0000000..aae75da --- /dev/null +++ b/app/views/enterprise_registration/creation.rhtml @@ -0,0 +1,9 @@ +
+<%= _("Your enterprise (%s) was successfully registered.") % @enterprise.name %> +
+ ++<%= link_to _('You can manage your enterprise now.'), @enterprise.admin_url %> +
diff --git a/app/views/search/enterprises.rhtml b/app/views/search/enterprises.rhtml index 4ee954f..846e406 100644 --- a/app/views/search/enterprises.rhtml +++ b/app/views/search/enterprises.rhtml @@ -15,6 +15,12 @@ <%= render :partial => 'search_form', :locals => { :form_title => _("Refine your search"), :simple_search => true } %> +<% if logged_in? && environment.enabled?('enterprise_registration') %> + <% button_bar do %> + <%= button(:add, __('New enterprise'), {:controller => 'enterprise_registration'}) %> + <% end %> +<% end %> + <% if @categories_menu %>