diff options
author | spag <spag@golwen.net> | 2013-01-24 15:37:24 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-01-24 15:37:24 +0100 |
commit | 99270421d02b3ac77bf111bbde62a2ef80f8e114 (patch) | |
tree | 6ddb8328729e53dcc7a605040cd7aece622d0e5a /app | |
parent | 5f5ea1d06686ec5cd31cf8b9db177191fa7e66fd (diff) | |
parent | 2d6ebf19e5cea45dd714f92a64b1b81e1200a811 (diff) |
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app')
19 files changed, 139 insertions, 137 deletions
diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 347e043..4f4a72a 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_help_path, :notice => t('gemeinschaft_setups.initial_setup.successful_setup') else render :new end diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb index dc5f57b..8f4fa88 100644 --- a/app/controllers/page_controller.rb +++ b/app/controllers/page_controller.rb @@ -11,8 +11,9 @@ class PageController < ApplicationController end end - def conference;end - def beginners_intro;end + def help + + end private def if_fresh_system_then_go_to_wizard diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb index cb67e5f..37874b2 100644 --- a/app/controllers/tenants_controller.rb +++ b/app/controllers/tenants_controller.rb @@ -70,7 +70,7 @@ class TenantsController < ApplicationController :amount_of_numbers => @tenant.array_of_internal_extension_numbers.count + @tenant.array_of_dids.count ) else - redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', + redirect_to page_help_path, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', :resource => @tenant, :amount_of_numbers => @tenant.array_of_internal_extension_numbers.count + @tenant.array_of_dids.count ) @@ -81,7 +81,7 @@ class TenantsController < ApplicationController :resource => @tenant ) else - redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created', + redirect_to page_help_path, :notice => t('tenants.controller.successfuly_created', :resource => @tenant ) end diff --git a/app/models/ability.rb b/app/models/ability.rb index b846af0..0d13dab 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -82,6 +82,10 @@ class Ability # cannot [:create, :destroy], GsParameter cannot [:create, :destroy], GuiFunction + + # An admin can not destroy his/her account + # + cannot [:destroy], User, :id => user.id else # Any user can do the following stuff. # 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/models/user.rb b/app/models/user.rb index b902b99..afb3f04 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -95,6 +95,8 @@ class User < ActiveRecord::Base before_destroy :destroy_or_logout_phones + after_save :become_a_member_of_default_user_groups + def destroy clean_whitelist_entries super @@ -142,6 +144,9 @@ class User < ActiveRecord::Base self.pin_hash == Digest::SHA2.hexdigest( "#{self.pin_salt}#{entered_pin}" ) end + def admin? + self.user_groups.include?(UserGroup.find(2)) + end private @@ -207,4 +212,12 @@ class User < ActiveRecord::Base end end + # Normaly a new user should become a member of default user groups. + # + def become_a_member_of_default_user_groups + UserGroup.where(:id => GsParameter.get('DEFAULT_USER_GROUPS_IDS')).each do |user_group| + user_group.user_group_memberships.create(:user_id => self.id) + end + end + end 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/gs_parameters/_index_core.html.haml b/app/views/gs_parameters/_index_core.html.haml index 9628feb..11d60db 100644 --- a/app/views/gs_parameters/_index_core.html.haml +++ b/app/views/gs_parameters/_index_core.html.haml @@ -10,8 +10,16 @@ - for gs_parameter in gs_parameters - cache(['gs_parameters_table_single_row', gs_parameter]) do %tr - %td= gs_parameter.name + %td + %span.hidden-phone + = truncate(gs_parameter.name, :length => GsParameter.get('DESKTOP_MAX_STRING_LENGTH')) + %span.visible-phone + = truncate(gs_parameter.name, :length => GsParameter.get('MOBILE_MAX_STRING_LENGTH')) - if !@sections %td= gs_parameter.section - %td= truncate(gs_parameter.value, :length => 50) + %td + %span.hidden-phone + = truncate(gs_parameter.value, :length => GsParameter.get('DESKTOP_MAX_STRING_LENGTH')) + %span.visible-phone + = truncate(gs_parameter.value, :length => GsParameter.get('MOBILE_MAX_STRING_LENGTH')) =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gs_parameter}
\ No newline at end of file diff --git a/app/views/gs_parameters/show.html.haml b/app/views/gs_parameters/show.html.haml index 795d09c..d04949b 100644 --- a/app/views/gs_parameters/show.html.haml +++ b/app/views/gs_parameters/show.html.haml @@ -1,20 +1,32 @@ -- cache(@gs_parameter) do - - content_for :title, t("gs_parameters.show.page_title") +- content_for :title, t("gs_parameters.show.page_title") - %p - %strong= t('gs_parameters.show.name') + ":" - = @gs_parameter.name - %p - %strong= t('gs_parameters.show.section') + ":" - = @gs_parameter.section - %p - %strong= t('gs_parameters.show.value') + ":" - = @gs_parameter.value - %p - %strong= t('gs_parameters.show.class_type') + ":" - = @gs_parameter.class_type - %p - %strong= t('gs_parameters.show.description') + ":" - = @gs_parameter.description +- cache(@gs_parameter) do + %table{:class => 'table table-striped'} + %tbody + %tr + %td + %strong= t('gs_parameters.show.name') + ":" + %td + = @gs_parameter.name + %tr + %td + %strong= t('gs_parameters.show.section') + ":" + %td + = @gs_parameter.section + %tr + %td + %strong= t('gs_parameters.show.value') + ":" + %td + = @gs_parameter.value + %tr + %td + %strong= t('gs_parameters.show.class_type') + ":" + %td + = @gs_parameter.class_type + %tr + %td + %strong= t('gs_parameters.show.description') + ":" + %td + = @gs_parameter.description = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gs_parameter }
\ No newline at end of file diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 7ef6523..c2d9946 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -9,9 +9,16 @@ %span.icon-bar %span.icon-bar - - if current_user && current_user.sip_accounts.any? - .nav-collapse.collapse - %ul.nav + .nav-collapse.collapse + %ul.nav + - if current_user && GemeinschaftSetup.any? && current_user.admin? + - if current_page?(page_help_path) + %li.active + =link_to 'Admin-Doku', page_help_path + - else + %li + =link_to 'Admin-Doku', page_help_path + - if current_user && current_user.sip_accounts.any? %li %a{:href => sip_account_call_histories_path(current_user.sip_accounts.first)} %i.icon-list-alt.icon-white diff --git a/app/views/page/beginners_intro.de.html.haml b/app/views/page/help.de.html.haml index 5eef135..5eef135 100644 --- a/app/views/page/beginners_intro.de.html.haml +++ b/app/views/page/help.de.html.haml diff --git a/app/views/page/beginners_intro.html.haml b/app/views/page/help.html.haml index dadd99f..dadd99f 100644 --- a/app/views/page/beginners_intro.html.haml +++ b/app/views/page/help.html.haml diff --git a/app/views/shared/_header.de.html.haml b/app/views/shared/_header.de.html.haml deleted file mode 100644 index 10ad2a0..0000000 --- a/app/views/shared/_header.de.html.haml +++ /dev/null @@ -1,41 +0,0 @@ -%header#main - .light - %h1.gemeinschaft-logo - - if @current_user && @current_user.current_tenant - = link_to "Gemeinschaft", tenant_path(@current_user.current_tenant) - - else - = link_to "Gemeinschaft", root_url - - - if current_user - = form_tag '/search' do - %div.search-box - - if GuiFunction.display?('search_field_in_top_navigation_bar', current_user) - %input.text{:value => 'Suchen ...', :name => 'q'} - %input{:type => 'submit', :value => ''} - - / Adjustable Navigation. - - if current_user - - if navigation_items.size > 0 - - navigation_items.each do |item| - - if GuiFunction.display?('navigation_items_in_top_navigation_bar', current_user) - %span - = link_to item[:title], item[:url] - - - if current_user - .user-context - %a.user{:href => tenant_user_path(current_user.current_tenant.id, current_user.id)} - - if GuiFunction.display?('user_avatar_in_top_navigation_bar', current_user) - - if current_user.image? && current_user.image_url(:mini) - = image_tag current_user.image_url(:mini).to_s, :class => 'display' - - else - - if current_user.male? - = image_tag 'icons/user-male-16x.png', :class => 'display logged-out' - - else - = image_tag 'icons/user-female-16x.png', :class => 'display logged-out' - = current_user - = link_to( "[x]", log_out_path, :class => 'logout', :title => "Abmelden" ) # Temporary way of logging out. - - else - .user-context - = link_to "Registrieren", sign_up_path - or - = link_to "Anmelden", log_in_path diff --git a/app/views/shared/_header.html.haml b/app/views/shared/_header.html.haml deleted file mode 100644 index 377d8e0..0000000 --- a/app/views/shared/_header.html.haml +++ /dev/null @@ -1,41 +0,0 @@ -%header#main - .light - %h1.gemeinschaft-logo - - if @current_user && @current_user.current_tenant - = link_to "Gemeinschaft", tenant_path(@current_user.current_tenant) - - else - = link_to "Gemeinschaft", root_url - - - if current_user - = form_tag '/search' do - %div.search-box - - if GuiFunction.display?('search_field_in_top_navigation_bar', current_user) - %input.text{:value => 'Search ...', :name => 'q'} - %input{:type => 'submit', :value => ''} - - / Adjustable Navigation. - - if current_user - - if navigation_items.size > 0 - - navigation_items.each do |item| - - if GuiFunction.display?('navigation_items_in_top_navigation_bar', current_user) - %span - = link_to item[:title], item[:url] - - - if current_user - .user-context - %a.user{:href => tenant_user_path(current_user.current_tenant.id, current_user.id)} - - if GuiFunction.display?('user_avatar_in_top_navigation_bar', current_user) - - if current_user.image? && current_user.image_url(:mini) - = image_tag current_user.image_url(:mini).to_s, :class => 'display' - - else - - if current_user.male? - = image_tag 'icons/user-male-16x.png', :class => 'display logged-out' - - else - = image_tag 'icons/user-female-16x.png', :class => 'display logged-out' - = current_user - = link_to( "[x]", log_out_path, :class => 'logout', :title => "Log out" ) # Temporary way of logging out. - - else - .user-context - = link_to "Sign up", sign_up_path - or - = link_to "Log in", log_in_path diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index 495ae84..1b96d27 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -1,7 +1,11 @@ .inputs - = f.input :auth_name, :as => :string, :label => t('sip_accounts.form.auth_name.label'), :hint => conditional_hint('sip_accounts.form.auth_name.hint') - = f.input :password, :as => :string, :label => t('sip_accounts.form.password.label'), :hint => conditional_hint('sip_accounts.form.password.hint') = f.input :caller_name, :as => :string, :label => t('sip_accounts.form.caller_name.label'), :hint => conditional_hint('sip_accounts.form.caller_name.hint'), :autofocus => true + - if @sip_account && @sip_account.new_record? + = f.hidden_field :auth_name + = f.hidden_field :password + - else + = f.input :auth_name, :as => :string, :label => t('sip_accounts.form.auth_name.label'), :hint => conditional_hint('sip_accounts.form.auth_name.hint') + = f.input :password, :as => :string, :label => t('sip_accounts.form.password.label'), :hint => conditional_hint('sip_accounts.form.password.hint') = f.input :voicemail_pin, :as => :string, :label => t('sip_accounts.form.voicemail_pin.label'), :hint => conditional_hint('sip_accounts.form.voicemail_pin.hint') = f.input :call_waiting, :label => t('sip_accounts.form.call_waiting.label'), :hint => conditional_hint('sip_accounts.form.call_waiting.hint') = f.input :clir, :label => t('sip_accounts.form.clir.label'), :hint => conditional_hint('sip_accounts.form.clir.hint') diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index 92614c8..28a8273 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -11,11 +11,11 @@ = render :partial => 'tenants/table_of_hunt_groups', :locals => {:tenant => tenant} = render :partial => 'tenants/table_of_automatic_call_distributors', :locals => {:tenant => tenant} - = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} - = render :partial => 'tenants/users_table', :locals => {:tenant => tenant} = render :partial => 'tenants/user_groups_table', :locals => {:tenant => tenant} + = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} + .well %h2 Gemeinschaft Konfiguration = render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => tenant} diff --git a/app/views/user_groups/_index_core.html.haml b/app/views/user_groups/_index_core.html.haml index c481a18..aa1497e 100644 --- a/app/views/user_groups/_index_core.html.haml +++ b/app/views/user_groups/_index_core.html.haml @@ -29,9 +29,5 @@ - else %td =render 'users/listing', :users => user_group.users - - if user_group.users.any? - %br - - if (user_group.tenant.user_ids - user_group.user_ids).any? - = render :partial => 'shared/create_link', :locals => {:parent => user_group, :child_class => UserGroupMembership} =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => user_group.tenant, :child => user_group} 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') |