ref: master
app/controllers/public/enterprise_registration_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
class EnterpriseRegistrationController < ApplicationController before_filter :login_required # CIRANDAS specific: only allow admins to access this protect 'edit_environment_features', :environment # Just go to the first step. # # FIXME: shouldn't this action present some sort of welcome message and point # to the first step explicitly? def index @validation = environment.organization_approval_method @create_enterprise = CreateEnterprise.new(params[:create_enterprise]) @kinds = environment.kinds.where(:type => 'Enterprise') if @validation == :region if params[:create_enterprise] && params[:create_enterprise][:target_id] @create_enterprise.target = Profile.find(params[:create_enterprise][:target_id]) end elsif @validation == :admin || @validation == :none @create_enterprise.target = environment end @create_enterprise.requestor = user the_action = if request.post? if @create_enterprise.valid_before_selecting_target? if @create_enterprise.valid? || @validation == :none :creation elsif @create_enterprise.valid? || @validation == :admin :confirmation else :select_validator end end end # default to basic_information the_action ||= :basic_information # fallback if false is returned the_action = :basic_information if not self.send the_action render :action => the_action end protected # Fill in the form and select your Region. # # Posts back. def basic_information if @validation == :region @regions = @create_enterprise.available_regions.map {|region| [region.name, region.id]} end end # present information about validator organizations, and the user one to # validate her brand new enterprise. # # Posts back. def select_validator @validators = @create_enterprise.region.validators end # Actually records the enterprise registration request and presents a # confirmation message saying to the user that the enterprise register # request was done. def confirmation @create_enterprise.save end # Records the enterprise and presents a confirmation message # saying to the user that the enterprise was created. def creation if @create_enterprise.save @create_enterprise.perform @enterprise = @create_enterprise.target.profiles.find_by identifier: @create_enterprise.identifier end end end |