summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/config_snom_controller.rb4
-rw-r--r--app/controllers/gemeinschaft_setups_controller.rb5
-rw-r--r--app/controllers/phones_controller.rb1
-rw-r--r--app/models/phone.rb6
-rw-r--r--app/models/phone_model.rb2
-rw-r--r--app/models/sip_account.rb2
-rw-r--r--app/views/phones/_form_core.html.haml2
-rw-r--r--app/views/phones/show.html.haml2
-rw-r--r--app/views/tenants/_admin_area.de.html.haml3
-rw-r--r--app/views/tenants/_admin_area.html.haml2
-rw-r--r--app/views/tenants/_sip_accounts_and_phones.html.haml117
-rw-r--r--app/views/tenants/_table_of_functions.html.haml2
-rw-r--r--app/views/tenants/_table_of_phone_books.html.haml2
-rw-r--r--config/database.yml42
-rw-r--r--db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb9
-rw-r--r--db/schema.rb2
16 files changed, 108 insertions, 95 deletions
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb
index cb664db..24f6e59 100644
--- a/app/controllers/config_snom_controller.rb
+++ b/app/controllers/config_snom_controller.rb
@@ -182,9 +182,9 @@ class ConfigSnomController < ApplicationController
send_sensitve = @provisioning_authenticated || !@phone.provisioning_key_active
@phone_settings = Hash.new()
- if defined?(PROVISIONING_KEY_LENGTH) && PROVISIONING_KEY_LENGTH > 0
+ if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0
if @phone.provisioning_key.blank?
- @phone.update_attributes({ :provisioning_key => SecureRandom.hex(PROVISIONING_KEY_LENGTH), :provisioning_key_active => false })
+ @phone.update_attributes({ :provisioning_key => SecureRandom.hex(GsParameter.get('PROVISIONING_KEY_LENGTH')), :provisioning_key_active => false })
elsif @provisioning_authenticated
@phone.update_attributes({ :provisioning_key_active => true })
end
diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb
index 73a748c..81faf2a 100644
--- a/app/controllers/gemeinschaft_setups_controller.rb
+++ b/app/controllers/gemeinschaft_setups_controller.rb
@@ -41,6 +41,11 @@ class GemeinschaftSetupsController < ApplicationController
super_tenant_super_admin_group = super_tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.super_admin_group_name'))
super_tenant_super_admin_group.user_group_memberships.create(:user_id => user.id)
+ # Set a couple of URLs in the GsParameter table
+ GsParameter.where(:name => 'phone_book_entry_image_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}/uploads/phone_book_entry/image")
+ GsParameter.where(:name => 'ringtone_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}")
+ GsParameter.where(:name => 'user_image_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}/uploads/user/image")
+
# Auto-Login:
session[:user_id] = user.id
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb
index 14735e6..3672390 100644
--- a/app/controllers/phones_controller.rb
+++ b/app/controllers/phones_controller.rb
@@ -46,6 +46,7 @@ class PhonesController < ApplicationController
m = method( :"#{@phoneable.class.name.underscore}_phone_path" )
redirect_to m.( @phoneable, @phone ), :notice => t('phones.controller.successfuly_updated')
else
+ set_fallback_sip_accounts
render :edit
end
end
diff --git a/app/models/phone.rb b/app/models/phone.rb
index a59b003..8b41b59 100644
--- a/app/models/phone.rb
+++ b/app/models/phone.rb
@@ -9,7 +9,7 @@ class Phone < ActiveRecord::Base
# Associations
#
belongs_to :phone_model
- belongs_to :phoneable, :polymorphic => true
+ belongs_to :phoneable, :polymorphic => true, :touch => true
has_many :phone_sip_accounts, :dependent => :destroy, :uniq => true, :order => :position
has_many :sip_accounts, :through => :phone_sip_accounts
@@ -200,6 +200,10 @@ class Phone < ActiveRecord::Base
# Sanitize MAC address.
#
def sanitize_mac_address
+ if self.mac_address.split(/:/).count == 6 && self.mac_address.length < 17
+ splitted_mac_address = self.mac_address.split(/:/)
+ self.mac_address = splitted_mac_address.map{|part| (part.size == 1 ? "0#{part}" : part)}.join('')
+ end
self.mac_address = self.mac_address.to_s.upcase.gsub( /[^A-F0-9]/, '' )
end
diff --git a/app/models/phone_model.rb b/app/models/phone_model.rb
index e00e0e3..ac4d4a3 100644
--- a/app/models/phone_model.rb
+++ b/app/models/phone_model.rb
@@ -3,7 +3,7 @@ class PhoneModel < ActiveRecord::Base
# Associations
#
- belongs_to :manufacturer
+ belongs_to :manufacturer, :touch => true
has_many :phones, :dependent => :destroy
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 5388395..d35f9b4 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -10,7 +10,7 @@ class SipAccount < ActiveRecord::Base
# Associations:
#
- belongs_to :sip_accountable, :polymorphic => true
+ belongs_to :sip_accountable, :polymorphic => true, :touch => true
has_many :phone_sip_accounts, :uniq => true
has_many :phones, :through => :phone_sip_accounts
diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml
index b09ee35..17b9ca8 100644
--- a/app/views/phones/_form_core.html.haml
+++ b/app/views/phones/_form_core.html.haml
@@ -11,5 +11,5 @@
- if defined? GsParameter.get('NIGHTLY_REBOOT_OF_PHONES') && GsParameter.get('NIGHTLY_REBOOT_OF_PHONES') == true
= f.input :nightly_reboot, :label => t('phones.form.nightly_reboot.label'), :hint => conditional_hint('phones.form.nightly_reboot.hint')
- - if defined? PROVISIONING_KEY_LENGTH && PROVISIONING_KEY_LENGTH > 0
+ - if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0
= f.input :provisioning_key_active, :label => t('phones.form.provisioning_key_active.label'), :hint => conditional_hint('phones.form.provisioning_key_active.hint')
diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml
index f20facd..0e0dad5 100644
--- a/app/views/phones/show.html.haml
+++ b/app/views/phones/show.html.haml
@@ -21,7 +21,7 @@
%strong= t('phones.show.nightly_reboot') + ":"
= @phone.nightly_reboot
-- if defined? PROVISIONING_KEY_LENGTH && PROVISIONING_KEY_LENGTH > 0
+- if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0
%p
%strong= t('phones.show.provisioning_key_active') + ":"
= @phone.provisioning_key_active
diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml
index c3411bc..d111c9d 100644
--- a/app/views/tenants/_admin_area.de.html.haml
+++ b/app/views/tenants/_admin_area.de.html.haml
@@ -1,4 +1,4 @@
-- cache([I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.count, Manufacturer.order(:updated_at).last, PhoneModel.count]) do
+- cache([I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.all]) do
%p
Sie sind Mitglied der
= link_to 'Admin Gruppe', tenant_user_group_path(@tenant, @tenant.user_groups.find_by_name('Admins'))
@@ -32,4 +32,3 @@
= render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant}
= render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant}
-
diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml
index 56b0820..b479995 100644
--- a/app/views/tenants/_admin_area.html.haml
+++ b/app/views/tenants/_admin_area.html.haml
@@ -1,4 +1,4 @@
-- cache([I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.count, Manufacturer.order(:updated_at).last, PhoneModel.count]) do
+- cache([I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.all]) do
%p
You belong to the
= link_to 'admin group', tenant_user_group_path(@tenant, @tenant.user_groups.find_by_name('Admins'))
diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml
index 9059126..f9d26f9 100644
--- a/app/views/tenants/_sip_accounts_and_phones.html.haml
+++ b/app/views/tenants/_sip_accounts_and_phones.html.haml
@@ -1,65 +1,64 @@
-- cache([I18n.locale, tenant, Phone.count, Phone.order(:updated_at).last, PhoneNumber.count, PhoneNumber.order(:updated_at).last, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do
- %table
- %tr{:class => 'even'}
- %th
- %th
- = tenant
- %th= t("users.index.page_title")
+%table
+ %tr{:class => 'even'}
+ %th
+ %th
+ = tenant
+ %th= t("users.index.page_title")
- %tr{:class => 'odd'}
- %td= t("sip_accounts.index.page_title")
- - cache([I18n.locale, tenant, tenant.sip_accounts.count, tenant.sip_accounts.order(:updated_at).last]) do
- %td
- - if tenant.sip_accounts.any?
- - if tenant.sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
- = link_to tenant.sip_accounts.count.to_s, tenant_sip_accounts_path(tenant)
- - else
- - tenant.sip_accounts.each do |sip_account|
- = succeed ', ' do
- =link_to "#{sip_account.caller_name}", tenant_sip_account_path(tenant,sip_account)
- - if sip_account.phone_numbers.any?
- = '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']'
- = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount}
- %td
- - if tenant.users_sip_accounts.any?
- - if tenant.users_sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
- = tenant.users_sip_accounts.count
- - else
- - tenant.users_sip_accounts.each do |sip_account|
- - if sip_account != tenant.users_sip_accounts.last
- = succeed ', ' do
- =link_to "#{sip_account.caller_name}", user_sip_account_path(sip_account.sip_accountable,sip_account)
- - if sip_account.phone_numbers.any?
- = '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']'
- - else
- =link_to "#{sip_account.caller_name}", user_sip_account_path(sip_account.sip_accountable,sip_account)
+ %tr{:class => 'odd'}
+ %td= t("sip_accounts.index.page_title")
+ %td
+ - if tenant.sip_accounts.any?
+ - if tenant.sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
+ = link_to tenant.sip_accounts.count.to_s, tenant_sip_accounts_path(tenant)
+ - else
+ - cache([I18n.locale, tenant, tenant.sip_accounts, PhoneNumber.where(:phone_numberable_type => 'SipAccount').where(:id => tenant.sip_account_ids)]) do
+ - tenant.sip_accounts.each do |sip_account|
+ = succeed ', ' do
+ =link_to "#{sip_account.caller_name}", tenant_sip_account_path(tenant,sip_account)
- if sip_account.phone_numbers.any?
= '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']'
+ = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount}
+ %td
+ - if tenant.users_sip_accounts.any?
+ - if tenant.users_sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
+ = tenant.users_sip_accounts.count
- else
- = "-"
-
- %tr{:class => 'even'}
- %td= t("phones.index.page_title")
- - cache([I18n.locale, tenant, tenant.phones.count, tenant.phones.order(:updated_at).last]) do
- %td
- - if tenant.phones.any?
- - if tenant.phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
- = link_to tenant.phones.count.to_s, tenant_phones_path(tenant)
+ - tenant.users_sip_accounts.each do |sip_account|
+ - if sip_account != tenant.users_sip_accounts.last
+ = succeed ', ' do
+ =link_to "#{sip_account.caller_name}", user_sip_account_path(sip_account.sip_accountable,sip_account)
+ - if sip_account.phone_numbers.any?
+ = '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']'
- else
- - tenant.phones.each do |phone|
- = succeed ', ' do
- = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", tenant_phone_path(tenant, phone)
- = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Phone}
- %td
- - if tenant.users_phones.any?
- - if tenant.users_phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
- = tenant.users_phones.count
- - else
- - tenant.users_phones.each do |phone|
- - if phone != tenant.users_phones.last
- = succeed ', ' do
- = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", user_phone_path(phone.phoneable, phone)
- - else
- = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", user_phone_path(phone.phoneable, phone)
+ =link_to "#{sip_account.caller_name}", user_sip_account_path(sip_account.sip_accountable,sip_account)
+ - if sip_account.phone_numbers.any?
+ = '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']'
+ - else
+ = "-"
+
+ %tr{:class => 'even'}
+ %td= t("phones.index.page_title")
+ %td
+ - if tenant.phones.any?
+ - if tenant.phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
+ = link_to tenant.phones.count.to_s, tenant_phones_path(tenant)
- else
- = '-' \ No newline at end of file
+ - cache([I18n.locale, tenant, tenant.phones]) do
+ - tenant.phones.each do |phone|
+ = succeed ', ' do
+ = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", tenant_phone_path(tenant, phone)
+ = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Phone}
+ %td
+ - if tenant.users_phones.any?
+ - if tenant.users_phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS')
+ = tenant.users_phones.count
+ - else
+ - tenant.users_phones.each do |phone|
+ - if phone != tenant.users_phones.last
+ = succeed ', ' do
+ = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", user_phone_path(phone.phoneable, phone)
+ - else
+ = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", user_phone_path(phone.phoneable, phone)
+ - else
+ = '-' \ No newline at end of file
diff --git a/app/views/tenants/_table_of_functions.html.haml b/app/views/tenants/_table_of_functions.html.haml
index d4d3950..79ea2b1 100644
--- a/app/views/tenants/_table_of_functions.html.haml
+++ b/app/views/tenants/_table_of_functions.html.haml
@@ -1,4 +1,4 @@
-- cache([I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at)]) do
+- cache([I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do
%table
%tr{:class => 'even'}
%th
diff --git a/app/views/tenants/_table_of_phone_books.html.haml b/app/views/tenants/_table_of_phone_books.html.haml
index ef118c7..811fe26 100644
--- a/app/views/tenants/_table_of_phone_books.html.haml
+++ b/app/views/tenants/_table_of_phone_books.html.haml
@@ -1,4 +1,4 @@
-- cache([I18n.locale, tenant]) do
+- cache([I18n.locale, tenant, tenant.phone_books]) do
-# Phone books
-#
- if GuiFunction.display?('show_phone_books_in_user_show_view', current_user)
diff --git a/config/database.yml b/config/database.yml
index 2a7dcb5..364cbdb 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -1,17 +1,23 @@
<% system_odbc_ini_file = '/var/lib/freeswitch/.odbc.ini' %>
-<% if File.exists?(system_odbc_ini_file) %>
-<% system_odbc_configuration = IniFile.load(system_odbc_ini_file) %>
-<% if !system_odbc_configuration['gemeinschaft']['DATABASE'].blank? && !system_odbc_configuration['gemeinschaft']['USER'].blank? %>
+<% if !File.exists?(system_odbc_ini_file) %>
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
production:
- adapter: mysql2
+ adapter: mysql2
encoding: utf8
- database: <%= system_odbc_configuration['gemeinschaft']['DATABASE'] %>
+ database: gemeinschaft
pool: 10
- username: <%= system_odbc_configuration['gemeinschaft']['USER'] %>
- password: <%= system_odbc_configuration['gemeinschaft']['PASSWORD'] %>
+ username: gemeinschaft
+ password: gemeinschaft
socket: /var/run/mysqld/mysqld.sock
reconnect: true
-
+<% else %>
+<% system_odbc_configuration = IniFile.load(system_odbc_ini_file) %>
+<% if !system_odbc_configuration['gemeinschaft']['DATABASE'].blank? && !system_odbc_configuration['gemeinschaft']['USER'].blank? %>
development:
adapter: mysql2
encoding: utf8
@@ -21,24 +27,14 @@ development:
password: <%= system_odbc_configuration['gemeinschaft']['PASSWORD'] %>
socket: /var/run/mysqld/mysqld.sock
reconnect: true
-<% else %>
-production:
- adapter: mysql2
- encoding: utf8
- database: gemeinschaft
- pool: 10
- username: gemeinschaft
- password: gemeinschaft
- socket: /var/run/mysqld/mysqld.sock
- reconnect: true
-development:
+production:
adapter: mysql2
encoding: utf8
- database: gemeinschaft
- pool: 5
- username: gemeinschaft
- password: gemeinschaft
+ database: <%= system_odbc_configuration['gemeinschaft']['DATABASE'] %>
+ pool: 10
+ username: <%= system_odbc_configuration['gemeinschaft']['USER'] %>
+ password: <%= system_odbc_configuration['gemeinschaft']['PASSWORD'] %>
socket: /var/run/mysqld/mysqld.sock
reconnect: true
<% end %>
diff --git a/db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb b/db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb
new file mode 100644
index 0000000..06d0ee8
--- /dev/null
+++ b/db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb
@@ -0,0 +1,9 @@
+class SetNewValueForProvisioningKeyLength < ActiveRecord::Migration
+ def up
+ GsParameter.create(:entity => nil, :section => 'Provisioning', :name => 'PROVISIONING_KEY_LENGTH', :value => '12', :class_type => 'Integer')
+ end
+
+ def down
+ GsParameter.where(:name => 'PROVISIONING_KEY_LENGTH').destroy_all
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index bc7693b..a6aae9b 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 => 20130111111747) do
+ActiveRecord::Schema.define(:version => 20130112103337) do
create_table "access_authorizations", :force => true do |t|
t.string "access_authorizationable_type"