diff options
-rw-r--r-- | app/controllers/gemeinschaft_setups_controller.rb | 28 | ||||
-rw-r--r-- | app/models/gemeinschaft_setup.rb | 8 | ||||
-rw-r--r-- | app/views/gemeinschaft_setups/new.de.html.haml | 20 | ||||
-rw-r--r-- | app/views/gemeinschaft_setups/new.html.haml | 22 | ||||
-rw-r--r-- | app/views/users/_form_core.html.haml | 3 | ||||
-rw-r--r-- | config/locales/views/gemeinschaft_setups/de.yml | 12 | ||||
-rw-r--r-- | config/locales/views/gemeinschaft_setups/en.yml | 10 | ||||
-rw-r--r-- | db/migrate/20130124105613_add_default_company_name_to_gemeinschaft_setup.rb | 6 | ||||
-rw-r--r-- | db/schema.rb | 8 |
9 files changed, 88 insertions, 29 deletions
diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 347e043..a860653 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -20,6 +20,9 @@ class GemeinschaftSetupsController < ApplicationController ) @gemeinschaft_setup.country = Country.find_by_name('Germany') @gemeinschaft_setup.language = Language.find_by_name('Deutsch') + + @gemeinschaft_setup.default_company_name = generate_a_new_name(Tenant.new) + @gemeinschaft_setup.default_system_email = 'admin@localhost' end def create @@ -64,11 +67,34 @@ class GemeinschaftSetupsController < ApplicationController FreeswitchAPI.execute('fsctl', 'shutdown restart') end + # Create the tenant + tenant = Tenant.create({:name => @gemeinschaft_setup.default_company_name, + :sip_domain_id => SipDomain.last.id, + :country_id => @gemeinschaft_setup.country.id, + :language_id => @gemeinschaft_setup.language_id, + :from_field_voicemail_email => @gemeinschaft_setup.default_system_email, + :from_field_pin_change_email => @gemeinschaft_setup.default_system_email, + }) + + # Become a member of this tenant. + # + tenant.tenant_memberships.create(:user_id => user.id) + + # Groups + # + admin_group = tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.admin_group_name')) + admin_group.users << user + + user_group = tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.user_group_name')) + user_group.users << user + + user.update_attributes!(:current_tenant_id => tenant.id) + # Auto-Login: session[:user_id] = user.id # Redirect to the user - redirect_to new_tenant_url, :notice => t('gemeinschaft_setups.initial_setup.successful_setup') + redirect_to page_beginners_intro_path, :notice => t('gemeinschaft_setups.initial_setup.successful_setup') else render :new end diff --git a/app/models/gemeinschaft_setup.rb b/app/models/gemeinschaft_setup.rb index 6056236..4b4dd37 100644 --- a/app/models/gemeinschaft_setup.rb +++ b/app/models/gemeinschaft_setup.rb @@ -6,6 +6,14 @@ class GemeinschaftSetup < ActiveRecord::Base belongs_to :country belongs_to :language + validates :default_company_name, + :presence => true, + :uniqueness => true + + validates :default_system_email, + :presence => true, + :uniqueness => true + # Remove the cache which was created by the heater rake task. # after_create :expire_cache diff --git a/app/views/gemeinschaft_setups/new.de.html.haml b/app/views/gemeinschaft_setups/new.de.html.haml index 3d9b173..cf1f207 100644 --- a/app/views/gemeinschaft_setups/new.de.html.haml +++ b/app/views/gemeinschaft_setups/new.de.html.haml @@ -5,23 +5,25 @@ = f.error_notification %h2 Admin-Konto - %p - Dieser erste Benutzer des Systems hat automatisch Admin-Rechte. = f.simple_fields_for :user, @user do |u| = render "users/form_core", :f => u - %h2 SIP-Domain - %p In den meisten Fällen sollten Sie den gleichen Wert für SIP-Realm und SIP-Domain benutzen. Wenn Sie mit diesen Begriffen nichts anfangen können, dann geben Sie hier bitte die IP-Adresse dieses Servers ein. - - = f.simple_fields_for :sip_domain, @sip_domain do |s| - = render "sip_domains/form_core", :f => s - - %h2 Allgemeine Informationen + %h2 Konfiguration der Telefonanlage = f.association :country, :label => t('gemeinschaft_setups.form.country_id.label'), :hint => conditional_hint('gemeinschaft_setups.form.country_id.hint'), :include_blank => false = f.association :language, :label => t('gemeinschaft_setups.form.language_id.label'), :hint => conditional_hint('gemeinschaft_setups.form.language_id.hint'), :include_blank => false = f.input :default_area_code, :label => t('gemeinschaft_setups.form.default_area_code.label'), :hint => conditional_hint('gemeinschaft_setups.form.default_area_code.hint') + = f.input :default_company_name, :label => t('gemeinschaft_setups.form.default_company_name.label'), :hint => conditional_hint('gemeinschaft_setups.form.default_company_name.hint') + + = f.input :default_system_email, :label => t('gemeinschaft_setups.form.default_system_email.label'), :hint => conditional_hint('gemeinschaft_setups.form.default_system_email.hint') + + %h3 SIP-Domain + %p In den meisten Fällen sollten Sie den gleichen Wert für SIP-Realm und SIP-Domain benutzen. Wenn Sie mit diesen Begriffen nichts anfangen können, dann geben Sie hier bitte die IP-Adresse dieses Servers ein. + + = f.simple_fields_for :sip_domain, @sip_domain do |s| + = render "sip_domains/form_core", :f => s + .actions = f.button :submit, conditional_t('gemeinschaft_setups.form.submit')
\ No newline at end of file diff --git a/app/views/gemeinschaft_setups/new.html.haml b/app/views/gemeinschaft_setups/new.html.haml index ff9c812..5e2434e 100644 --- a/app/views/gemeinschaft_setups/new.html.haml +++ b/app/views/gemeinschaft_setups/new.html.haml @@ -4,24 +4,26 @@ = simple_form_for(@gemeinschaft_setup) do |f| = f.error_notification - %h3 Admin user account - %p - This is the first user of this system who has admin rights by default. + %h2 Admin user account = f.simple_fields_for :user, @user do |u| = render "users/form_core", :f => u - %h3 SIP domain - %p You should use the same value for the SIP realm as for the SIP domain to ensure compatibility with different phone models. In case you have no clue what we are talking about: Just enter the IP address of this server. - - = f.simple_fields_for :sip_domain, @sip_domain do |s| - = render "sip_domains/form_core", :f => s - - %h3 General information + %h2 Configuration of this PBX = f.association :country, :label => t('gemeinschaft_setups.form.country_id.label'), :hint => conditional_hint('gemeinschaft_setups.form.country_id.hint'), :include_blank => false = f.association :language, :label => t('gemeinschaft_setups.form.language_id.label'), :hint => conditional_hint('gemeinschaft_setups.form.language_id.hint'), :include_blank => false = f.input :default_area_code, :label => t('gemeinschaft_setups.form.default_area_code.label'), :hint => conditional_hint('gemeinschaft_setups.form.default_area_code.hint') + = f.input :default_company_name, :label => t('gemeinschaft_setups.form.default_company_name.label'), :hint => conditional_hint('gemeinschaft_setups.form.default_company_name.hint') + + = f.input :default_system_email, :label => t('gemeinschaft_setups.form.default_system_email.label'), :hint => conditional_hint('gemeinschaft_setups.form.default_system_email.hint') + + %h3 SIP-Domain + %p You should use the same value for the SIP realm as for the SIP domain to ensure compatibility with different phone models. In case you have no clue what we are talking about: Just enter the IP address of this server. + + = f.simple_fields_for :sip_domain, @sip_domain do |s| + = render "sip_domains/form_core", :f => s + .actions = f.button :submit, conditional_t('gemeinschaft_setups.form.submit')
\ No newline at end of file diff --git a/app/views/users/_form_core.html.haml b/app/views/users/_form_core.html.haml index 24b15f5..980976d 100644 --- a/app/views/users/_form_core.html.haml +++ b/app/views/users/_form_core.html.haml @@ -2,7 +2,8 @@ - if GuiFunction.display?('name_data_fields_in_user_edit_form', current_user) = f.input :male, :collection => [[true, t('users.form.gender.male')], [false, t('users.form.gender.female')]], :label_method => :last, :value_method => :first, :label => t('users.form.male.label'), :hint => conditional_hint('users.form.gender.hint'), :label => t('users.form.gender.label'), :as => :radio_buttons = f.input :first_name, :label => t('users.form.first_name.label'), :hint => conditional_hint('users.form.first_name.hint'), :autofocus => true - = f.input :middle_name, :label => t('users.form.middle_name.label'), :hint => conditional_hint('users.form.middle_name.hint') + - if User.any? + = f.input :middle_name, :label => t('users.form.middle_name.label'), :hint => conditional_hint('users.form.middle_name.hint') = f.input :last_name, :label => t('users.form.last_name.label'), :hint => conditional_hint('users.form.last_name.hint') - if GuiFunction.display?('user_name_field_in_user_edit_form', current_user) = f.input :user_name, :label => t('users.form.user_name.label'), :hint => conditional_hint('users.form.user_name.hint') diff --git a/config/locales/views/gemeinschaft_setups/de.yml b/config/locales/views/gemeinschaft_setups/de.yml index d087583..57bc7e6 100644 --- a/config/locales/views/gemeinschaft_setups/de.yml +++ b/config/locales/views/gemeinschaft_setups/de.yml @@ -4,7 +4,7 @@ de: initial_setup: tenant_name_default: 'Beispiel-Firma GmbH' access_denied_only_available_on_a_new_system: 'Zugriff verweigert! Der Installations-Assistent ist nur auf einem frisch installierten System verfügbar.' - successful_setup: 'Ihr Admin-Konto wurde erstellt. Als nächsten Schritt müssen Sie einen Mandant anlegen.' + successful_setup: 'Ihre neue Telefonanlage ist jetzt eingerichtet. Bitte erstellen Sie jetzt ein paar SIP-Accounts und richten Sie danach Telefone dafür ein.' admin_name: 'admin' super_tenant_description: 'Die Benutzer dieses Mandanten haben besondere Rechte. Sie können andere Mandanten anlegen und löschen.' admin_group_name: 'Admins' @@ -27,5 +27,11 @@ de: hint: '' default_area_code: label: 'Standard Ortsvorwahl' - hint: '030 für Berlin, 0261 für Koblenz, 02631 für Neuwied, usw.' - button: 'Absenden'
\ No newline at end of file + hint: '030 für Berlin, 0261 für Koblenz, 02631 für Neuwied, usw.' + default_company_name: + label: 'Name der Organisation' + hint: 'z.B. Firmenname' + default_system_email: + label: 'System E-Mail Adresse' + hint: 'Für den E-Mail Versand von Faxen und Voicemails.' + submit: 'Anlage einrichten'
\ No newline at end of file diff --git a/config/locales/views/gemeinschaft_setups/en.yml b/config/locales/views/gemeinschaft_setups/en.yml index 5e22e58..7af160c 100644 --- a/config/locales/views/gemeinschaft_setups/en.yml +++ b/config/locales/views/gemeinschaft_setups/en.yml @@ -4,7 +4,7 @@ en: initial_setup: tenant_name_default: 'Snake Oil, Ltd.' access_denied_only_available_on_a_new_system: 'Access denied! The setup wizard is only available on a new system.' - successful_setup: 'Your admin account has been created. The next step is to create a tenant.' + successful_setup: 'Your new PBX is up and running. Have a look around and setup some SIP accounts and phones.' admin_name: 'admin' super_tenant_description: 'The members of this tenant have the power to create and delete other tenants.' admin_group_name: 'Admins' @@ -28,4 +28,10 @@ en: default_area_code: label: 'Default area code' hint: '' - button: 'Submit'
\ No newline at end of file + default_company_name: + label: 'Name of the organisation' + hint: 'e.g. name of the company' + default_system_email: + label: 'System e-mail address' + hint: 'From field for voicemail or fax e-mails.' + button: 'Create this PBX'
\ No newline at end of file diff --git a/db/migrate/20130124105613_add_default_company_name_to_gemeinschaft_setup.rb b/db/migrate/20130124105613_add_default_company_name_to_gemeinschaft_setup.rb new file mode 100644 index 0000000..46b4884 --- /dev/null +++ b/db/migrate/20130124105613_add_default_company_name_to_gemeinschaft_setup.rb @@ -0,0 +1,6 @@ +class AddDefaultCompanyNameToGemeinschaftSetup < ActiveRecord::Migration + def change + add_column :gemeinschaft_setups, :default_company_name, :string + add_column :gemeinschaft_setups, :default_system_email, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 649e022..17563b1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130122121100) do +ActiveRecord::Schema.define(:version => 20130124105613) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -535,9 +535,11 @@ ActiveRecord::Schema.define(:version => 20130122121100) do t.integer "sip_domain_id" t.integer "country_id" t.integer "language_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "default_area_code" + t.string "default_company_name" + t.string "default_system_email" end create_table "gs_cluster_sync_log_entries", :force => true do |t| |