From 7525ca487b993cc04c5540c0cf3bee4dabc2cc1c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 21:04:13 +0100 Subject: Added nightly build to the release number. --- config/initializers/gemeinschaft_parameters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/gemeinschaft_parameters.rb b/config/initializers/gemeinschaft_parameters.rb index b1481ef..1624165 100644 --- a/config/initializers/gemeinschaft_parameters.rb +++ b/config/initializers/gemeinschaft_parameters.rb @@ -1,6 +1,6 @@ # Use this file to set generic parameters for Gemeinschaft -GEMEINSCHAFT_VERSION = '5.0.2' +GEMEINSCHAFT_VERSION = '5.0.2-nightly-build' SUPER_TENANT_NAME = 'Super-Tenant' # System defaults -- cgit v1.2.3 From 2a165046b5e1bc32ccb5930be76be10c6d80d7fb Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 21:28:42 +0100 Subject: Updated some gems. --- Gemfile.lock | 113 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f9a6596..696166f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,95 +28,95 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_list (0.1.5) - addressable (2.2.7) + acts_as_list (0.1.9) + addressable (2.3.2) arel (3.0.2) bcrypt-ruby (3.0.1) - breadcrumbs_on_rails (2.2.0) - builder (3.0.0) - cancan (1.6.7) - carrierwave (0.5.8) - activesupport (~> 3.0) - chunky_png (1.2.5) + breadcrumbs_on_rails (2.3.0) + builder (3.0.4) + cancan (1.6.8) + carrierwave (0.7.1) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + chunky_png (1.2.6) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) - compass (0.12.rc.1) + coffee-script-source (1.4.0) + compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.0.rc.3) - compass (~> 0.12.rc.0) + compass-rails (1.0.3) + compass (>= 0.12.2, < 0.14) cookiejar (0.3.0) - delayed_job (3.0.1) + delayed_job (3.0.4) activesupport (~> 3.0) - delayed_job_active_record (0.3.2) - activerecord (> 2.1.0) - delayed_job (~> 3.0.0) - em-http-request (1.0.1) + delayed_job_active_record (0.3.3) + activerecord (>= 2.1.0, < 4) + delayed_job (~> 3.0) + em-http-request (1.0.3) addressable (>= 2.2.3) cookiejar em-socksify eventmachine (>= 1.0.0.beta.4) http_parser.rb (>= 0.5.3) - em-socksify (0.1.0) - eventmachine + em-socksify (0.2.1) + eventmachine (>= 1.0.0.beta.4) erubis (2.7.0) - eventmachine (1.0.0.beta.4) - execjs (1.3.0) + eventmachine (1.0.0) + execjs (1.4.0) multi_json (~> 1.0) - factory_girl (2.6.1) - activesupport (>= 2.3.9) - factory_girl_rails (1.7.0) - factory_girl (~> 2.6.0) + factory_girl (4.1.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.1.0) + factory_girl (~> 4.1.0) railties (>= 3.0.0) - faye (0.8.0) + faye (0.8.6) cookiejar (>= 0.3.0) em-http-request (>= 0.3.0) eventmachine (>= 0.12.0) faye-websocket (>= 0.4.0) rack (>= 1.0.0) yajl-ruby (>= 1.0.0) - faye-websocket (0.4.1) + faye-websocket (0.4.6) eventmachine (>= 0.12.0) - fssm (0.2.8.1) + fssm (0.2.9) haml (3.1.7) hike (1.2.1) - hirb (0.6.1) + hirb (0.7.0) http_accept_language (1.0.2) http_parser.rb (0.5.3) - i18n (0.6.0) - journey (1.0.3) - jquery-rails (2.0.1) - railties (>= 3.2.0, < 5.0) - thor (~> 0.14) - json (1.6.5) - libv8 (3.3.10.4) + i18n (0.6.1) + journey (1.0.4) + jquery-rails (2.1.4) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + json (1.7.5) macaddr (1.6.1) systemu (~> 2.5.0) - mail (2.4.3) + mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.17.2) + mime-types (1.19) mini_magick (3.4) subexec (~> 0.2.1) - multi_json (1.1.0) + multi_json (1.5.0) mysql2 (0.3.11) - nokogiri (1.5.5) + nokogiri (1.5.6) polyglot (0.3.3) - private_pub (1.0.1) + private_pub (1.0.3) faye rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) rails (3.2.2) actionmailer (= 3.2.2) @@ -137,38 +137,39 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - rake (0.9.2.2) + rake (10.0.3) rdoc (3.12) json (~> 1.4) + ref (1.0.2) ruby-graphviz (0.9.21) - sass (3.1.15) - sass-rails (3.2.4) + sass (3.2.4) + sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - sprockets (2.1.2) + sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.6) state_machine (1.1.2) - subexec (0.2.1) - systemu (2.5.1) - therubyracer (0.9.10) - libv8 (~> 3.3.10) + subexec (0.2.2) + systemu (2.5.2) + therubyracer (0.11.0) + ref thor (0.14.6) tilt (1.3.3) - treetop (1.4.10) + treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) - uglifier (1.2.3) + tzinfo (0.3.35) + uglifier (1.3.0) execjs (>= 0.3.0) - multi_json (>= 1.0.2) - uuid (2.3.5) + multi_json (~> 1.0, >= 1.0.2) + uuid (2.3.6) macaddr (~> 1.0) will_paginate (3.0.3) yajl-ruby (1.1.0) -- cgit v1.2.3 From 4e716cea253be9293b247fbe74d25fe288b7853f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:03:10 +0100 Subject: Converted Factory to FactoryGirl. --- Gemfile.lock | 4 +- test/factories/area_codes.rb | 10 +++-- test/factories/call_forwards.rb | 28 +++++++------- test/factories/conference_invitees.rb | 12 +++--- test/factories/conferences.rb | 12 +++--- test/factories/countries.rb | 12 +++--- test/factories/gemeinschaft_setups.rb | 12 +++--- test/factories/languages.rb | 8 ++-- test/factories/manufacturers.rb | 8 ++-- test/factories/ouis.rb | 8 ++-- test/factories/phone_book_entries.rb | 10 +++-- test/factories/phone_books.rb | 8 ++-- test/factories/phone_models.rb | 8 ++-- test/factories/phone_number_ranges.rb | 8 ++-- test/factories/phone_numbers.rb | 10 +++-- test/factories/phones.rb | 22 ++++++----- test/factories/sip_accounts.rb | 26 +++++++------ test/factories/sip_domains.rb | 8 ++-- test/factories/tenant_memberships.rb | 8 ++-- test/factories/tenants.rb | 11 +++--- test/factories/user_group_memberships.rb | 22 ++++++----- test/factories/user_groups.rb | 8 ++-- test/factories/users.rb | 18 +++++---- test/functional/call_forwards_controller_test.rb | 12 +++--- .../conference_invitees_controller_test.rb | 2 +- test/functional/conferences_controller_test.rb | 2 +- .../gemeinschaft_setups_controller_test.rb | 4 +- test/functional/manufacturers_controller_test.rb | 8 ++-- test/functional/page_controller_test.rb | 8 ++-- .../phone_book_entries_controller_test.rb | 4 +- test/functional/phone_books_controller_test.rb | 10 ++--- test/functional/phone_models_controller_test.rb | 12 +++--- .../phone_number_ranges_controller_test.rb | 2 +- test/functional/phone_numbers_controller_test.rb | 8 ++-- test/functional/phones_controller_test.rb | 4 +- .../phones_sip_accounts_controller_test.rb | 2 +- test/functional/sip_accounts_controller_test.rb | 8 ++-- test/functional/sip_domains_controller_test.rb | 4 +- test/functional/tenants_controller_test.rb | 4 +- test/functional/user_groups_controller_test.rb | 4 +- test/functional/users_controller_test.rb | 6 +-- test/unit/area_code_test.rb | 2 +- test/unit/call_forward_test.rb | 2 +- test/unit/conference_invitee_test.rb | 4 +- test/unit/conference_test.rb | 16 ++++---- test/unit/country_test.rb | 2 +- test/unit/gemeinschaft_setup_test.rb | 2 +- test/unit/language_test.rb | 2 +- test/unit/manufacturer_test.rb | 6 +-- test/unit/oui_test.rb | 4 +- test/unit/phone_book_entry_test.rb | 22 +++++------ test/unit/phone_book_test.rb | 44 +++++++++++----------- test/unit/phone_model_test.rb | 2 +- test/unit/phone_number_range_test.rb | 2 +- test/unit/phone_number_test.rb | 20 +++++----- test/unit/phone_test.rb | 14 +++---- test/unit/sip_account_test.rb | 10 ++--- test/unit/sip_domain_test.rb | 2 +- test/unit/tenant_membership_test.rb | 4 +- test/unit/tenant_test.rb | 12 +++--- test/unit/user_group_membership_test.rb | 20 +++++----- test/unit/user_group_test.rb | 20 +++++----- test/unit/user_test.rb | 24 ++++++------ 63 files changed, 332 insertions(+), 289 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 696166f..9336fe9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,8 +50,8 @@ GEM chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) + compass-rails (1.0.0.rc.3) + compass (~> 0.12.rc.0) cookiejar (0.3.0) delayed_job (3.0.4) activesupport (~> 3.0) diff --git a/test/factories/area_codes.rb b/test/factories/area_codes.rb index 87b2271..3ed894d 100644 --- a/test/factories/area_codes.rb +++ b/test/factories/area_codes.rb @@ -1,7 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :area_code do |f| - f.sequence(:name) { |n| "AreaCode #{n}" } - f.sequence(:area_code) { |n| "#{n}" } - f.association :country +FactoryGirl.define do + factory :area_code do + sequence(:name) { |n| "AreaCode #{n}" } + sequence(:area_code) { |n| "#{n}" } + association :country + end end \ No newline at end of file diff --git a/test/factories/call_forwards.rb b/test/factories/call_forwards.rb index d275e9d..bdb899e 100644 --- a/test/factories/call_forwards.rb +++ b/test/factories/call_forwards.rb @@ -1,16 +1,18 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :call_forward do |f| - f.association :phone_number - #OPTIMIZE Make sure that the phone_number's phone_numberable - # isn't a phone_book_entry but a sip_account. - #f.sequence( :call_forward_case_id ) { |n| CallForwardCase.where(:value => "always").first.id } - #f.association :call_forward_case - f.sequence( :call_forward_case_id ) { |n| 1 } - f.sequence( :destination ) { |n| "20#{n}" } - f.sequence( :to_voicemail ) { |n| false } - f.sequence( :timeout ) { |n| nil } - f.sequence( :source ) { |n| nil } - f.sequence( :depth ) { |n| 5 } - f.sequence( :active ) { |n| false } +FactoryGirl.define do + factory :call_forward do + association :phone_number + #OPTIMIZE Make sure that the phone_number's phone_numberable + # isn't a phone_book_entry but a sip_account. + #f.sequence( :call_forward_case_id ) { |n| CallForwardCase.where(:value => "always").first.id } + #f.association :call_forward_case + sequence( :call_forward_case_id ) { |n| 1 } + sequence( :destination ) { |n| "20#{n}" } + sequence( :to_voicemail ) { |n| false } + sequence( :timeout ) { |n| nil } + sequence( :source ) { |n| nil } + sequence( :depth ) { |n| 5 } + sequence( :active ) { |n| false } + end end diff --git a/test/factories/conference_invitees.rb b/test/factories/conference_invitees.rb index 4e1eb68..54fa53a 100644 --- a/test/factories/conference_invitees.rb +++ b/test/factories/conference_invitees.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :conference_invitee do |f| - f.phone_number { Factory.build(:phone_number) } - f.association :conference - f.speaker true - f.moderator false +FactoryGirl.define do + factory :conference_invitee do + phone_number { FactoryGirl.build(:phone_number) } + association :conference + speaker true + moderator false + end end \ No newline at end of file diff --git a/test/factories/conferences.rb b/test/factories/conferences.rb index 3c49a7a..7a563b7 100644 --- a/test/factories/conferences.rb +++ b/test/factories/conferences.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :conference do |f| - f.sequence(:name) { |n| "Conference room #{n}" } - f.open_for_anybody true - f.association :conferenceable, :factory => :tenant - f.max_members 10 +FactoryGirl.define do + factory :conference do + sequence(:name) { |n| "Conference room #{n}" } + open_for_anybody true + association :conferenceable, :factory => :tenant + max_members 10 + end end \ No newline at end of file diff --git a/test/factories/countries.rb b/test/factories/countries.rb index cc3fc88..99caab5 100644 --- a/test/factories/countries.rb +++ b/test/factories/countries.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :country do |f| - f.sequence(:name) { |n| "Country #{n}" } - f.sequence(:country_code) { |n| "#{n}" } - f.sequence(:international_call_prefix) { |n| "#{n}" } - f.sequence(:trunk_prefix) { |n| "#{n}" } +FactoryGirl.define do + factory :country do + sequence(:name) { |n| "Country #{n}" } + sequence(:country_code) { |n| "#{n}" } + sequence(:international_call_prefix) { |n| "#{n}" } + sequence(:trunk_prefix) { |n| "#{n}" } + end end \ No newline at end of file diff --git a/test/factories/gemeinschaft_setups.rb b/test/factories/gemeinschaft_setups.rb index ed69bc3..a2c0f72 100644 --- a/test/factories/gemeinschaft_setups.rb +++ b/test/factories/gemeinschaft_setups.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :gemeinschaft_setup do |f| - f.association :user - f.association :sip_domain - f.association :country - f.association :language +FactoryGirl.define do + factory :gemeinschaft_setup do + association :user + association :sip_domain + association :country + association :language + end end \ No newline at end of file diff --git a/test/factories/languages.rb b/test/factories/languages.rb index 29d2ece..a8ecace 100644 --- a/test/factories/languages.rb +++ b/test/factories/languages.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :language do |f| - f.name 'Deutsch' - f.code 'de' +FactoryGirl.define do + factory :language do + name 'Deutsch' + code 'de' + end end \ No newline at end of file diff --git a/test/factories/manufacturers.rb b/test/factories/manufacturers.rb index f091dd2..e211fc6 100644 --- a/test/factories/manufacturers.rb +++ b/test/factories/manufacturers.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :manufacturer do |f| - f.sequence(:name) { |n| "#{n}. manufacturer" } - f.sequence(:ieee_name) { |n| "#{n}. ieee" } +FactoryGirl.define do + factory :manufacturer do + sequence(:name) { |n| "#{n}. manufacturer" } + sequence(:ieee_name) { |n| "#{n}. ieee" } + end end \ No newline at end of file diff --git a/test/factories/ouis.rb b/test/factories/ouis.rb index 3a90fd4..f99f02b 100644 --- a/test/factories/ouis.rb +++ b/test/factories/ouis.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :oui do |f| - f.association :manufacturer - f.sequence(:value) { |n| (n + 11184810).to_s(16).upcase } +FactoryGirl.define do + factory :oui do + association :manufacturer + sequence(:value) { |n| (n + 11184810).to_s(16).upcase } + end end \ No newline at end of file diff --git a/test/factories/phone_book_entries.rb b/test/factories/phone_book_entries.rb index 7427886..8e1b535 100644 --- a/test/factories/phone_book_entries.rb +++ b/test/factories/phone_book_entries.rb @@ -1,7 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_book_entry do |f| - f.sequence(:last_name) { |n| "Lastname #{n}" } - f.sequence(:is_male) { |n| true } - f.association :phone_book +FactoryGirl.define do + factory :phone_book_entry do + sequence(:last_name) { |n| "Lastname #{n}" } + sequence(:is_male) { |n| true } + association :phone_book + end end diff --git a/test/factories/phone_books.rb b/test/factories/phone_books.rb index 4aa8d07..80e2a06 100644 --- a/test/factories/phone_books.rb +++ b/test/factories/phone_books.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_book do |f| - f.sequence(:name) { |n| "Phone book #{n}" } - f.association :phone_bookable, :factory => :user +FactoryGirl.define do + factory :phone_book do + sequence(:name) { |n| "Phone book #{n}" } + association :phone_bookable, :factory => :user + end end diff --git a/test/factories/phone_models.rb b/test/factories/phone_models.rb index 8e6a50f..28b8802 100644 --- a/test/factories/phone_models.rb +++ b/test/factories/phone_models.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_model do |f| - f.sequence(:name) { |n| "Phone Model #{n}" } - f.association :manufacturer +FactoryGirl.define do + factory :phone_model do + sequence(:name) { |n| "Phone Model #{n}" } + association :manufacturer + end end diff --git a/test/factories/phone_number_ranges.rb b/test/factories/phone_number_ranges.rb index cb2f7ee..68d9a03 100644 --- a/test/factories/phone_number_ranges.rb +++ b/test/factories/phone_number_ranges.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_number_range do |f| - f.name INTERNAL_EXTENSIONS - f.association :phone_number_rangeable, :factory => :tenant +FactoryGirl.define do + factory :phone_number_range do + name INTERNAL_EXTENSIONS + association :phone_number_rangeable, :factory => :tenant + end end diff --git a/test/factories/phone_numbers.rb b/test/factories/phone_numbers.rb index 74b43cc..3b25938 100644 --- a/test/factories/phone_numbers.rb +++ b/test/factories/phone_numbers.rb @@ -1,7 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_number do |f| - f.sequence(:name) { |n| "Name #{n}" } - f.sequence(:number) { |n| "(0)30 227 #{n}" } - f.association :phone_numberable, :factory => :phone_book_entry +FactoryGirl.define do + factory :phone_number do + sequence(:name) { |n| "Name #{n}" } + sequence(:number) { |n| "(0)30 227 #{n}" } + association :phone_numberable, :factory => :phone_book_entry + end end \ No newline at end of file diff --git a/test/factories/phones.rb b/test/factories/phones.rb index 646d548..af0b37a 100644 --- a/test/factories/phones.rb +++ b/test/factories/phones.rb @@ -1,15 +1,17 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone do |f| - f.sequence(:mac_address) { |n| ('%06d' % n).to_s + ('%06d' % n).to_s } - f.association :phone_model - f.association :phoneable, :factory => :tenant +FactoryGirl.define do + factory :phone do |f| + f.sequence(:mac_address) { |n| ('%06d' % n).to_s + ('%06d' % n).to_s } + f.association :phone_model + f.association :phoneable, :factory => :tenant - # We have to make sure that the OUI is created as well. - f.after_build do |instance| - Factory.create(:oui, - :manufacturer => instance.phone_model.manufacturer, - :value => instance.mac_address.slice(0, 6) - ) + # We have to make sure that the OUI is created as well. + f.after_build do |instance| + FactoryGirl.create(:oui, + :manufacturer => instance.phone_model.manufacturer, + :value => instance.mac_address.slice(0, 6) + ) + end end end \ No newline at end of file diff --git a/test/factories/sip_accounts.rb b/test/factories/sip_accounts.rb index 2f91717..a21fa27 100644 --- a/test/factories/sip_accounts.rb +++ b/test/factories/sip_accounts.rb @@ -1,17 +1,19 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :sip_account do |f| - f.association :sip_accountable, :factory => :user - f.sequence(:auth_name) {|n| "auth_name#{n}" } - f.sequence(:caller_name) {|n| "Foo Account #{n}" } - f.sequence(:password) {|n| "12345678" } - - f.after_build do |sip_account| - if sip_account.tenant_id.blank? - tenant = sip_account.create_tenant(FactoryGirl.build(:tenant).attributes) - sip_domain = tenant.create_sip_domain(FactoryGirl.build(:sip_domain).attributes) - sip_account.tenant.tenant_memberships.create(:user_id => sip_account.sip_accountable.id) - sip_account.tenant_id = tenant.id +FactoryGirl.define do + factory :sip_account do |f| + f.association :sip_accountable, :factory => :user + f.sequence(:auth_name) {|n| "auth_name#{n}" } + f.sequence(:caller_name) {|n| "Foo Account #{n}" } + f.sequence(:password) {|n| "12345678" } + + f.after_build do |sip_account| + if sip_account.tenant_id.blank? + tenant = sip_account.create_tenant(FactoryGirl.build(:tenant).attributes) + sip_domain = tenant.create_sip_domain(FactoryGirl.build(:sip_domain).attributes) + sip_account.tenant.tenant_memberships.create(:user_id => sip_account.sip_accountable.id) + sip_account.tenant_id = tenant.id + end end end end diff --git a/test/factories/sip_domains.rb b/test/factories/sip_domains.rb index 347b6a6..442f270 100644 --- a/test/factories/sip_domains.rb +++ b/test/factories/sip_domains.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :sip_domain do |f| - f.sequence(:host ) {|n| "host#{n}.localdomain" } - f.sequence(:realm ) {|n| "host#{n}.localdomain" } +FactoryGirl.define do + factory :sip_domain do + sequence(:host ) {|n| "host#{n}.localdomain" } + sequence(:realm ) {|n| "host#{n}.localdomain" } + end end diff --git a/test/factories/tenant_memberships.rb b/test/factories/tenant_memberships.rb index ee52367..38c4cb8 100644 --- a/test/factories/tenant_memberships.rb +++ b/test/factories/tenant_memberships.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :tenant_membership do |f| - f.association :user - f.association :tenant +FactoryGirl.define do + factory :tenant_membership do + association :user + association :tenant + end end \ No newline at end of file diff --git a/test/factories/tenants.rb b/test/factories/tenants.rb index 9a62e93..fc85e88 100644 --- a/test/factories/tenants.rb +++ b/test/factories/tenants.rb @@ -1,8 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :tenant do |f| - f.sequence(:name) { |n| "Tenant #{n}" } - f.association :country - f.association :language -# f.association :sip_domain +FactoryGirl.define do + factory :tenant do + sequence(:name) { |n| "Tenant #{n}" } + association :country + association :language + end end diff --git a/test/factories/user_group_memberships.rb b/test/factories/user_group_memberships.rb index 7904f2f..8dc74f0 100644 --- a/test/factories/user_group_memberships.rb +++ b/test/factories/user_group_memberships.rb @@ -1,14 +1,16 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :user_group_membership do |f| - f.association :user_group - f.association :user - - # Make sure that the User is a member of the Tenant. - f.after_build do |instance| - Factory.create(:tenant_membership, - :tenant_id => instance.user_group.tenant.id, - :user_id => instance.user.id - ) +FactoryGirl.define do + factory :user_group_membership do |f| + f.association :user_group + f.association :user + + # Make sure that the User is a member of the Tenant. + f.after_build do |instance| + FactoryGirl.create(:tenant_membership, + :tenant_id => instance.user_group.tenant.id, + :user_id => instance.user.id + ) + end end end \ No newline at end of file diff --git a/test/factories/user_groups.rb b/test/factories/user_groups.rb index 9a448ec..c777d95 100644 --- a/test/factories/user_groups.rb +++ b/test/factories/user_groups.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :user_group do |f| - f.sequence(:name) { |n| "UserGroup #{n}" } - f.association :tenant +FactoryGirl.define do + factory :user_group do + sequence(:name) { |n| "UserGroup #{n}" } + association :tenant + end end \ No newline at end of file diff --git a/test/factories/users.rb b/test/factories/users.rb index 3d53141..a84b41d 100644 --- a/test/factories/users.rb +++ b/test/factories/users.rb @@ -1,11 +1,13 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :user do |f| - f.sequence(:user_name) { |n| "User #{n}" } - f.sequence(:first_name) { |n| "John #{n}" } - f.sequence(:last_name) { |n| "Smith #{n}" } - f.sequence(:email) { |n| "john.smith#{n}@company.com" } - f.sequence(:password) { |n| "Testpassword#{n}" } - f.sequence(:password_confirmation) { |n| "Testpassword#{n}" } - f.association :language +FactoryGirl.define do + factory :user do + sequence(:user_name) { |n| "User #{n}" } + sequence(:first_name) { |n| "John #{n}" } + sequence(:last_name) { |n| "Smith #{n}" } + sequence(:email) { |n| "john.smith#{n}@company.com" } + sequence(:password) { |n| "Testpassword#{n}" } + sequence(:password_confirmation) { |n| "Testpassword#{n}" } + association :language + end end \ No newline at end of file diff --git a/test/functional/call_forwards_controller_test.rb b/test/functional/call_forwards_controller_test.rb index 0993623..da8e6c9 100644 --- a/test/functional/call_forwards_controller_test.rb +++ b/test/functional/call_forwards_controller_test.rb @@ -3,27 +3,27 @@ require 'test_helper' class CallForwardsControllerTest < ActionController::TestCase setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) - #@tenant = Factory.create(:tenant) + #@tenant = FactoryGirl.create(:tenant) #@tenant.tenant_memberships.create(:user_id => @user.id) #@user.update_attributes!(:current_tenant_id => @tenant.id) - @sip_account = Factory.create( + @sip_account = FactoryGirl.create( :sip_account, :sip_accountable => @user, ) @user.sip_accounts << @sip_account @sip_account = @user.sip_accounts.last - @phone_number = Factory.create( + @phone_number = FactoryGirl.create( :phone_number, :phone_numberable => @sip_account, ) @sip_account.phone_numbers << @phone_number @phone_number = @sip_account.phone_numbers.last - @call_forward = Factory.create( + @call_forward = FactoryGirl.create( :call_forward, :phone_number => @phone_number, ) @@ -50,7 +50,7 @@ class CallForwardsControllerTest < ActionController::TestCase # assert_difference('CallForward.count') do # post :create, # :phone_number_id => @phone_number.to_param, -# :call_forward => Factory.attributes_for( +# :call_forward => FactoryGirl.attributes_for( # :call_forward # ) # end diff --git a/test/functional/conference_invitees_controller_test.rb b/test/functional/conference_invitees_controller_test.rb index 72d2e2c..8ac5479 100644 --- a/test/functional/conference_invitees_controller_test.rb +++ b/test/functional/conference_invitees_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class ConferenceInviteesControllerTest < ActionController::TestCase setup do - @conference_invitee = Factory.create(:conference_invitee) + @conference_invitee = FactoryGirl.create(:conference_invitee) end # test "should get index" do diff --git a/test/functional/conferences_controller_test.rb b/test/functional/conferences_controller_test.rb index 954838b..0f2d007 100644 --- a/test/functional/conferences_controller_test.rb +++ b/test/functional/conferences_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class ConferencesControllerTest < ActionController::TestCase setup do - @conference = Factory.create(:conference) + @conference = FactoryGirl.create(:conference) end # test "should get index" do diff --git a/test/functional/gemeinschaft_setups_controller_test.rb b/test/functional/gemeinschaft_setups_controller_test.rb index b23a878..5e6cadf 100644 --- a/test/functional/gemeinschaft_setups_controller_test.rb +++ b/test/functional/gemeinschaft_setups_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class GemeinschaftSetupsControllerTest < ActionController::TestCase setup do - @gemeinschaft_setup = Factory.build(:gemeinschaft_setup) + @gemeinschaft_setup = FactoryGirl.build(:gemeinschaft_setup) end # test "should get index" do @@ -20,7 +20,7 @@ class GemeinschaftSetupsControllerTest < ActionController::TestCase # test "should create gemeinschaft_setup" do # assert_difference('GemeinschaftSetup.count') do # post :create, -# gemeinschaft_setup: Factory.attributes_for(:gemeinschaft_setup) +# gemeinschaft_setup: FactoryGirl.attributes_for(:gemeinschaft_setup) # end # assert_redirected_to gemeinschaft_setup_path(assigns(:gemeinschaft_setup)) # end diff --git a/test/functional/manufacturers_controller_test.rb b/test/functional/manufacturers_controller_test.rb index dad38e5..0b10f6d 100644 --- a/test/functional/manufacturers_controller_test.rb +++ b/test/functional/manufacturers_controller_test.rb @@ -2,14 +2,14 @@ require 'test_helper' class ManufacturersControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @user.update_attributes!(:current_tenant_id => @tenant.id) - @manufacturer = Factory.create(:manufacturer) + @manufacturer = FactoryGirl.create(:manufacturer) @expected_status_if_not_authorized = :redirect end @@ -46,7 +46,7 @@ class ManufacturersControllerTest < ActionController::TestCase # # test "should create manufacturer" do # assert_difference('Manufacturer.count') do - # post :create, manufacturer: Factory.build(:manufacturer).attributes + # post :create, manufacturer: FactoryGirl.build(:manufacturer).attributes # end # # assert_redirected_to manufacturer_path(assigns(:manufacturer)) diff --git a/test/functional/page_controller_test.rb b/test/functional/page_controller_test.rb index a5ae5ad..2bc1b80 100644 --- a/test/functional/page_controller_test.rb +++ b/test/functional/page_controller_test.rb @@ -11,8 +11,8 @@ class PageControllerTest < ActionController::TestCase test "a logged in user should get index" do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.users << @user @@ -22,8 +22,8 @@ class PageControllerTest < ActionController::TestCase end test "a logged out user should be redirected to the login" do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.users << @user diff --git a/test/functional/phone_book_entries_controller_test.rb b/test/functional/phone_book_entries_controller_test.rb index 81c5b61..b340f0f 100644 --- a/test/functional/phone_book_entries_controller_test.rb +++ b/test/functional/phone_book_entries_controller_test.rb @@ -3,9 +3,9 @@ require 'test_helper' class PhoneBookEntriesControllerTest < ActionController::TestCase setup do - @user1 = Factory.create(:user) + @user1 = FactoryGirl.create(:user) pb = @user1.phone_books.first - @user1_phone_book_entry = Factory.create( + @user1_phone_book_entry = FactoryGirl.create( :phone_book_entry, :phone_book_id => pb.id ) diff --git a/test/functional/phone_books_controller_test.rb b/test/functional/phone_books_controller_test.rb index a00f597..aef2890 100644 --- a/test/functional/phone_books_controller_test.rb +++ b/test/functional/phone_books_controller_test.rb @@ -2,19 +2,19 @@ require 'test_helper' class PhoneBooksControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) @admins = @tenant.user_groups.find_or_create_by_name('Admins') @users = @tenant.user_groups.find_or_create_by_name('Users') - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @tenant.users << @user @users.users << @user - @personal_phone_book = Factory.create(:phone_book, + @personal_phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => @user.class.to_s, :phone_bookable_id => @user.id ) - phone_book_entry = Factory.create(:phone_book_entry) + phone_book_entry = FactoryGirl.create(:phone_book_entry) @personal_phone_book.phone_book_entries << phone_book_entry @expected_status_if_not_authorized = :redirect @@ -34,7 +34,7 @@ class PhoneBooksControllerTest < ActionController::TestCase end test "should create phone_book" do - phone_book2 = Factory.build(:phone_book, + phone_book2 = FactoryGirl.build(:phone_book, :phone_bookable_type => @user.class.to_s, :phone_bookable_id => @user.id ) diff --git a/test/functional/phone_models_controller_test.rb b/test/functional/phone_models_controller_test.rb index 2d1a87a..199be45 100644 --- a/test/functional/phone_models_controller_test.rb +++ b/test/functional/phone_models_controller_test.rb @@ -4,21 +4,21 @@ class PhoneModelsControllerTest < ActionController::TestCase setup do # Create a tenant: - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) # Create a User who is member of the Tenant but has no special rights: - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @user.update_attributes!(:current_tenant_id => @tenant.id) # Create a User who is member of the Tenant and has super admin rights: - @super_admin = Factory.create(:user) + @super_admin = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @super_admin.id) @super_admin.update_attributes!(:current_tenant_id => @tenant.id) # Create a PhoneModel # - @phone_model = Factory.create(:phone_model) + @phone_model = FactoryGirl.create(:phone_model) end [ '@user.id', '' ].each do |user_id_code| @@ -44,7 +44,7 @@ class PhoneModelsControllerTest < ActionController::TestCase session[:user_id] = eval( user_id_code ) assert_no_difference('PhoneModel.count') do - post :create, manufacturer_id: @phone_model.manufacturer_id, phone_model: Factory.build(:phone_model, + post :create, manufacturer_id: @phone_model.manufacturer_id, phone_model: FactoryGirl.build(:phone_model, :manufacturer_id => @phone_model.manufacturer_id).attributes end end @@ -106,7 +106,7 @@ class PhoneModelsControllerTest < ActionController::TestCase # # add routes first. # test "should create phone_model as super admin" do # assert_difference('PhoneModel.count') do - # post :create, phone_model: Factory.build(:phone_model, + # post :create, phone_model: FactoryGirl.build(:phone_model, # :manufacturer_id => @phone_model.manufacturer_id).attributes # end # diff --git a/test/functional/phone_number_ranges_controller_test.rb b/test/functional/phone_number_ranges_controller_test.rb index 39f28c4..9569f3e 100644 --- a/test/functional/phone_number_ranges_controller_test.rb +++ b/test/functional/phone_number_ranges_controller_test.rb @@ -5,7 +5,7 @@ class PhoneNumberRangesControllerTest < ActionController::TestCase #TODO Uncomment tests once the views are implemented. setup do - @phone_number_range = Factory.create(:phone_number_range) + @phone_number_range = FactoryGirl.create(:phone_number_range) end test "should get index" do diff --git a/test/functional/phone_numbers_controller_test.rb b/test/functional/phone_numbers_controller_test.rb index ab0a4b2..b11e3e8 100644 --- a/test/functional/phone_numbers_controller_test.rb +++ b/test/functional/phone_numbers_controller_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class PhoneNumbersControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @@ -12,11 +12,11 @@ class PhoneNumbersControllerTest < ActionController::TestCase @private_phone_book = @user.phone_books.first - @private_phone_book_entry = Factory.create( + @private_phone_book_entry = FactoryGirl.create( :phone_book_entry, :phone_book => @private_phone_book ) - @phone_number = Factory.create( + @phone_number = FactoryGirl.create( :phone_number, :phone_numberable => @private_phone_book_entry ) diff --git a/test/functional/phones_controller_test.rb b/test/functional/phones_controller_test.rb index 1b0aa55..f2cc716 100644 --- a/test/functional/phones_controller_test.rb +++ b/test/functional/phones_controller_test.rb @@ -6,7 +6,7 @@ class PhonesControllerTest < ActionController::TestCase #TODO Uncomment tests once the route has been implemented. # setup do -# @phone = Factory.create(:phone) +# @phone = FactoryGirl.create(:phone) # end # # test "should get index" do @@ -24,7 +24,7 @@ class PhonesControllerTest < ActionController::TestCase # # # # test "should create phone" do # # assert_difference('Phone.count') do -# # post :create, phone: Factory.build(:phone, :phone_model_id => @phone.phone_model_id).attributes +# # post :create, phone: FactoryGirl.build(:phone, :phone_model_id => @phone.phone_model_id).attributes # # end # # # # assert_redirected_to phone_path(assigns(:phone)) diff --git a/test/functional/phones_sip_accounts_controller_test.rb b/test/functional/phones_sip_accounts_controller_test.rb index 967b8fe..834e502 100644 --- a/test/functional/phones_sip_accounts_controller_test.rb +++ b/test/functional/phones_sip_accounts_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PhonesSipAccountsControllerTest < ActionController::TestCase setup do - @phones_sip_account = Factory.create(:phones_sip_account) + @phones_sip_account = FactoryGirl.create(:phones_sip_account) end # test "should get index" do diff --git a/test/functional/sip_accounts_controller_test.rb b/test/functional/sip_accounts_controller_test.rb index 5c97dd2..e079718 100644 --- a/test/functional/sip_accounts_controller_test.rb +++ b/test/functional/sip_accounts_controller_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class SipAccountsControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) - @sip_account = @user.sip_accounts.create( Factory.build(:sip_account).attributes ) + @sip_account = @user.sip_accounts.create( FactoryGirl.build(:sip_account).attributes ) @parent_param = @sip_account.sip_accountable_type.foreign_key.to_sym @parent_id = @sip_account.sip_accountable.id @@ -32,7 +32,7 @@ class SipAccountsControllerTest < ActionController::TestCase assert_difference('SipAccount.count') do post :create, @parent_param => @parent_id, - sip_account: Factory.attributes_for(:sip_account) + sip_account: FactoryGirl.attributes_for(:sip_account) end end diff --git a/test/functional/sip_domains_controller_test.rb b/test/functional/sip_domains_controller_test.rb index f26ea02..5cbd519 100644 --- a/test/functional/sip_domains_controller_test.rb +++ b/test/functional/sip_domains_controller_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class SipDomainsControllerTest < ActionController::TestCase setup do - @sip_domain = Factory.create(:sip_domain) + @sip_domain = FactoryGirl.create(:sip_domain) end test "should get index" do @@ -18,7 +18,7 @@ class SipDomainsControllerTest < ActionController::TestCase test "should create sip_domain" do assert_difference('SipDomain.count') do - post :create, sip_domain: Factory.build(:sip_domain).attributes + post :create, sip_domain: FactoryGirl.build(:sip_domain).attributes end assert_redirected_to sip_domain_path(assigns(:sip_domain)) diff --git a/test/functional/tenants_controller_test.rb b/test/functional/tenants_controller_test.rb index b4e2df4..7c5ec93 100644 --- a/test/functional/tenants_controller_test.rb +++ b/test/functional/tenants_controller_test.rb @@ -4,7 +4,7 @@ class TenantsControllerTest < ActionController::TestCase # TODO Create tests which test that a login user has specific rights. # setup do - # @tenant = Factory.create(:tenant) + # @tenant = FactoryGirl.create(:tenant) # end # # test "should get index" do @@ -20,7 +20,7 @@ class TenantsControllerTest < ActionController::TestCase # # test "should create tenant" do # assert_difference('Tenant.count') do - # post :create, tenant: Factory.build(:tenant).attributes + # post :create, tenant: FactoryGirl.build(:tenant).attributes # end # # assert_redirected_to tenant_path(assigns(:tenant)) diff --git a/test/functional/user_groups_controller_test.rb b/test/functional/user_groups_controller_test.rb index 0e39048..6f0c753 100644 --- a/test/functional/user_groups_controller_test.rb +++ b/test/functional/user_groups_controller_test.rb @@ -4,7 +4,7 @@ class UserGroupsControllerTest < ActionController::TestCase # TODO Create tests which test that a login user has specific rights. # setup do - # @user_group = Factory.create(:user_group) + # @user_group = FactoryGirl.create(:user_group) # end # # test "should get index" do @@ -20,7 +20,7 @@ class UserGroupsControllerTest < ActionController::TestCase # # test "should create user_group" do # assert_difference('UserGroup.count') do - # post :create, user_group: Factory.build(:user_group).attributes + # post :create, user_group: FactoryGirl.build(:user_group).attributes # end # # assert_redirected_to user_group_path(assigns(:user_group)) diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index d1898f7..987b3df 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -2,8 +2,8 @@ require 'test_helper' class UsersControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @@ -30,7 +30,7 @@ class UsersControllerTest < ActionController::TestCase # test "should create user" do # session[:user_id] = nil # assert_difference('User.count') do - # post :create, user: Factory.build(:user).attributes + # post :create, user: FactoryGirl.build(:user).attributes # end # # # assert_redirected_to user_path(assigns(:user)) diff --git a/test/unit/area_code_test.rb b/test/unit/area_code_test.rb index 10c7c08..d59b290 100644 --- a/test/unit/area_code_test.rb +++ b/test/unit/area_code_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class AreaCodeTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:area_code).valid? + assert FactoryGirl.build(:area_code).valid? end end diff --git a/test/unit/call_forward_test.rb b/test/unit/call_forward_test.rb index 95716c5..afde3c0 100644 --- a/test/unit/call_forward_test.rb +++ b/test/unit/call_forward_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class CallForwardTest < ActiveSupport::TestCase test "should have a valid factory" do - assert Factory.build(:call_forward).valid? + assert FactoryGirl.build(:call_forward).valid? end end diff --git a/test/unit/conference_invitee_test.rb b/test/unit/conference_invitee_test.rb index bcc4c9b..2823709 100644 --- a/test/unit/conference_invitee_test.rb +++ b/test/unit/conference_invitee_test.rb @@ -3,11 +3,11 @@ require 'test_helper' class ConferenceInviteeTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:conference_invitee).valid? + assert FactoryGirl.build(:conference_invitee).valid? end test "parent conference should not have a phone number twice" do - invitee = Factory.create(:conference_invitee) + invitee = FactoryGirl.create(:conference_invitee) conference = invitee.conference phone_number = PhoneNumber.new(:number => invitee.phone_number.number) invitee_bad = conference.conference_invitees.build(:phone_number => phone_number) diff --git a/test/unit/conference_test.rb b/test/unit/conference_test.rb index b7cce28..85f7ddb 100644 --- a/test/unit/conference_test.rb +++ b/test/unit/conference_test.rb @@ -3,29 +3,29 @@ require 'test_helper' class ConferenceTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:conference).valid? + assert FactoryGirl.build(:conference).valid? end def test_dates_must_make_sense # We can't create a conference in the past. - assert !Factory.build(:conference, :start => Time.now - 1.day, :end => Time.now + 1.day).valid? + assert !FactoryGirl.build(:conference, :start => Time.now - 1.day, :end => Time.now + 1.day).valid? # But we can create a conference which started 2 minutes ago. - assert Factory.build(:conference, :start => Time.now - 2.minutes, :end => Time.now + 1.hour).valid? + assert FactoryGirl.build(:conference, :start => Time.now - 2.minutes, :end => Time.now + 1.hour).valid? # The end must be before the start. - assert !Factory.build(:conference, :start => Time.now + 2.day, :end => Time.now + 1.day).valid? + assert !FactoryGirl.build(:conference, :start => Time.now + 2.day, :end => Time.now + 1.day).valid? # No date at all is fine. - assert Factory.build(:conference, :start => nil, :end => nil).valid? + assert FactoryGirl.build(:conference, :start => nil, :end => nil).valid? # Just start or just end is not ok. - assert !Factory.build(:conference, :start => nil, :end => Time.now + 1.day).valid? - assert !Factory.build(:conference, :start => Time.now + 1.day, :end => nil).valid? + assert !FactoryGirl.build(:conference, :start => nil, :end => Time.now + 1.day).valid? + assert !FactoryGirl.build(:conference, :start => Time.now + 1.day, :end => nil).valid? end def test_pin_must_be_nil_or_more_than_6_digits - conference = Factory.build(:conference, :pin => nil) + conference = FactoryGirl.build(:conference, :pin => nil) assert conference.valid? diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb index 4933843..06f520e 100644 --- a/test/unit/country_test.rb +++ b/test/unit/country_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class CountryTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:country).valid? + assert FactoryGirl.build(:country).valid? end end diff --git a/test/unit/gemeinschaft_setup_test.rb b/test/unit/gemeinschaft_setup_test.rb index 5ea6523..bd398ff 100644 --- a/test/unit/gemeinschaft_setup_test.rb +++ b/test/unit/gemeinschaft_setup_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class GemeinschaftSetupTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:gemeinschaft_setup).valid? + assert FactoryGirl.build(:gemeinschaft_setup).valid? end end diff --git a/test/unit/language_test.rb b/test/unit/language_test.rb index 3308735..4a8cd77 100644 --- a/test/unit/language_test.rb +++ b/test/unit/language_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class LanguageTest < ActiveSupport::TestCase test "has a valid factory" do - assert Factory.build(:language).valid? + assert FactoryGirl.build(:language).valid? end end diff --git a/test/unit/manufacturer_test.rb b/test/unit/manufacturer_test.rb index 635a977..012d34d 100644 --- a/test/unit/manufacturer_test.rb +++ b/test/unit/manufacturer_test.rb @@ -2,18 +2,18 @@ require 'test_helper' class ManufacturerTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:manufacturer).valid? + assert FactoryGirl.build(:manufacturer).valid? end # StateMachine Tests: def test_that_the_initial_state_should_be_active - @manufacturer = Factory.create(:manufacturer) + @manufacturer = FactoryGirl.create(:manufacturer) assert_equal 'active', @manufacturer.state assert @manufacturer.active? end def test_not_active_state_will_not_be_displayed - @manufacturer = Factory.create(:manufacturer) + @manufacturer = FactoryGirl.create(:manufacturer) assert_equal 1, Manufacturer.count @manufacturer.deactivate! diff --git a/test/unit/oui_test.rb b/test/unit/oui_test.rb index de48a97..cff5864 100644 --- a/test/unit/oui_test.rb +++ b/test/unit/oui_test.rb @@ -2,11 +2,11 @@ require 'test_helper' class OuiTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:oui).valid? + assert FactoryGirl.build(:oui).valid? end def test_that_the_initial_state_should_be_active - @oui = Factory.create(:oui) + @oui = FactoryGirl.create(:oui) assert_equal 'active', @oui.state assert @oui.active? end diff --git a/test/unit/phone_book_entry_test.rb b/test/unit/phone_book_entry_test.rb index c8d639b..2613398 100644 --- a/test/unit/phone_book_entry_test.rb +++ b/test/unit/phone_book_entry_test.rb @@ -2,17 +2,17 @@ require 'test_helper' class PhoneBookEntryTest < ActiveSupport::TestCase def test_should_be_valid - assert Factory.build(:phone_book_entry).valid? + assert FactoryGirl.build(:phone_book_entry).valid? end # TODO Fix this test. # test "only user can read entries in private phone books" do - # user = Factory.create(:user) - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) - # phone_book_entry = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) + # user = FactoryGirl.create(:user) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) + # phone_book_entry = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -24,17 +24,17 @@ class PhoneBookEntryTest < ActiveSupport::TestCase # end def test_that_the_initial_state_should_be_active - @phone_book_entry = Factory.create(:phone_book_entry) + @phone_book_entry = FactoryGirl.create(:phone_book_entry) assert_equal 'active', @phone_book_entry.state assert @phone_book_entry.active? end test "a destroyed phone_book will destroy all phone_book_entries" do - phone_book = Factory.create(:phone_book) - 10.times { Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) } + phone_book = FactoryGirl.create(:phone_book) + 10.times { FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) } - phone_book2 = Factory.create(:phone_book) - 5.times { Factory.create(:phone_book_entry, :phone_book_id => phone_book2.id) } + phone_book2 = FactoryGirl.create(:phone_book) + 5.times { FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book2.id) } assert_equal 15, PhoneBookEntry.all.count @@ -44,7 +44,7 @@ class PhoneBookEntryTest < ActiveSupport::TestCase end test "that the value_of_to_s field is filled" do - phone_book_entry = Factory.create(:phone_book_entry) + phone_book_entry = FactoryGirl.create(:phone_book_entry) assert_equal phone_book_entry.value_of_to_s, phone_book_entry.to_s end diff --git a/test/unit/phone_book_test.rb b/test/unit/phone_book_test.rb index 7db48f8..b820521 100644 --- a/test/unit/phone_book_test.rb +++ b/test/unit/phone_book_test.rb @@ -2,15 +2,15 @@ require 'test_helper' class PhoneBookTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone_book).valid? + assert FactoryGirl.build(:phone_book).valid? end def test_should_have_unique_name_depending_on_type - user1 = Factory.create(:user) - user2 = Factory.create(:user) - tenant = Factory.create(:tenant) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) + tenant = FactoryGirl.create(:tenant) - phonebook = Factory.create(:phone_book, :phone_bookable => user1) + phonebook = FactoryGirl.create(:phone_book, :phone_bookable => user1) assert !user1.phone_books.build(:name => phonebook.name).valid? assert user2.phone_books.build(:name => phonebook.name).valid? assert tenant.phone_books.build(:name => phonebook.name).valid? @@ -20,7 +20,7 @@ class PhoneBookTest < ActiveSupport::TestCase # test "User gets a private phone book with rw rights" do - # user = Factory.create(:user) + # user = FactoryGirl.create(:user) # assert_equal 1, user.phone_books.count # phone_book = user.phone_books.first @@ -34,9 +34,9 @@ class PhoneBookTest < ActiveSupport::TestCase # # Lets test some stuff about the phone_book_entries # assert_equal 0, phone_book.phone_book_entries.count - # entry1 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) - # entry2 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) - # entry3 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) + # entry1 = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) + # entry2 = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) + # entry3 = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) # assert_equal 3, phone_book.phone_book_entries.count # assert_equal 1, PhoneBookEntry.where(:id => entry1.id).count @@ -50,22 +50,22 @@ class PhoneBookTest < ActiveSupport::TestCase # end test "Tenant gets automatically one phone book and can destroy it" do - tenant = Factory.create(:tenant) + tenant = FactoryGirl.create(:tenant) assert_equal 1, tenant.phone_books.count tenant.phone_books.first.destroy assert_equal 0, tenant.phone_books.count end # test "only tenant members can read a tenant phone book" do - # tenant = Factory.create(:tenant) - # user = Factory.create(:user) + # tenant = FactoryGirl.create(:tenant) + # user = FactoryGirl.create(:user) # tenant.users << user # tenant.save # user.current_tenant = tenant # user.save - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -79,12 +79,12 @@ class PhoneBookTest < ActiveSupport::TestCase # test "tenant's phone book can not be edited by tenant members" do - # tenant = Factory.create(:tenant) - # user = Factory.create(:user) + # tenant = FactoryGirl.create(:tenant) + # user = FactoryGirl.create(:user) # tenant.users << user - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -96,10 +96,10 @@ class PhoneBookTest < ActiveSupport::TestCase # end # test "only user can manage his private phone book after creating it" do - # user = Factory.create(:user) - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) + # user = FactoryGirl.create(:user) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -111,7 +111,7 @@ class PhoneBookTest < ActiveSupport::TestCase # end def test_that_the_initial_state_should_be_active - @phone_book = Factory.create(:phone_book) + @phone_book = FactoryGirl.create(:phone_book) assert_equal 'active', @phone_book.state assert @phone_book.active? end diff --git a/test/unit/phone_model_test.rb b/test/unit/phone_model_test.rb index e358cf9..ef293f4 100644 --- a/test/unit/phone_model_test.rb +++ b/test/unit/phone_model_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PhoneModelTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone_model).valid? + assert FactoryGirl.build(:phone_model).valid? end end diff --git a/test/unit/phone_number_range_test.rb b/test/unit/phone_number_range_test.rb index 1770299..e70cd60 100644 --- a/test/unit/phone_number_range_test.rb +++ b/test/unit/phone_number_range_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PhoneNumberRangeTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone_number_range).valid? + assert FactoryGirl.build(:phone_number_range).valid? end end diff --git a/test/unit/phone_number_test.rb b/test/unit/phone_number_test.rb index e10b20c..3fd92d6 100644 --- a/test/unit/phone_number_test.rb +++ b/test/unit/phone_number_test.rb @@ -5,17 +5,17 @@ require 'test_helper' class PhoneNumberTest < ActiveSupport::TestCase test "should have valid factory" do - assert Factory.build(:phone_number).valid? + assert FactoryGirl.build(:phone_number).valid? end def test_that_the_initial_state_should_be_active - @phone_number = Factory.create(:phone_number) + @phone_number = FactoryGirl.create(:phone_number) assert_equal 'active', @phone_number.state assert @phone_number.active? end test "that the value_of_to_s field is filled" do - phone_number = Factory.create(:phone_number) + phone_number = FactoryGirl.create(:phone_number) assert_equal phone_number.value_of_to_s, phone_number.to_s end @@ -198,7 +198,7 @@ class PhoneNumberTest < ActiveSupport::TestCase AreaCode.create(:country => germany, :name => "Hohenmocker", :area_code => "39993") # create a tenant - tenant = Factory.create(:tenant, :country_id => germany.id) + tenant = FactoryGirl.create(:tenant, :country_id => germany.id) # create some extensions internal_extension_range = tenant.phone_number_ranges.create(:name => INTERNAL_EXTENSIONS) ['2000', '2001', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '5', '99'].each do |extension| @@ -216,7 +216,7 @@ class PhoneNumberTest < ActiveSupport::TestCase # Language.create(:name => 'Deutsch', :code => 'de') # AreaCode.create(:country => germany, :name => "Bendorf", :area_code => "2622") - # @sip_domain = Factory.create(:sip_domain) + # @sip_domain = FactoryGirl.create(:sip_domain) # @tenant = @sip_domain.tenants.build(:name => 'AMOOMA GmbH') # @tenant.country = Country.first @@ -226,8 +226,8 @@ class PhoneNumberTest < ActiveSupport::TestCase # @tenant.generate_internal_extensions - # sip_account = @tenant.sip_accounts.build(Factory.create(:sip_account).attributes) - # phone_number = sip_account.phone_numbers.create(Factory.build(:phone_number, :number => '10').attributes) + # sip_account = @tenant.sip_accounts.build(FactoryGirl.create(:sip_account).attributes) + # phone_number = sip_account.phone_numbers.create(FactoryGirl.build(:phone_number, :number => '10').attributes) # phone_number_evil = sip_account.phone_numbers.build(phone_number.attributes) # assert phone_number.valid? @@ -235,14 +235,14 @@ class PhoneNumberTest < ActiveSupport::TestCase # end # test "has to be unique per SIP domain even for different tenants" do - # provider_sip_domain = Factory.create(:sip_domain) + # provider_sip_domain = FactoryGirl.create(:sip_domain) # tenants = [] # sip_accounts = [] # 2.times { |i| - # tenants[i] = provider_sip_domain.tenants.create(Factory.build(:tenant, :internal_extension_ranges => '10-20').attributes) + # tenants[i] = provider_sip_domain.tenants.create(FactoryGirl.build(:tenant, :internal_extension_ranges => '10-20').attributes) # tenants[i].generate_internal_extensions - # sip_accounts[i] = tenants[i].sip_accounts.build(Factory.build(:sip_account, :tenant_id => tenants[i].id).attributes) + # sip_accounts[i] = tenants[i].sip_accounts.build(FactoryGirl.build(:sip_account, :tenant_id => tenants[i].id).attributes) # sip_accounts[i].phone_numbers.build(:number => '10') # } # sip_accounts[0].save diff --git a/test/unit/phone_test.rb b/test/unit/phone_test.rb index 4ad21df..b9d33af 100644 --- a/test/unit/phone_test.rb +++ b/test/unit/phone_test.rb @@ -3,19 +3,19 @@ require 'test_helper' class PhoneTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone).valid? + assert FactoryGirl.build(:phone).valid? end # test "should destroy_all phones_sip_accounts if the phoneable changed" do - # sip_domain = Factory.create(:sip_domain) - # tenant = sip_domain.tenants.create(Factory.build(:tenant).attributes) + # sip_domain = FactoryGirl.create(:sip_domain) + # tenant = sip_domain.tenants.create(FactoryGirl.build(:tenant).attributes) # - # user1 = Factory.create(:user) - # user2 = Factory.create(:user) + # user1 = FactoryGirl.create(:user) + # user2 = FactoryGirl.create(:user) # tenant.tenant_memberships.create(:user_id => user1.id) # tenant.tenant_memberships.create(:user_id => user2.id) # - # phone = Factory.create(:phone, :phoneable => tenant) + # phone = FactoryGirl.create(:phone, :phoneable => tenant) # # # Nothing there # # @@ -28,7 +28,7 @@ class PhoneTest < ActiveSupport::TestCase # # # create some sip_accounts associated to phone # # - # 3.times { Factory.create(:sip_account, :sip_accountable => user1, :tenant_id => tenant.id) } + # 3.times { FactoryGirl.create(:sip_account, :sip_accountable => user1, :tenant_id => tenant.id) } # SipAccount.all.each do |sip_account| # phone.phones_sip_accounts.create(:sip_account_id => sip_account.id) # end diff --git a/test/unit/sip_account_test.rb b/test/unit/sip_account_test.rb index 6595ccc..e85e493 100644 --- a/test/unit/sip_account_test.rb +++ b/test/unit/sip_account_test.rb @@ -3,21 +3,21 @@ require 'test_helper' class SipAccountTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:sip_account).valid? + assert FactoryGirl.build(:sip_account).valid? end test "that the value_of_to_s field is filled" do - sip_account = Factory.create(:sip_account) + sip_account = FactoryGirl.create(:sip_account) assert_equal sip_account.value_of_to_s, sip_account.to_s end test "should have a unique auth_name per sip_domain" do - provider_sip_domain = Factory.create(:sip_domain) + provider_sip_domain = FactoryGirl.create(:sip_domain) tenants = [] sip_accounts = [] 2.times { |i| - tenants[i] = provider_sip_domain.tenants.create(Factory.build(:tenant).attributes) - sip_accounts[i] = Factory.build( + tenants[i] = provider_sip_domain.tenants.create(FactoryGirl.build(:tenant).attributes) + sip_accounts[i] = FactoryGirl.build( :sip_account, :sip_accountable => tenants[i], :auth_name => "somerandomauthname", diff --git a/test/unit/sip_domain_test.rb b/test/unit/sip_domain_test.rb index 5d31f69..61ac89a 100644 --- a/test/unit/sip_domain_test.rb +++ b/test/unit/sip_domain_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class SipDomainTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:sip_domain).valid? + assert FactoryGirl.build(:sip_domain).valid? end end diff --git a/test/unit/tenant_membership_test.rb b/test/unit/tenant_membership_test.rb index 8e7a191..ba57eae 100644 --- a/test/unit/tenant_membership_test.rb +++ b/test/unit/tenant_membership_test.rb @@ -2,11 +2,11 @@ require 'test_helper' class TenantMembershipTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:tenant_membership).valid? + assert FactoryGirl.build(:tenant_membership).valid? end def test_that_the_initial_state_should_be_active - @tenant_membership = Factory.create(:tenant_membership) + @tenant_membership = FactoryGirl.create(:tenant_membership) assert_equal 'active', @tenant_membership.state assert @tenant_membership.active? end diff --git a/test/unit/tenant_test.rb b/test/unit/tenant_test.rb index 4d4abce..0b342ba 100644 --- a/test/unit/tenant_test.rb +++ b/test/unit/tenant_test.rb @@ -2,23 +2,23 @@ require 'test_helper' class TenantTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:tenant).valid? + assert FactoryGirl.build(:tenant).valid? end def test_should_have_unique_name - tenant = Factory.create(:tenant) - assert !Factory.build(:tenant, :name => tenant.name).valid? - assert Factory.build(:tenant, :name => "different_#{tenant.name}").valid? + tenant = FactoryGirl.create(:tenant) + assert !FactoryGirl.build(:tenant, :name => tenant.name).valid? + assert FactoryGirl.build(:tenant, :name => "different_#{tenant.name}").valid? end def test_that_the_initial_state_should_be_active - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) assert_equal 'active', @tenant.state assert @tenant.active? end def test_not_active_state_will_not_be_displayed - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) assert_equal 1, Tenant.count @tenant.deactivate! diff --git a/test/unit/user_group_membership_test.rb b/test/unit/user_group_membership_test.rb index 251229f..34a577c 100644 --- a/test/unit/user_group_membership_test.rb +++ b/test/unit/user_group_membership_test.rb @@ -2,29 +2,29 @@ require 'test_helper' class UserGroupMembershipTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:user_group_membership).valid? + assert FactoryGirl.build(:user_group_membership).valid? end def test_should_have_unique_members_in_each_group - group1 = Factory.create(:user_group) - group2 = Factory.create(:user_group) - user1 = Factory.create(:user) - user2 = Factory.create(:user) - member = Factory.create( + group1 = FactoryGirl.create(:user_group) + group2 = FactoryGirl.create(:user_group) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) + member = FactoryGirl.create( :user_group_membership, :user_id => user1.id, :user_group_id => group1.id ) - assert !Factory.build( + assert !FactoryGirl.build( :user_group_membership, :user_id => user1.id, :user_group_id => group1.id ).valid? - assert Factory.build( + assert FactoryGirl.build( :user_group_membership, :user_id => user1.id, :user_group_id => group2.id ).valid? - assert Factory.build( + assert FactoryGirl.build( :user_group_membership, :user_id => user2.id, :user_group_id => group1.id @@ -32,7 +32,7 @@ class UserGroupMembershipTest < ActiveSupport::TestCase end def test_that_the_initial_state_should_be_active - @user_group_membership = Factory.create(:user_group_membership) + @user_group_membership = FactoryGirl.create(:user_group_membership) assert_equal 'active', @user_group_membership.state assert @user_group_membership.active? end diff --git a/test/unit/user_group_test.rb b/test/unit/user_group_test.rb index 5e815a8..1023bd6 100644 --- a/test/unit/user_group_test.rb +++ b/test/unit/user_group_test.rb @@ -2,23 +2,23 @@ require 'test_helper' class UserGroupTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:user_group).valid? + assert FactoryGirl.build(:user_group).valid? end def test_should_have_unique_name_on_same_tenant - tenant1 = Factory.create(:tenant) - tenant2 = Factory.create(:tenant) - group = Factory.create(:user_group, :tenant_id => tenant1.id) - assert !Factory.build(:user_group, :name => group.name, :tenant_id => tenant1.id).valid? - assert Factory.build(:user_group, :name => group.name, :tenant_id => tenant2.id).valid? - assert Factory.build(:user_group, :name => "different_#{group.name}", :tenant_id => tenant1.id).valid? + tenant1 = FactoryGirl.create(:tenant) + tenant2 = FactoryGirl.create(:tenant) + group = FactoryGirl.create(:user_group, :tenant_id => tenant1.id) + assert !FactoryGirl.build(:user_group, :name => group.name, :tenant_id => tenant1.id).valid? + assert FactoryGirl.build(:user_group, :name => group.name, :tenant_id => tenant2.id).valid? + assert FactoryGirl.build(:user_group, :name => "different_#{group.name}", :tenant_id => tenant1.id).valid? end test "user_group_membership only available for tenant_memberships" do - good_tenant = Factory.create(:tenant) - evil_tenant = Factory.create(:tenant) + good_tenant = FactoryGirl.create(:tenant) + evil_tenant = FactoryGirl.create(:tenant) - user = Factory.create(:user) + user = FactoryGirl.create(:user) good_tenant.tenant_memberships.create(:user_id => user.id) good_user_group = good_tenant.user_groups.create(:name => 'Example') diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index bb89e77..5fa1e4a 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -3,21 +3,21 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:user).valid? + assert FactoryGirl.build(:user).valid? end def test_should_have_a_unique_email_address - user = Factory.create(:user) - assert !Factory.build(:user, :email => user.email).valid? - assert Factory.build(:user, :email => "different_#{user.email}").valid? + user = FactoryGirl.create(:user) + assert !FactoryGirl.build(:user, :email => user.email).valid? + assert FactoryGirl.build(:user, :email => "different_#{user.email}").valid? end def test_can_not_move_to_a_current_tenant_without_a_membership_relation - super_tenant = Factory.create(:tenant) - good_tenant = Factory.create(:tenant) - evil_tenant = Factory.create(:tenant) + super_tenant = FactoryGirl.create(:tenant) + good_tenant = FactoryGirl.create(:tenant) + evil_tenant = FactoryGirl.create(:tenant) - user = Factory.create(:user) + user = FactoryGirl.create(:user) super_tenant.tenant_memberships.create(:user_id => user.id) good_tenant.tenant_memberships.create(:user_id => user.id) @@ -27,7 +27,7 @@ class UserTest < ActiveSupport::TestCase end test "should be possible to modify the user without changing the PIN" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) pin_salt = user.pin_salt pin_hash = user.pin_hash user.middle_name = "#{user.middle_name} Foo" @@ -39,7 +39,7 @@ class UserTest < ActiveSupport::TestCase end test "should be possible to change the PIN" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) pin_salt = user.pin_salt pin_hash = user.pin_hash new_pin = '453267' @@ -52,7 +52,7 @@ class UserTest < ActiveSupport::TestCase end test "should not be possible to change the PIN if the confirmation does not match" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) pin_salt = user.pin_salt pin_hash = user.pin_hash user.new_pin = '123001' @@ -67,7 +67,7 @@ class UserTest < ActiveSupport::TestCase end test "PIN must be numeric" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) new_pin = 'xxxx' user.new_pin = new_pin user.new_pin_confirmation = new_pin -- cgit v1.2.3 From 648f51a0ac97675d6cdf6a4b0c3c75bc9ea23168 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:04:51 +0100 Subject: Undo the last commit. --- Gemfile.lock | 113 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 696166f..f9a6596 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,95 +28,95 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_list (0.1.9) - addressable (2.3.2) + acts_as_list (0.1.5) + addressable (2.2.7) arel (3.0.2) bcrypt-ruby (3.0.1) - breadcrumbs_on_rails (2.3.0) - builder (3.0.4) - cancan (1.6.8) - carrierwave (0.7.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - chunky_png (1.2.6) + breadcrumbs_on_rails (2.2.0) + builder (3.0.0) + cancan (1.6.7) + carrierwave (0.5.8) + activesupport (~> 3.0) + chunky_png (1.2.5) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) - compass (0.12.2) + coffee-script-source (1.2.0) + compass (0.12.rc.1) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) + compass-rails (1.0.0.rc.3) + compass (~> 0.12.rc.0) cookiejar (0.3.0) - delayed_job (3.0.4) + delayed_job (3.0.1) activesupport (~> 3.0) - delayed_job_active_record (0.3.3) - activerecord (>= 2.1.0, < 4) - delayed_job (~> 3.0) - em-http-request (1.0.3) + delayed_job_active_record (0.3.2) + activerecord (> 2.1.0) + delayed_job (~> 3.0.0) + em-http-request (1.0.1) addressable (>= 2.2.3) cookiejar em-socksify eventmachine (>= 1.0.0.beta.4) http_parser.rb (>= 0.5.3) - em-socksify (0.2.1) - eventmachine (>= 1.0.0.beta.4) + em-socksify (0.1.0) + eventmachine erubis (2.7.0) - eventmachine (1.0.0) - execjs (1.4.0) + eventmachine (1.0.0.beta.4) + execjs (1.3.0) multi_json (~> 1.0) - factory_girl (4.1.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.1.0) - factory_girl (~> 4.1.0) + factory_girl (2.6.1) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) railties (>= 3.0.0) - faye (0.8.6) + faye (0.8.0) cookiejar (>= 0.3.0) em-http-request (>= 0.3.0) eventmachine (>= 0.12.0) faye-websocket (>= 0.4.0) rack (>= 1.0.0) yajl-ruby (>= 1.0.0) - faye-websocket (0.4.6) + faye-websocket (0.4.1) eventmachine (>= 0.12.0) - fssm (0.2.9) + fssm (0.2.8.1) haml (3.1.7) hike (1.2.1) - hirb (0.7.0) + hirb (0.6.1) http_accept_language (1.0.2) http_parser.rb (0.5.3) - i18n (0.6.1) - journey (1.0.4) - jquery-rails (2.1.4) - railties (>= 3.0, < 5.0) - thor (>= 0.14, < 2.0) - json (1.7.5) + i18n (0.6.0) + journey (1.0.3) + jquery-rails (2.0.1) + railties (>= 3.2.0, < 5.0) + thor (~> 0.14) + json (1.6.5) + libv8 (3.3.10.4) macaddr (1.6.1) systemu (~> 2.5.0) - mail (2.4.4) + mail (2.4.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.19) + mime-types (1.17.2) mini_magick (3.4) subexec (~> 0.2.1) - multi_json (1.5.0) + multi_json (1.1.0) mysql2 (0.3.11) - nokogiri (1.5.6) + nokogiri (1.5.5) polyglot (0.3.3) - private_pub (1.0.3) + private_pub (1.0.1) faye rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.2) + rack-test (0.6.1) rack (>= 1.0) rails (3.2.2) actionmailer (= 3.2.2) @@ -137,39 +137,38 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - rake (10.0.3) + rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - ref (1.0.2) ruby-graphviz (0.9.21) - sass (3.2.4) - sass-rails (3.2.5) + sass (3.1.15) + sass-rails (3.2.4) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - sprockets (2.1.3) + sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) + sqlite3 (1.3.5) state_machine (1.1.2) - subexec (0.2.2) - systemu (2.5.2) - therubyracer (0.11.0) - ref + subexec (0.2.1) + systemu (2.5.1) + therubyracer (0.9.10) + libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) - treetop (1.4.12) + treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.3.0) + tzinfo (0.3.32) + uglifier (1.2.3) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - uuid (2.3.6) + multi_json (>= 1.0.2) + uuid (2.3.5) macaddr (~> 1.0) will_paginate (3.0.3) yajl-ruby (1.1.0) -- cgit v1.2.3 From 9f14a9a6573db607b79124524088803812454515 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:15:58 +0100 Subject: Upgraded FactoryGirl gem --- Gemfile.lock | 105 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9336fe9..4e2ff46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,95 +28,95 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_list (0.1.9) - addressable (2.3.2) + acts_as_list (0.1.5) + addressable (2.2.7) arel (3.0.2) bcrypt-ruby (3.0.1) - breadcrumbs_on_rails (2.3.0) - builder (3.0.4) - cancan (1.6.8) - carrierwave (0.7.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - chunky_png (1.2.6) + breadcrumbs_on_rails (2.2.0) + builder (3.0.0) + cancan (1.6.7) + carrierwave (0.5.8) + activesupport (~> 3.0) + chunky_png (1.2.5) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) - compass (0.12.2) + coffee-script-source (1.2.0) + compass (0.12.rc.1) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) compass-rails (1.0.0.rc.3) compass (~> 0.12.rc.0) cookiejar (0.3.0) - delayed_job (3.0.4) + delayed_job (3.0.1) activesupport (~> 3.0) - delayed_job_active_record (0.3.3) - activerecord (>= 2.1.0, < 4) - delayed_job (~> 3.0) - em-http-request (1.0.3) + delayed_job_active_record (0.3.2) + activerecord (> 2.1.0) + delayed_job (~> 3.0.0) + em-http-request (1.0.1) addressable (>= 2.2.3) cookiejar em-socksify eventmachine (>= 1.0.0.beta.4) http_parser.rb (>= 0.5.3) - em-socksify (0.2.1) - eventmachine (>= 1.0.0.beta.4) + em-socksify (0.1.0) + eventmachine erubis (2.7.0) - eventmachine (1.0.0) - execjs (1.4.0) + eventmachine (1.0.0.beta.4) + execjs (1.3.0) multi_json (~> 1.0) - factory_girl (4.1.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.1.0) - factory_girl (~> 4.1.0) + factory_girl (2.6.4) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) railties (>= 3.0.0) - faye (0.8.6) + faye (0.8.0) cookiejar (>= 0.3.0) em-http-request (>= 0.3.0) eventmachine (>= 0.12.0) faye-websocket (>= 0.4.0) rack (>= 1.0.0) yajl-ruby (>= 1.0.0) - faye-websocket (0.4.6) + faye-websocket (0.4.1) eventmachine (>= 0.12.0) - fssm (0.2.9) + fssm (0.2.8.1) haml (3.1.7) hike (1.2.1) - hirb (0.7.0) + hirb (0.6.1) http_accept_language (1.0.2) http_parser.rb (0.5.3) i18n (0.6.1) - journey (1.0.4) - jquery-rails (2.1.4) - railties (>= 3.0, < 5.0) - thor (>= 0.14, < 2.0) - json (1.7.5) + journey (1.0.3) + jquery-rails (2.0.1) + railties (>= 3.2.0, < 5.0) + thor (~> 0.14) + json (1.6.5) + libv8 (3.3.10.4) macaddr (1.6.1) systemu (~> 2.5.0) - mail (2.4.4) + mail (2.4.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.19) + mime-types (1.17.2) mini_magick (3.4) subexec (~> 0.2.1) multi_json (1.5.0) mysql2 (0.3.11) - nokogiri (1.5.6) + nokogiri (1.5.5) polyglot (0.3.3) - private_pub (1.0.3) + private_pub (1.0.1) faye rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.2) + rack-test (0.6.1) rack (>= 1.0) rails (3.2.2) actionmailer (= 3.2.2) @@ -137,39 +137,38 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - rake (10.0.3) + rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - ref (1.0.2) ruby-graphviz (0.9.21) - sass (3.2.4) - sass-rails (3.2.5) + sass (3.1.15) + sass-rails (3.2.4) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - sprockets (2.1.3) + sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) + sqlite3 (1.3.5) state_machine (1.1.2) - subexec (0.2.2) - systemu (2.5.2) - therubyracer (0.11.0) - ref + subexec (0.2.1) + systemu (2.5.1) + therubyracer (0.9.10) + libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) - treetop (1.4.12) + treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.3.0) + tzinfo (0.3.32) + uglifier (1.2.3) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - uuid (2.3.6) + multi_json (>= 1.0.2) + uuid (2.3.5) macaddr (~> 1.0) will_paginate (3.0.3) yajl-ruby (1.1.0) -- cgit v1.2.3 From f5a512fe34fff50bcc7e96b57120d56a79ea47cb Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:25:52 +0100 Subject: Set a couple of :autofocus => true to make the UI better. --- app/views/call_forwards/_form_core.html.haml | 2 +- app/views/phone_numbers/_form_core.html.haml | 6 +++--- app/views/sip_accounts/_form_core.html.haml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/call_forwards/_form_core.html.haml b/app/views/call_forwards/_form_core.html.haml index 3dadb68..f75181f 100644 --- a/app/views/call_forwards/_form_core.html.haml +++ b/app/views/call_forwards/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs - = f.input :call_forward_case_id, :as => :select, :collection => @available_call_forward_cases.map {|x| [I18n.t("call_forward_cases.#{x.value}"), x.id] }, :label => t('call_forwards.form.call_forward_case_id.label'), :hint => conditional_hint('call_forwards.form.call_forward_case_id.hint'), :include_blank => false + = f.input :call_forward_case_id, :as => :select, :collection => @available_call_forward_cases.map {|x| [I18n.t("call_forward_cases.#{x.value}"), x.id] }, :label => t('call_forwards.form.call_forward_case_id.label'), :hint => conditional_hint('call_forwards.form.call_forward_case_id.hint'), :include_blank => false, :autofocus => true = f.input :timeout, :label => t('call_forwards.form.timeout.label'), :hint => conditional_hint('call_forwards.form.timeout.hint') = f.input :call_forwarding_destination , :as => :select, :collection => @call_forwarding_destinations, :label => t('call_forwards.form.call_forwarding_destination.label'), :hint => conditional_hint('call_forwards.form.call_forwarding_destination.hint'), :include_blank => false diff --git a/app/views/phone_numbers/_form_core.html.haml b/app/views/phone_numbers/_form_core.html.haml index add3039..a1ce1f3 100644 --- a/app/views/phone_numbers/_form_core.html.haml +++ b/app/views/phone_numbers/_form_core.html.haml @@ -2,9 +2,9 @@ - if @phone_book_entry = f.input :name, :collection => ['Office', 'Home', 'Mobile', 'Fax'], :include_blank => false, :label => t('phone_numbers.form.name.label'), :hint => conditional_hint('phone_numbers.form.name.hint') - = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint') + = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true - else - if @callthrough || @hunt_group_member || @access_authorization || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count == 0 || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count > 250 - = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint') + = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true - else - = f.input :number, :collection => @current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false + = f.input :number, :collection => @current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false, :autofocus => true diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index dbd27fe..6a63da6 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -1,7 +1,7 @@ .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') + = 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 = 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') -- cgit v1.2.3 From 12c8f4c82770ded6ea6b519e4451ed6757419ddf Mon Sep 17 00:00:00 2001 From: Sascha Daniels Date: Mon, 31 Dec 2012 02:09:05 +0100 Subject: Remove unused ontroller --- app/controllers/config_siemens_sort_controller.rb | 371 ---------------------- 1 file changed, 371 deletions(-) delete mode 100644 app/controllers/config_siemens_sort_controller.rb diff --git a/app/controllers/config_siemens_sort_controller.rb b/app/controllers/config_siemens_sort_controller.rb deleted file mode 100644 index c0739e5..0000000 --- a/app/controllers/config_siemens_sort_controller.rb +++ /dev/null @@ -1,371 +0,0 @@ -require 'nokogiri' -#doc.search('Message/ItemList').each do |a| puts a.children end -class ConfigSiemensController < ApplicationController -#TODO Authentication - # No access for admins though as this contains personal data. - - # We can't use load_and_authorize_resource() here because - # ConfigSiemensController isn't a resource. - # We can try client certificates - - skip_authorization_check - - - def index - os40_keys=7 - os60_keys=8 - os80_keys=9 - doc = Nokogiri::XML(request.body.read) - #logger.debug("#{params[:WorkpointMessage].to_xml}") - #logger.debug("#{params[:WorkpointMessage][:Message][:ItemList].to_xml}") - @phone_items=Hash.new - contact_reason = params[:WorkpointMessage][:Message][:ReasonForContact] - reply_status = doc.search('Message/ReasonForContact').first[:status] - reply_action = doc.search('Message/ReasonForContact').first[:action] - - doc.search('Message/ItemList/Item').each do |post_item| - @phone_items[post_item[:name]]=post_item.children.to_s - end - - mac_address = @phone_items['mac-addr'] - phone_type = @phone_items['device-type'] - if phone_type == "OpenStage 40" - max_keys = (os40_keys) * 2 - elsif phone_type == "OpenStage 60" - max_keys = (os60_keys) * 2 - elsif phone_type == "OpenStage 80" - max_keys = (os80_keys) * 2 - else - max_keys = 0 - end - - blf_keys_max = max_keys / 2 - shift_key_position = blf_keys_max - 1 - - #logger.debug(request.body.read) - @phone = Phone.find_by_mac_address(mac_address.gsub(':','').upcase) - if ! @phone.nil? - @phone.update_attributes(:ip_address => request.remote_ip) - sip_account = SipAccount.where(:sip_accountable_type == @phone.phoneable_type, - :sip_accountable_id == @phone.phoneable_id).first - end - - if ! @phone.nil? && ! sip_account.nil? - #logger.debug(@phone_items) - @my_nonce = params[:WorkpointMessage][:Message][:nonce] - @new_settings = Array.new - - @new_settings << ['dhcp', nil, 'true'] - @new_settings << ['hostname', nil, mac_address.gsub(':', '') ] - @new_settings << ['e164-hostname', nil, 'false'] - @new_settings << ['mobility-enabled', nil, 'false'] - @new_settings << ['mobility-password-on-logoff', nil, 'false'] - @new_settings << ['e164', nil, sip_account.try(:phone_numbers).first.number] - @new_settings << ['sip-user-id', nil, sip_account.auth_name] - @new_settings << ['reg-id', nil, sip_account.auth_name] - @new_settings << ['reg-number', nil, sip_account.auth_name] - @new_settings << ['fully-qualified-phone-no', nil, sip_account.auth_name] - @new_settings << ['sip-pwd', nil, sip_account.password] - @new_settings << ['sip-name', nil, sip_account.caller_name] - @new_settings << ['register-by-name', nil, 'false'] - #OPTIMIZE Display ID ? - @new_settings << ['display-id', nil, sip_account.try(:phone_numbers).first.number] - @new_settings << ['display-id-unicode', nil, sip_account.caller_name] - @new_settings << ['use-display-id', nil, 'true'] - @new_settings << ['reg-addr', nil, sip_account.sip_domain.host] - @new_settings << ['reg-port', nil, '5060'] - @new_settings << ['registrar-addr', nil, sip_account.sip_domain.host] - @new_settings << ['registrar-port', nil, '5060'] - @new_settings << ['outbound-proxy', nil, sip_account.sip_domain.host] - @new_settings << ['outbound-proxy-user', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-addr', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-addr-user', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-port', nil, '5060' ] - @new_settings << ['sgnl-gateway-port-user', nil, '5060'] - @new_settings << ['sgnl-route', nil, '0' ] - @new_settings << ['mwi-e164', nil, '' ] - @new_settings << ['rtp-base-port', nil, '5004'] - @new_settings << ['default-domain', nil, '' ] - @new_settings << ['sip-transport', nil, '0' ] - @new_settings << ['sip-transport-user', nil, '0' ] - @new_settings << ['server-type', nil, '0' ] - @new_settings << ['session-timer', nil, 'true'] - @new_settings << ['session-duration', nil, '3600' ] - @new_settings << ['reg-ttl', nil, '3600' ] - @new_settings << ['realm', nil, sip_account.sip_domain.realm] - @new_settings << ['emergency-e164', nil, '0110' ] - @new_settings << ['voice-mail-e164', nil, 'voicemail'] - @new_settings << ['auto-answer', nil, 'false'] - @new_settings << ['beep-on-auto-answer', nil, 'true'] - @new_settings << ['auto-reconnect', nil, 'false' ] - @new_settings << ['beep-on-auto-reconnect', nil, 'true'] - @new_settings << ['permit-decline-call', nil, 'true'] - @new_settings << ['transfer-on-ring', nil, 'false' ] - @new_settings << ['join-allowed-in-conference', nil, 'true'] - @new_settings << ['pickup-group-uri', nil, '*8*'] - @new_settings << ['pickup-group-uri', nil, '' ] - @new_settings << ['hot-line-warm-line-digits', nil, '' ] - @new_settings << ['initial-digit-timer', nil, '30' ] - @new_settings << ['conference-factory-uri', nil, ''] - @new_settings << ['callback-busy-allow', nil, 'false'] - @new_settings << ['callback-busy-code', nil, '' ] - @new_settings << ['callback-ring-allow', nil, 'false'] - @new_settings << ['callback-ring-code', nil, ''] - @new_settings << ['callback-cancel-code', nil, ''] - @new_settings << ['park-server', nil, ''] - #OPTIMIZE Callwaiting - @new_settings << ['call-waiting-enabled', nil, 'true'] - @new_settings << ['qos-layer2', nil, 'true'] - @new_settings << ['l2qos-voice', nil, '5' ] - @new_settings << ['l2qos-signalling', nil, '3' ] - @new_settings << ['l2qos-default', nil, '0'] - @new_settings << ['qos-layer3', nil, 'true'] - @new_settings << ['l3qos-voice', nil, '46'] - @new_settings << ['l3qos-signalling', nil, '26'] - @new_settings << ['vlan-method', nil, '1'] - #OPTIMIZE Timezone - @new_settings << ['sntp-tz-offset', nil, ''] - @new_settings << ['daylight-save', nil, ''] - @new_settings << ['daylight-save-minutes', nil, ''] - #OPTIMIZE Use SNMP? - @new_settings << ['snmp-trap-addr', nil, ''] - @new_settings << ['snmp-trap-port', nil, ''] - @new_settings << ['snmp-trap-pwd', nil, 'snmp' ] - @new_settings << ['snmp-traps-active', nil, 'false' ] - @new_settings << ['diagnostic-trap-addr', nil, ''] - @new_settings << ['diagnostic-trap-port', nil, ''] - @new_settings << ['diagnostic-trap-pwd', nil, 'snmp' ] - @new_settings << ['diagnostic-traps-active', nil, 'false' ] - @new_settings << ['diagnostic-snmp-active', nil, 'false'] - @new_settings << ['qdc-collection-unit-addr', nil, ''] - @new_settings << ['qdc-collection-unit-port', nil, '12010'] - - @new_settings << ['qdc-trap-pwd', nil, 'QOSDC'] - @new_settings << ['qdc-snmp-active', nil, 'false'] - @new_settings << ['qdc-qcu-active', nil, 'false'] - @new_settings << ['snmp-queries-allowed', nil, 'false'] - @new_settings << ['snmp-pwd', nil, ''] - @new_settings << ['disable-microphone', nil, 'false'] - @new_settings << ['loudspeech-enabled', nil, 'true'] - @new_settings << ['audio-silence-suppression', nil, 'false'] - - @new_settings << ['port1', nil, '0' ] # 0=Automatic (speed) - @new_settings << ['port2', nil, '0' ] - @new_settings << ['port2-mode', nil, '1' ] - @new_settings << ['port2-auto-mdix-enabled', nil, 'true' ] - @new_settings << ['originating-line-preference', nil, '0'] - @new_settings << ['terminating-line-preference', nil, '0'] - @new_settings << ['line-key-operating-mode', nil, '0'] - @new_settings << ['line-rollover-type', nil, '2'] - @new_settings << ['line-rollover-volume', nil, '5' ]# 1-5 - @new_settings << ['line-registration-leds', nil, 'true'] - @new_settings << ['keyset-use-focus', nil, 'true' ] - @new_settings << ['keyset-remote-forward-ind', nil, 'true'] - @new_settings << ['keyset-reservation-timer', nil, '60' ] # 0-300 - @new_settings << ['dial-plan-enabled', nil, '' ] - @new_settings << ['Canonical-dialing-international-prefix', nil, ''] - @new_settings << ['Canonical-dialing-local-country-code', nil, ''] - @new_settings << ['Canonical-dialing-national-prefix', nil, ''] - @new_settings << ['Canonical-dialing-local-area-code', nil, ''] - @new_settings << ['Canonical-dialing-local-node', nil, ''] - @new_settings << ['Canonical-dialing-external-access', nil, '0'] - @new_settings << ['Canonical-dialing-operator-code', nil, ''] - @new_settings << ['Canonical-dialing-emergency-number', nil, ''] - @new_settings << ['Canonical-dialing-dial-needs-access-code', nil, '0'] - @new_settings << ['Canonical-dialing-dial-needs-intGWcode', nil, '0'] - @new_settings << ['Canonical-dialing-min-local-number-length', nil, '10'] - @new_settings << ['Canonical-dialing-extension-initial-digits', nil, ''] - @new_settings << ['Canonical-dialing-dial-internal-form', nil, '0' ] - @new_settings << ['Canonical-dialing-dial-external-form', nil, '0' ] - @new_settings << ['Canonical-lookup-local-code', nil, '' ] - @new_settings << ['Canonical-lookup-international-code', nil, ''] - @new_settings << ['hot-keypad-dialing', nil, ''] - @new_settings << ['ldap-transport', nil, '0'] - @new_settings << ['ldap-server-address', nil, '' ] - @new_settings << ['ldap-server-port', nil, '389' ] - @new_settings << ['ldap-authentication', nil, '1'] - @new_settings << ['ldap-user', nil, '' ] - @new_settings << ['ldap-pwd', nil, '' ] - @new_settings << ['ldap-max-responses', nil, '25'] - @new_settings << ['backup-addr', nil, ''] - @new_settings << ['backup-registration', nil, 'false'] - @new_settings << ['qdc-qcu-active', nil, 'false' ] - @new_settings << ['min-admin-passw-length', nil, '6' ] - @new_settings << ['default-locked-config-menus', nil, 'true' ] - @new_settings << ['locked-config-menus', nil, 'true' ] - @new_settings << ['default-locked-local-function-menus', nil, 'true' ] - @new_settings << ['locked-local-function-menus', nil, 'true' ] - @new_settings << ['dls-mode-secure', nil, '0' ] - @new_settings << ['dls-chunk-size', nil, '9492'] - @new_settings << ['default-passw-policy', nil, 'false'] - @new_settings << ['deflect-destination', nil, ''] - @new_settings << ['display-skin', nil, ''] - @new_settings << ['enable-bluetooth-interface', nil, 'true'] - @new_settings << ['usb-access-enabled', nil, 'false' ] - @new_settings << ['usb-backup-enabled', nil, 'false' ] - @new_settings << ['line-button-mode', nil, '0' ] - @new_settings << ['lock-forwarding', nil, '' ] - @new_settings << ['loudspeaker-function-mode', nil, '0' ] - @new_settings << ['max-pin-retries', nil, '' ] - @new_settings << ['inactivity-timeout', nil, '30' ] - @new_settings << ['not-used-timeout', nil, '2' ] - @new_settings << ['passw-char-set', nil, '0' ] - @new_settings << ['refuse-call', nil, 'true' ] - @new_settings << ['restart-password', nil, ''] - #OPTIMIZE clock format - @new_settings << ['time-format', nil, '0' ]# 1=12 h - @new_settings << ['uaCSTA-enabled', nil, 'false' ] - @new_settings << ['enable-test-interface', nil, 'false'] - @new_settings << ['enable-WBM', nil, 'true'] - @new_settings << ['pixelsaver-timeout', nil, '2' ]# 2 hours? - @new_settings << ['voice-message-dial-tone', nil, '' ] - @new_settings << ['call-pickup-allowed', nil, 'true' ] - @new_settings << ['group-pickup-tone-allowed', nil, 'true'] - @new_settings << ['group-pickup-as-ringer', nil, 'false'] - @new_settings << ['group-pickup-alert-type', nil, '0' ] - @new_settings << ['default-profile', nil, '' ] - @new_settings << ['count-medium-priority', nil, '5'] - @new_settings << ['timer-medium-priority', nil, '60'] # 1 - 999 - @new_settings << ['timer-high-priority', nil, '5'] # 0 - 999 - @new_settings << ['dss-sip-detect-timer', nil, '10'] - @new_settings << ['dss-sip-deflect', nil, 'false' ] - @new_settings << ['dss-sip-refuse', nil, 'false' ] - @new_settings << ['feature-availability', nil, 'false'] - @new_settings << ['feature-availability', nil, 'true' ] - @new_settings << ['feature-availability', nil, 'true' ] - @new_settings << ['local-control-feature-availability', nil, 'false' ] - @new_settings << ['trace-level', nil, '0' ] # Off - @new_settings << ['default-locked-function-keys', nil, 'true' ]# "unknown item" - #OPTIMIZE Put pickup prefix into database/global constant? - @new_settings << ['blf-code', nil, 'f_ia_'] # pickup prefix for softkey function 59 (BLF) - @new_settings << ['stimulus-feature-code', nil, true] - @new_settings << ['stimulus-led-control-uri', nil, true] - - - @new_settings << ['min-user-passw-length', nil, '6' ]# 6 - 24 - #OPTIMIZE language - @new_settings << ['country-iso', nil, 'DE' ] - @new_settings << ['language-iso', nil, 'de'] - @new_settings << ['date-format', nil, '0' ] # DD.MM.YYYY - #OPTIMIZE ringtones - @new_settings << ['ringer-melody', nil, '1'] - - @new_settings << ['ringer-melody', nil, '2'] - @new_settings << ['ringer-tone-sequence', nil, '2'] - - soft_keys = Array.new - # Getting BLF keys only for the first level - blf_keys = sip_account.softkeys.find( - :all, - :conditions => {:function => ['blf', 'conference']}, - :limit => blf_keys_max) - #Getting other keys - non_blf_keys = sip_account.softkeys.find( - :all, - :conditions => {:function => ['speed_dial']}) - - # Fill softkey array with BLF keys up to shift key - blf_keys.each do |k| - soft_keys << k - end - # Fill sofkey with other keys up to end - non_blf_keys.each do |k| - if soft_keys.length < max_keys - soft_keys << k - end - end - # Delete unset softkeys - while soft_keys.length < max_keys - soft_keys << Softkey.new - end - - key_pos=1 - - #soft_keys.each do |sk| - - while key_pos < shift_key_position - - (1..shift_key_position-1).each do |key_idx| - sk = soft_keys.shift - logger.debug(sk.function, key_idx) - if sk.function == "blf" - @new_settings << ['function-key-def', key_idx, '59'] - @new_settings << ['select-dial', key_idx, sk.number ] - elsif sk.function == "log_out" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, 'f_lo' ] - elsif sk.function == "log_in" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, "f_li_#{sk.number}" ] - elsif sk.function == "dtmf" - @new_settings << ['function-key-def', key_idx, '54'] - @new_settings << ['stimulus-DTMF-sequence', key_idx, sk.number ] - elsif sk.function.nil? - @new_settings << ['function-key-def', key_idx, '0'] - else - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, sk.number ] - end - @new_settings << ['key-label', key_idx, sk.label ] - @new_settings << ['key-label-unicode', key_idx, sk.label ] - key_pos = key_pos+1 - - end - end - if key_pos == shift_key_position - @new_settings << ['function-key-def', shift_key_position, '18'] - @new_settings << ['key-label', shift_key_position, 'Shift'] - @new_settings << ['key-label-unicode', shift_key_position, 'Shift'] - key_pos = key_pos+1 - end - - (1001..1000+shift_key_position-1).each do |key_idx| - sk = soft_keys.shift - if sk.function == "log_out" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, 'f_lo' ] - elsif sk.function == "log_in" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, "f_li_#{sk.number}" ] - elsif sk.function == "dtmf" - @new_settings << ['function-key-def', key_idx, '54'] - @new_settings << ['stimulus-DTMF-sequence', key_idx, sk.number ] - elsif sk.function.nil? - @new_settings << ['function-key-def', key_idx, '0'] - else - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, sk.number ] - end - @new_settings << ['key-label', key_idx, sk.label ] - @new_settings << ['key-label-unicode', key_idx, sk.label ] - key_pos = key_pos+1 - - end - - #end - logger.debug(@new_settings) - end - - if @phone.nil? || sip_account.nil? - respond_to { |format| - format.xml { render :action => "clean-up" } - } - - elsif (reply_status == 'accepted' && contact_reason == 'reply-to' && reply_action == 'ReadAllItems') - respond_to { |format| - format.xml { render :action => "write" } - } - - elsif ["reply-to"].include? contact_reason - respond_to { |format| - format.xml { render :action => "clean-up" } - } - - else - respond_to { |format| - format.xml { render :action => "index" } - } - end - - end -end -- cgit v1.2.3 From c24bd3a8212e85894b2f7c26e190fe5e89fbaaf2 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 31 Dec 2012 08:47:23 +0100 Subject: hide hotdeskable check box for tenant sip accounts --- app/views/sip_accounts/_form_core.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index dbd27fe..bb70edb 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -6,7 +6,8 @@ = 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') = f.input :clip, :label => t('sip_accounts.form.clip.label'), :hint => conditional_hint('sip_accounts.form.clip.hint') - = f.input :hotdeskable, :label => t('sip_accounts.form.hotdeskable.label'), :hint => conditional_hint('sip_accounts.form.hotdeskable.hint') + - if @sip_account.sip_accountable_type == 'User' + = f.input :hotdeskable, :label => t('sip_accounts.form.hotdeskable.label'), :hint => conditional_hint('sip_accounts.form.hotdeskable.hint') = f.input :clip_no_screening, :label => t('sip_accounts.form.clip_no_screening.label'), :hint => conditional_hint('sip_accounts.form.clip_no_screening.hint') - if CallForward.where(:phone_number_id => @sip_account.phone_number_ids).count == 0 || @sip_account.callforward_rules_act_per_sip_account == true = f.input :callforward_rules_act_per_sip_account, :label => t('sip_accounts.form.callforward_rules_act_per_sip_account.label'), :hint => conditional_hint('sip_accounts.form.callforward_rules_act_per_sip_account.hint') -- cgit v1.2.3 From a3bf87ed7d6d693c28d081c2e7e8d8e55373cae4 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 31 Dec 2012 09:31:43 +0100 Subject: show hot deskable option for user sip accounts only --- app/controllers/sip_accounts_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 1f3166e..8292a74 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -20,7 +20,9 @@ class SipAccountsController < ApplicationController @sip_account.clip = DEFAULT_CLIP_SETTING @sip_account.voicemail_pin = random_pin @sip_account.callforward_rules_act_per_sip_account = CALLFORWARD_RULES_ACT_PER_SIP_ACCOUNT_DEFAULT - @sip_account.hotdeskable = true + if @parent.class == User + @sip_account.hotdeskable = true + end # Make sure that we don't use an already taken auth_name # -- cgit v1.2.3 From e29f14a7742e7fd049a7a09a6d1fa046c2741d67 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 31 Dec 2012 09:32:41 +0100 Subject: fixed fallback_sip_accounts query --- app/controllers/phones_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index 2698465..14735e6 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -78,11 +78,11 @@ class PhonesController < ApplicationController end def set_fallback_sip_accounts - used_sip_account_ids = Phone.where(:fallback_sip_account_id => SipAccount.pluck(:id)).pluck(:fallback_sip_account_id) - @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant').where(:hotdeskable => true) - SipAccount.where(:id => used_sip_account_ids) - if @phone && !@phone.fallback_sip_account_id.blank? && SipAccount.exists?(@phone.fallback_sip_account_id) - @fallback_sip_accounts << SipAccount.where(:id => @phone.fallback_sip_account_id).first + used_sip_account_ids = Phone.pluck(:fallback_sip_account_id) + PhoneSipAccount.pluck(:sip_account_id) + if @phone + used_sip_account_ids = used_sip_account_ids - [ @phone.fallback_sip_account_id ] end + @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant') - SipAccount.where(:id => used_sip_account_ids) end end -- cgit v1.2.3 From 79a1a0013c9dfb8701c06221ab99c604eb2fd211 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 2 Jan 2013 08:28:30 +0100 Subject: Changed defaults and added some basic docu. --- misc/freeswitch/scripts/ini/dialplan.ini | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/ini/dialplan.ini b/misc/freeswitch/scripts/ini/dialplan.ini index aab8353..2e8914a 100644 --- a/misc/freeswitch/scripts/ini/dialplan.ini +++ b/misc/freeswitch/scripts/ini/dialplan.ini @@ -10,5 +10,11 @@ ringtone_url = http://192.168.0.150 ringback = %(2000,4000,440.0,480.0) tone_busy = %(500,500,480,620);loops=4 +; This one activates the lookup of phone numbers in +; the stored phone books. For incoming calls. phonebook_number_lookup = true -geo_number_lookup = true \ No newline at end of file + +; This one activates adding the Cityname for incoming +; phone calls from Germany which are not in any +; phone book. +geo_number_lookup = false \ No newline at end of file -- cgit v1.2.3 From 16e326c0b62cd319b48c6a6201127857de019585 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 3 Jan 2013 12:29:00 +0100 Subject: comment --- misc/freeswitch/scripts/ini/dialplan.ini | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/misc/freeswitch/scripts/ini/dialplan.ini b/misc/freeswitch/scripts/ini/dialplan.ini index 2e8914a..e081055 100644 --- a/misc/freeswitch/scripts/ini/dialplan.ini +++ b/misc/freeswitch/scripts/ini/dialplan.ini @@ -11,10 +11,9 @@ ringback = %(2000,4000,440.0,480.0) tone_busy = %(500,500,480,620);loops=4 ; This one activates the lookup of phone numbers in -; the stored phone books. For incoming calls. +; the stored phone books. phonebook_number_lookup = true -; This one activates adding the Cityname for incoming -; phone calls from Germany which are not in any -; phone book. -geo_number_lookup = false \ No newline at end of file +; This option controls city, country or operator number lookup for +; all numbers not resolved by "phonebook_number_lookup" +geo_number_lookup = false -- cgit v1.2.3 From a65c4ec370b60a4739e0b87ba398e5e25e3b1340 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 4 Jan 2013 09:12:58 +0100 Subject: return true if login was successful but phone resync failed --- app/models/phone.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/phone.rb b/app/models/phone.rb index a606834..a59b003 100644 --- a/app/models/phone.rb +++ b/app/models/phone.rb @@ -162,7 +162,6 @@ class Phone < ActiveRecord::Base if ! self.resync(true, sip_account_resync) errors.add(:resync, "Resync failed") - return false end return true -- cgit v1.2.3 From 5867df0eff12622c826cf0d699d3c2ec4aff5a7d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 4 Jan 2013 10:01:48 +0100 Subject: Set :autofocus => true for the first_name. --- app/views/phone_book_entries/_form_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/phone_book_entries/_form_core.html.haml b/app/views/phone_book_entries/_form_core.html.haml index c05139e..5159668 100644 --- a/app/views/phone_book_entries/_form_core.html.haml +++ b/app/views/phone_book_entries/_form_core.html.haml @@ -1,6 +1,6 @@ .inputs = f.input :is_male, :collection => [[true, t('phone_book_entries.form.gender.male')], [false, t('phone_book_entries.form.gender.female')]], :label_method => :last, :value_method => :first, :label => t('phone_book_entries.form.male.label'), :hint => conditional_hint('phone_book_entries.form.gender.hint'), :label => t('phone_book_entries.form.gender.label'), :as => :radio - = f.input :first_name, :label => t('phone_book_entries.form.first_name.label'), :hint => conditional_hint('phone_book_entries.form.first_name.hint') + = f.input :first_name, :label => t('phone_book_entries.form.first_name.label'), :hint => conditional_hint('phone_book_entries.form.first_name.hint'), :autofocus => true = f.input :middle_name, :label => t('phone_book_entries.form.middle_name.label'), :hint => conditional_hint('phone_book_entries.form.middle_name.hint') = f.input :last_name, :label => t('phone_book_entries.form.last_name.label'), :hint => conditional_hint('phone_book_entries.form.last_name.hint') = f.input :birth_name, :label => t('phone_book_entries.form.birth_name.label'), :hint => conditional_hint('phone_book_entries.form.birth_name.hint') -- cgit v1.2.3 From 7171f3ecfb8af4f9fcc30bcd168159d05ec4ae7f Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 4 Jan 2013 10:23:47 +0100 Subject: snom idle icon settings --- app/controllers/config_snom_controller.rb | 5 +++++ app/views/config_snom/show.xml.haml | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 7542415..9a06a99 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -503,6 +503,11 @@ class ConfigSnomController < ApplicationController :idle_down => "keyevent F_NEXT_ID", :idle_left => "url #{xml_applications_url}/call_history.xml?type=received", :idle_right => "url #{xml_applications_url}/call_history.xml?type=missed", + :touch_idle_adr_book => "url #{xml_applications_url}/phone_book.xml", + :touch_idle_list_missed => "url #{xml_applications_url}/call_history.xml?type=missed", + :touch_idle_list_taken => "url #{xml_applications_url}/call_history.xml?type=received", + :touch_idle_redial => "url #{xml_applications_url}/call_history.xml?type=dialed", + :touch_idle_dialog => "url #{xml_applications_url}/call_history.xml", } # Remap conference key to first conference if found diff --git a/app/views/config_snom/show.xml.haml b/app/views/config_snom/show.xml.haml index d9953c5..a11715d 100644 --- a/app/views/config_snom/show.xml.haml +++ b/app/views/config_snom/show.xml.haml @@ -68,6 +68,11 @@ %dkey_conf{:perm => 'RW'}= @dkeys[:conf] %dkey_redial{:perm => 'RW'}= @dkeys[:redial] %dkey_directory{:perm => 'RW'}= @dkeys[:directory] + %dkey_touch_idle_adr_book{:perm => 'RW'}= @dkeys[:touch_idle_adr_book] + %dkey_touch_idle_list_missed{:perm => 'RW'}= @dkeys[:touch_idle_list_missed] + %dkey_touch_idle_list_taken{:perm => 'RW'}= @dkeys[:touch_idle_list_taken] + %dkey_touch_idle_redial{:perm => 'RW'}= @dkeys[:touch_idle_redial] + %dkey_touch_idle_dialog{:perm => 'RW'}= @dkeys[:touch_idle_dialog] %idle_ok_key_action{:perm => 'RW'}= @dkeys[:idle_ok] %idle_cancel_key_action{:perm => 'RW'}= @dkeys[:idle_cancel] @@ -76,6 +81,29 @@ %idle_left_key_action{:perm => 'RW'}= @dkeys[:idle_left] %idle_right_key_action{:perm => 'RW'}= @dkeys[:idle_right] + / Display + %backlight{:perm => 'RW'}= '15' + %backlight_idle{:perm => 'RW'}= '0' + %dim_timer{:perm => 'RW'}= '300' + + - if @phone.phone_model.name == 'Snom 870' + / Snom 870 idle icons + %idle_icon_01{:perm => 'RW'}= '9' + %idle_icon_02{:perm => 'RW'}= '20' + %idle_icon_03{:perm => 'RW'}= '4' + %idle_icon_04{:perm => 'RW'}= '-1' + %idle_icon_05{:perm => 'RW'}= '6' + %idle_icon_06{:perm => 'RW'}= '-1' + %idle_icon_07{:perm => 'RW'}= '-1' + %idle_icon_08{:perm => 'RW'}= '-1' + %idle_icon_09{:perm => 'RW'}= '-1' + %idle_icon_10{:perm => 'RW'}= '-1' + %idle_icon_11{:perm => 'RW'}= '15' + %idle_icon_12{:perm => 'RW'}= '-1' + %idle_icon_13{:perm => 'RW'}= '-1' + %idle_icon_14{:perm => 'RW'}= '13' + %idle_icon_15{:perm => 'RW'}= '12' + != "\ - @@ -654,12 +624,8 @@ - - - - @@ -668,62 +634,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + -- cgit v1.2.3 From ce44ece18e64dc0bccee4cab680b965a38c0522d Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 12 Jan 2013 09:07:50 +0100 Subject: dialplan variables set --- db/migrate/20130112073300_set_dialplan_variables.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20130112073300_set_dialplan_variables.rb diff --git a/db/migrate/20130112073300_set_dialplan_variables.rb b/db/migrate/20130112073300_set_dialplan_variables.rb new file mode 100644 index 0000000..3d538c0 --- /dev/null +++ b/db/migrate/20130112073300_set_dialplan_variables.rb @@ -0,0 +1,11 @@ +class SetDialplanVariables < ActiveRecord::Migration + def up + GsParameter.create(:entity => 'dialplan', :section => 'variables', :name => 'ringback', :value => '%(2000,4000,440.0,480.0)', :class_type => 'String') + GsParameter.create(:entity => 'dialplan', :section => 'variables', :name => 'send_silence_when_idle', :value => 0, :class_type => 'Integer') + GsParameter.create(:entity => 'dialplan', :section => 'variables', :name => 'hold_music', :value => 'local_stream://moh', :class_type => 'String') + end + + def down + GsParameter.where(:entity => 'dialplan', :section => 'variables').destroy_all + end +end -- cgit v1.2.3 From 0b9e91fd4654ac5c73072f9e77025abc3060c0c0 Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 12 Jan 2013 09:08:06 +0100 Subject: ringback parameter removed --- db/migrate/20130112074800_remove_ringback_dialplan_parameter.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20130112074800_remove_ringback_dialplan_parameter.rb diff --git a/db/migrate/20130112074800_remove_ringback_dialplan_parameter.rb b/db/migrate/20130112074800_remove_ringback_dialplan_parameter.rb new file mode 100644 index 0000000..90b793d --- /dev/null +++ b/db/migrate/20130112074800_remove_ringback_dialplan_parameter.rb @@ -0,0 +1,9 @@ +class RemoveRingbackDialplanParameter < ActiveRecord::Migration + def up + GsParameter.where(:entity => 'dialplan', :section => 'parameters', :name => 'ringback').destroy_all + end + + def down + GsParameter.create(:entity => 'dialplan', :section => 'parameters', :name => 'ringback', :value => '%(2000,4000,440.0,480.0)', :class_type => 'String') + end +end -- cgit v1.2.3 From d8287a7dbcc287791ed069cfc14ca6b9db0e66a7 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 12 Jan 2013 10:28:49 +0100 Subject: Fixed a logic if/else bug. --- config/database.yml | 42 +++++++++++++++++++----------------------- db/schema.rb | 2 +- 2 files changed, 20 insertions(+), 24 deletions(-) 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/schema.rb b/db/schema.rb index bc7693b..cc5afcc 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 => 20130112074800) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" -- cgit v1.2.3 From 2e3bddd415f03aa15cd2759d7c18f64d5545ea80 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 12 Jan 2013 10:53:20 +0100 Subject: Accept truncated MAC addresses. #80 --- app/controllers/phones_controller.rb | 1 + app/models/phone.rb | 4 ++++ 2 files changed, 5 insertions(+) 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..4865a12 100644 --- a/app/models/phone.rb +++ b/app/models/phone.rb @@ -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 -- cgit v1.2.3 From ec342d3d91d2cfa8c210722354353cfe8a90a8bc Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 12 Jan 2013 11:53:21 +0100 Subject: Add PROVISIONING_KEY_LENGTH as a GsParameter value. #73 --- app/controllers/config_snom_controller.rb | 4 ++-- app/views/phones/_form_core.html.haml | 2 +- app/views/phones/show.html.haml | 2 +- .../20130112103337_set_new_value_for_provisioning_key_length.rb | 9 +++++++++ db/schema.rb | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb 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/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/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 cc5afcc..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 => 20130112074800) do +ActiveRecord::Schema.define(:version => 20130112103337) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" -- cgit v1.2.3 From 1e5c4e80fe27eddf87d0e01ea771e8ea050bc4c1 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 12 Jan 2013 21:37:55 +0100 Subject: Fixed a caching bug. #95 --- app/views/tenants/_sip_accounts_and_phones.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml index 9059126..ed5599f 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -8,7 +8,7 @@ %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 + - cache([I18n.locale, tenant, 'sip_accounts', 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') @@ -19,7 +19,7 @@ =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} + = 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') @@ -40,7 +40,7 @@ %tr{:class => 'even'} %td= t("phones.index.page_title") - - cache([I18n.locale, tenant, tenant.phones.count, tenant.phones.order(:updated_at).last]) do + - cache([I18n.locale, tenant, 'phones', 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') -- cgit v1.2.3 From 45ab6dc23ef7d8d6ddf60ab355c2d1b3450f35c8 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 12 Jan 2013 22:54:59 +0100 Subject: Cache fixes. --- app/models/phone.rb | 2 +- app/models/phone_model.rb | 2 +- app/models/sip_account.rb | 2 +- app/views/tenants/_admin_area.de.html.haml | 3 +- app/views/tenants/_admin_area.html.haml | 2 +- .../tenants/_sip_accounts_and_phones.html.haml | 117 ++++++++++----------- app/views/tenants/_table_of_functions.html.haml | 2 +- app/views/tenants/_table_of_phone_books.html.haml | 2 +- 8 files changed, 65 insertions(+), 67 deletions(-) diff --git a/app/models/phone.rb b/app/models/phone.rb index 4865a12..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 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/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 ed5599f..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, 'sip_accounts', 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, 'phones', 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) -- cgit v1.2.3 From 9567f239586f253002dea0ed654b7bd18a15e572 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 12 Jan 2013 23:05:51 +0100 Subject: Added the URLs for some GsParameters. #96 --- app/controllers/gemeinschaft_setups_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) 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 -- cgit v1.2.3 From 9012171763a7f1155e39bfb7f39fea34d437feef Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 13 Jan 2013 17:22:00 +0100 Subject: gateway class added --- misc/freeswitch/scripts/common/gateway.lua | 122 +++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 misc/freeswitch/scripts/common/gateway.lua diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua new file mode 100644 index 0000000..2c50c0f --- /dev/null +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -0,0 +1,122 @@ +-- Gemeinschaft 5 module: gateway class +-- (c) AMOOMA GmbH 2013 +-- + +module(...,package.seeall) + +Gateway = {} + +-- Create Gateway object +function Gateway.new(self, arg) + arg = arg or {} + object = arg.object or {} + setmetatable(object, self); + self.__index = self; + self.class = 'gateway'; + self.log = arg.log; + self.database = arg.database; + self.record = arg.record; + return object; +end + + +function Gateway.list(self, technology) + technology = technology or 'sip'; + local sql_query = 'SELECT * FROM `gateways` WHERE (`outbound` IS TRUE OR `inbound` IS TRUE) AND `technology` = "' .. technology .. '"'; + local gateways = {}; + self.database:query(sql_query, function(entry) + table.insert(gateways, entry); + end) + + return gateways; +end + + +function Gateway.find_by_sql(self, where) + local sql_query = 'SELECT * FROM `gateways` WHERE ' .. where .. ' LIMIT 1'; + + local gateway = nil; + self.database:query(sql_query, function(entry) + gateway = Gateway:new(self); + gateway.record = entry; + gateway.id = tonumber(entry.id); + gateway.uuid = entry.uuid; + end) + + return gateway; +end + + +-- find gateway by id +function Gateway.find_by_id(self, id) + local sql_query = '`id`= ' .. tonumber(id); + return self:find_by_sql(sql_query); +end + +-- find gateway name +function Gateway.find_by_name(self, name) + local sql_query = '`name`= "' .. name .. '"'; + + return self:find_by_sql(sql_query); +end + + +function Gateway.profile_get(self, gateway_id) + local sql_query = 'SELECT `value` FROM `gateway_settings` WHERE `gateway_id` = ' .. tonumber(gateway_id) .. ' AND `name` = "profile" LIMIT 1'; + + return self.database:query_return_value(sql_query); +end + + +function Gateway.config_table_get(self, config_table, gateway_id) + require 'common.str' + + local sql_query = 'SELECT * FROM `'.. config_table ..'` WHERE `gateway_id` = ' .. tonumber(gateway_id); + + local settings = {}; + self.database:query(sql_query, function(entry) + local p_class_type = common.str.strip(entry.class_type):lower(); + local p_name = common.str.strip(entry.name):lower(); + + if p_class_type == 'boolean' then + settings[p_name] = common.str.to_b(entry.value); + elseif p_class_type == 'integer' then + settings[p_name] = common.str.to_i(entry.value); + else + settings[p_name] = tostring(entry.value); + end + end) + + return settings +end + + +function Gateway.parameters_build(self, gateway_id) + local settings = self:config_table_get('gateway_settings', gateway_id); + local parameters = { + realm = settings.domain, + extension = 'auto_to_user', + }; + + require 'common.str' + + if common.str.blank(settings.username) then + parameters.username = 'gateway' .. gateway_id; + parameters.register = false; + else + parameters.username = settings.username; + parameters.register = true; + end + + if common.str.blank(settings.password) then + parameters.password = 'gateway' .. gateway_id; + else + parameters.password = settings.password; + end + + for key, value in pairs(self:config_table_get('gateway_parameters', gateway_id)) do + parameters[key] = value; + end + + return parameters; +end -- cgit v1.2.3 From 0d5114566e73c44799eac83d46f159cd979f4fcc Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 13 Jan 2013 17:23:37 +0100 Subject: read gateway configuration from database --- misc/freeswitch/scripts/configuration.lua | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/misc/freeswitch/scripts/configuration.lua b/misc/freeswitch/scripts/configuration.lua index 3ef1a9c..b4dc0f6 100644 --- a/misc/freeswitch/scripts/configuration.lua +++ b/misc/freeswitch/scripts/configuration.lua @@ -28,25 +28,29 @@ function nodes(database, local_node_id) return gateways_xml; end -function gateways(profile_name) + +function gateways(database, profile_name) require 'configuration.simple_xml' local xml = configuration.simple_xml.SimpleXml:new(); - require 'common.configuration_file' - local gateways_xml = ''; - local gateways = common.configuration_file.get('/opt/freeswitch/scripts/ini/gateways.ini', false); + require 'common.str' - if not gateways then - return ''; - end + require 'common.gateway' + local gateway_class = common.gateway.Gateway:new{ log = log, database = database}; + local gateways = gateway_class:list('sip'); + + local gateways_xml = ''; + for index=1, #gateways do + local gateway = gateways[index]; + local gateway_profile = gateway_class:profile_get(gateway.id); + if tostring(gateway_profile) == profile_name or (profile_name == 'gemeinschaft' and common.str.blank(gateway_profile)) then + log:debug('GATEWAY - name: ', gateway.name); + local parameters = gateway_class:parameters_build(gateway.id); - for gateway_name, gateway_parameters in pairs(gateways) do - if tostring(gateway_parameters.profile) == profile_name then - log:debug('GATEWAY - name: ', gateway_name, ', address: ', gateway_parameters.proxy); gateways_xml = gateways_xml .. xml:element{ 'gateway', - name = gateway_name, - xml:from_hash('param', gateway_parameters, 'name', 'value'), + name = gateway.name, + xml:from_hash('param', parameters, 'name', 'value'), }; end end @@ -54,6 +58,7 @@ function gateways(profile_name) return gateways_xml; end + function profile(database, sofia_ini, profile_name, index, domains, node_id) require 'configuration.simple_xml' local xml = configuration.simple_xml.SimpleXml:new(); @@ -81,7 +86,7 @@ function profile(database, sofia_ini, profile_name, index, domains, node_id) log:debug('SOFIA_PROFILE ', index,' - name: ', profile_name, ' - no domains'); end - local gateways_xml = gateways(profile_name); + local gateways_xml = gateways(database, profile_name); if index == 1 then gateways_xml = gateways_xml .. nodes(database, node_id); -- cgit v1.2.3 From aa896ace9575e1be265a8214add35892063579e6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:28:47 +0000 Subject: gateway route added --- config/routes.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 6d45f9f..4e812c0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,10 @@ Gemeinschaft42c::Application.routes.draw do + + resources :gateways do + resources :gateway_settings + resources :gateway_parameters + end + resources :gs_parameters, :only => [:show, :index, :update, :edit] resources :automatic_call_distributors -- cgit v1.2.3 From f4ff0f4d08d73e699edf3b18ff99ba34e64f952b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:32:51 +0000 Subject: gateway models added --- app/models/gateway.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/models/gateway.rb diff --git a/app/models/gateway.rb b/app/models/gateway.rb new file mode 100644 index 0000000..6a7514c --- /dev/null +++ b/app/models/gateway.rb @@ -0,0 +1,6 @@ +class Gateway < ActiveRecord::Base + attr_accessible :name, :technology, :inbound, :outbound, :description + + has_many :gateway_settings, :dependent => :destroy + has_many :gateway_parameters, :dependent => :destroy +end -- cgit v1.2.3 From 409e32a29e183202be31935aaaf6e1f97b30702f Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:33:07 +0000 Subject: gateway settings models added --- app/models/gateway_setting.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/models/gateway_setting.rb diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb new file mode 100644 index 0000000..c6c0b9a --- /dev/null +++ b/app/models/gateway_setting.rb @@ -0,0 +1,5 @@ +class GatewaySetting < ActiveRecord::Base + attr_accessible :gateway_id, :name, :value, :class_type, :description + + belongs_to :gateway +end -- cgit v1.2.3 From 983cce30e1f84a4674fa45977076f1a04f0f20db Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:33:19 +0000 Subject: gateway parameters models added --- app/models/gateway_parameter.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/models/gateway_parameter.rb diff --git a/app/models/gateway_parameter.rb b/app/models/gateway_parameter.rb new file mode 100644 index 0000000..efa52df --- /dev/null +++ b/app/models/gateway_parameter.rb @@ -0,0 +1,5 @@ +class GatewayParameter < ActiveRecord::Base + attr_accessible :gateway_id, :name, :value, :class_type, :description + + belongs_to :gateway +end -- cgit v1.2.3 From 35d855d7c0d174a77fb5edd2978c2381fad83520 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:34:12 +0000 Subject: gateway controller --- app/controllers/gateways_controller.rb | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/controllers/gateways_controller.rb diff --git a/app/controllers/gateways_controller.rb b/app/controllers/gateways_controller.rb new file mode 100644 index 0000000..6173ca3 --- /dev/null +++ b/app/controllers/gateways_controller.rb @@ -0,0 +1,41 @@ +class GatewaysController < ApplicationController + def index + @gateways = Gateway.all + end + + def show + @gateway = Gateway.find(params[:id]) + end + + def new + @gateway = Gateway.new + end + + def create + @gateway = Gateway.new(params[:gateway]) + if @gateway.save + redirect_to @gateway, :notice => t('gateways.controller.successfuly_created') + else + render :new + end + end + + def edit + @gateway = Gateway.find(params[:id]) + end + + def update + @gateway = Gateway.find(params[:id]) + if @gateway.update_attributes(params[:gateway]) + redirect_to @gateway, :notice => t('gateways.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @gateway = Gateway.find(params[:id]) + @gateway.destroy + redirect_to gateways_url, :notice => t('gateways.controller.successfuly_destroyed') + end +end -- cgit v1.2.3 From 6f5d708a5fe74e6ba3efe2ec2d0f9f7cec5c6758 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:34:29 +0000 Subject: gateway helper --- app/helpers/gateways_helper.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/helpers/gateways_helper.rb diff --git a/app/helpers/gateways_helper.rb b/app/helpers/gateways_helper.rb new file mode 100644 index 0000000..247e4bc --- /dev/null +++ b/app/helpers/gateways_helper.rb @@ -0,0 +1,2 @@ +module GatewaysHelper +end -- cgit v1.2.3 From 778bcf22238298f3104ddf029b007656e92fc98a Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:35:06 +0000 Subject: gateway settings controller --- app/controllers/gateway_settings_controller.rb | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 app/controllers/gateway_settings_controller.rb diff --git a/app/controllers/gateway_settings_controller.rb b/app/controllers/gateway_settings_controller.rb new file mode 100644 index 0000000..04af795 --- /dev/null +++ b/app/controllers/gateway_settings_controller.rb @@ -0,0 +1,42 @@ +class GatewaySettingsController < ApplicationController + load_and_authorize_resource :gateway + load_and_authorize_resource :gateway_setting, :through => [:gateway] + + def index + end + + def show + end + + def new + # @gateway_setting = @gateway.gateway_settings.build + end + + def create + @gateway_setting = GatewaySetting.new(params[:gateway_setting]) + if @gateway_setting.save + redirect_to @gateway_setting, :notice => t('gateway_settings.controller.successfuly_created') + else + render :new + end + end + + def edit + @gateway_setting = GatewaySetting.find(params[:id]) + end + + def update + @gateway_setting = GatewaySetting.find(params[:id]) + if @gateway_setting.update_attributes(params[:gateway_setting]) + redirect_to @gateway_setting, :notice => t('gateway_settings.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @gateway_setting = GatewaySetting.find(params[:id]) + @gateway_setting.destroy + redirect_to gateway_settings_url, :notice => t('gateway_settings.controller.successfuly_destroyed') + end +end -- cgit v1.2.3 From 2452f145763d3d1972dc4238f4420da7c6cc02fe Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:35:30 +0000 Subject: gateway parameters controller --- app/controllers/gateway_parameters_controller.rb | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/controllers/gateway_parameters_controller.rb diff --git a/app/controllers/gateway_parameters_controller.rb b/app/controllers/gateway_parameters_controller.rb new file mode 100644 index 0000000..a5066d0 --- /dev/null +++ b/app/controllers/gateway_parameters_controller.rb @@ -0,0 +1,41 @@ +class GatewayParametersController < ApplicationController + def index + @gateway_parameters = GatewayParameter.all + end + + def show + @gateway_parameter = GatewayParameter.find(params[:id]) + end + + def new + @gateway_parameter = GatewayParameter.new + end + + def create + @gateway_parameter = GatewayParameter.new(params[:gateway_parameter]) + if @gateway_parameter.save + redirect_to @gateway_parameter, :notice => t('gateway_parameters.controller.successfuly_created') + else + render :new + end + end + + def edit + @gateway_parameter = GatewayParameter.find(params[:id]) + end + + def update + @gateway_parameter = GatewayParameter.find(params[:id]) + if @gateway_parameter.update_attributes(params[:gateway_parameter]) + redirect_to @gateway_parameter, :notice => t('gateway_parameters.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @gateway_parameter = GatewayParameter.find(params[:id]) + @gateway_parameter.destroy + redirect_to gateway_parameters_url, :notice => t('gateway_parameters.controller.successfuly_destroyed') + end +end -- cgit v1.2.3 From d262df1df477324a606743a4e100f6cb4fa7b87c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:35:56 +0000 Subject: gateway parameters helper --- app/helpers/gateway_parameters_helper.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/helpers/gateway_parameters_helper.rb diff --git a/app/helpers/gateway_parameters_helper.rb b/app/helpers/gateway_parameters_helper.rb new file mode 100644 index 0000000..a6fa037 --- /dev/null +++ b/app/helpers/gateway_parameters_helper.rb @@ -0,0 +1,2 @@ +module GatewayParametersHelper +end -- cgit v1.2.3 From 3bc87f6b2e7563e1e22e3976e11db20d040ba18e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:36:19 +0000 Subject: gateway settings helper --- app/helpers/gateway_settings_helper.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/helpers/gateway_settings_helper.rb diff --git a/app/helpers/gateway_settings_helper.rb b/app/helpers/gateway_settings_helper.rb new file mode 100644 index 0000000..acb0a8c --- /dev/null +++ b/app/helpers/gateway_settings_helper.rb @@ -0,0 +1,2 @@ +module GatewaySettingsHelper +end -- cgit v1.2.3 From f48e68fbf5889a837cb4f7442e39997eea94511c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:36:51 +0000 Subject: gateway views --- app/views/gateways/_form.html.haml | 7 +++++++ app/views/gateways/_form_core.html.haml | 6 ++++++ app/views/gateways/_index_core.html.haml | 17 +++++++++++++++++ app/views/gateways/edit.html.haml | 3 +++ app/views/gateways/index.html.haml | 6 ++++++ app/views/gateways/new.html.haml | 3 +++ app/views/gateways/show.html.haml | 19 +++++++++++++++++++ 7 files changed, 61 insertions(+) create mode 100644 app/views/gateways/_form.html.haml create mode 100644 app/views/gateways/_form_core.html.haml create mode 100644 app/views/gateways/_index_core.html.haml create mode 100644 app/views/gateways/edit.html.haml create mode 100644 app/views/gateways/index.html.haml create mode 100644 app/views/gateways/new.html.haml create mode 100644 app/views/gateways/show.html.haml diff --git a/app/views/gateways/_form.html.haml b/app/views/gateways/_form.html.haml new file mode 100644 index 0000000..5f6d5dd --- /dev/null +++ b/app/views/gateways/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@gateway) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('gateways.form.submit') \ No newline at end of file diff --git a/app/views/gateways/_form_core.html.haml b/app/views/gateways/_form_core.html.haml new file mode 100644 index 0000000..3545772 --- /dev/null +++ b/app/views/gateways/_form_core.html.haml @@ -0,0 +1,6 @@ +.inputs + = f.input :name, :label => t('gateways.form.name.label'), :hint => conditional_hint('gateways.form.name.hint') + = f.input :technology, :label => t('gateways.form.technology.label'), :hint => conditional_hint('gateways.form.technology.hint') + = f.input :inbound, :label => t('gateways.form.inbound.label'), :hint => conditional_hint('gateways.form.inbound.hint') + = f.input :outbound, :label => t('gateways.form.outbound.label'), :hint => conditional_hint('gateways.form.outbound.hint') + = f.input :description, :label => t('gateways.form.description.label'), :hint => conditional_hint('gateways.form.description.hint') diff --git a/app/views/gateways/_index_core.html.haml b/app/views/gateways/_index_core.html.haml new file mode 100644 index 0000000..21414c3 --- /dev/null +++ b/app/views/gateways/_index_core.html.haml @@ -0,0 +1,17 @@ +%table + %tr + %th= t('gateways.index.name') + %th= t('gateways.index.technology') + %th= t('gateways.index.inbound') + %th= t('gateways.index.outbound') + %th= t('gateways.index.description') + + - reset_cycle + - for gateway in gateways + %tr{:class => cycle('odd', 'even')} + %td= gateway.name + %td= gateway.technology + %td= gateway.inbound + %td= gateway.outbound + %td= gateway.description + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gateway} \ No newline at end of file diff --git a/app/views/gateways/edit.html.haml b/app/views/gateways/edit.html.haml new file mode 100644 index 0000000..417dd09 --- /dev/null +++ b/app/views/gateways/edit.html.haml @@ -0,0 +1,3 @@ +- title t("gateways.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/gateways/index.html.haml b/app/views/gateways/index.html.haml new file mode 100644 index 0000000..cec9cd1 --- /dev/null +++ b/app/views/gateways/index.html.haml @@ -0,0 +1,6 @@ +- title t("gateways.index.page_title") + +- if @gateways && @gateways.count > 0 + = render "index_core", :gateways => @gateways + += render :partial => 'shared/create_link', :locals => {:child_class => Gateway} \ No newline at end of file diff --git a/app/views/gateways/new.html.haml b/app/views/gateways/new.html.haml new file mode 100644 index 0000000..a2609f3 --- /dev/null +++ b/app/views/gateways/new.html.haml @@ -0,0 +1,3 @@ +- title t("gateways.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml new file mode 100644 index 0000000..c9942dd --- /dev/null +++ b/app/views/gateways/show.html.haml @@ -0,0 +1,19 @@ +- title t("gateways.show.page_title") + +%p + %strong= t('gateways.show.name') + ":" + = @gateway.name +%p + %strong= t('gateways.show.technology') + ":" + = @gateway.technology +%p + %strong= t('gateways.show.inbound') + ":" + = @gateway.inbound +%p + %strong= t('gateways.show.outbound') + ":" + = @gateway.outbound +%p + %strong= t('gateways.show.description') + ":" + = @gateway.description + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway } \ No newline at end of file -- cgit v1.2.3 From dbb740151dabceeec4891a2233d37b4ad55c9edc Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:37:07 +0000 Subject: gateway_settings views --- app/views/gateway_settings/_form.html.haml | 7 +++++++ app/views/gateway_settings/_form_core.html.haml | 5 +++++ app/views/gateway_settings/_index_core.html.haml | 17 +++++++++++++++++ app/views/gateway_settings/edit.html.haml | 3 +++ app/views/gateway_settings/index.html.haml | 6 ++++++ app/views/gateway_settings/new.html.haml | 3 +++ app/views/gateway_settings/show.html.haml | 19 +++++++++++++++++++ 7 files changed, 60 insertions(+) create mode 100644 app/views/gateway_settings/_form.html.haml create mode 100644 app/views/gateway_settings/_form_core.html.haml create mode 100644 app/views/gateway_settings/_index_core.html.haml create mode 100644 app/views/gateway_settings/edit.html.haml create mode 100644 app/views/gateway_settings/index.html.haml create mode 100644 app/views/gateway_settings/new.html.haml create mode 100644 app/views/gateway_settings/show.html.haml diff --git a/app/views/gateway_settings/_form.html.haml b/app/views/gateway_settings/_form.html.haml new file mode 100644 index 0000000..af26d2a --- /dev/null +++ b/app/views/gateway_settings/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for([@gateway, @gateway_setting]) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('gateway_settings.form.submit') diff --git a/app/views/gateway_settings/_form_core.html.haml b/app/views/gateway_settings/_form_core.html.haml new file mode 100644 index 0000000..3880113 --- /dev/null +++ b/app/views/gateway_settings/_form_core.html.haml @@ -0,0 +1,5 @@ +.inputs + = f.input :name, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint') + = f.input :value, :label => t('gateway_settings.form.value.label'), :hint => conditional_hint('gateway_settings.form.value.hint') + = f.input :class_type, :label => t('gateway_settings.form.class_type.label'), :hint => conditional_hint('gateway_settings.form.class_type.hint') + = f.input :description, :label => t('gateway_settings.form.description.label'), :hint => conditional_hint('gateway_settings.form.description.hint') diff --git a/app/views/gateway_settings/_index_core.html.haml b/app/views/gateway_settings/_index_core.html.haml new file mode 100644 index 0000000..1b8e443 --- /dev/null +++ b/app/views/gateway_settings/_index_core.html.haml @@ -0,0 +1,17 @@ +%table + %tr + %th= t('gateway_settings.index.gateway_id') + %th= t('gateway_settings.index.name') + %th= t('gateway_settings.index.value') + %th= t('gateway_settings.index.class_type') + %th= t('gateway_settings.index.description') + + - reset_cycle + - for gateway_setting in gateway_settings + %tr{:class => cycle('odd', 'even')} + %td= gateway_setting.gateway_id + %td= gateway_setting.name + %td= gateway_setting.value + %td= gateway_setting.class_type + %td= gateway_setting.description + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gateway_setting} \ No newline at end of file diff --git a/app/views/gateway_settings/edit.html.haml b/app/views/gateway_settings/edit.html.haml new file mode 100644 index 0000000..b374f42 --- /dev/null +++ b/app/views/gateway_settings/edit.html.haml @@ -0,0 +1,3 @@ +- title t("gateway_settings.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/gateway_settings/index.html.haml b/app/views/gateway_settings/index.html.haml new file mode 100644 index 0000000..b85ef0a --- /dev/null +++ b/app/views/gateway_settings/index.html.haml @@ -0,0 +1,6 @@ +- title t("gateway_settings.index.page_title") + +- if @gateway_settings && @gateway_settings.count > 0 + = render "index_core", :gateway_settings => @gateway_settings + += render :partial => 'shared/create_link', :locals => {:parent => @gateway, :child_class => GatewaySetting} diff --git a/app/views/gateway_settings/new.html.haml b/app/views/gateway_settings/new.html.haml new file mode 100644 index 0000000..5399dc3 --- /dev/null +++ b/app/views/gateway_settings/new.html.haml @@ -0,0 +1,3 @@ +- title t("gateway_settings.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/gateway_settings/show.html.haml b/app/views/gateway_settings/show.html.haml new file mode 100644 index 0000000..4f38e0b --- /dev/null +++ b/app/views/gateway_settings/show.html.haml @@ -0,0 +1,19 @@ +- title t("gateway_settings.show.page_title") + +%p + %strong= t('gateway_settings.show.gateway_id') + ":" + = @gateway_setting.gateway_id +%p + %strong= t('gateway_settings.show.name') + ":" + = @gateway_setting.name +%p + %strong= t('gateway_settings.show.value') + ":" + = @gateway_setting.value +%p + %strong= t('gateway_settings.show.class_type') + ":" + = @gateway_setting.class_type +%p + %strong= t('gateway_settings.show.description') + ":" + = @gateway_setting.description + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway_setting } \ No newline at end of file -- cgit v1.2.3 From 7cfddc9022d0b283ee278eea3be88c80089c0207 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:37:22 +0000 Subject: gateway_parameters views --- app/views/gateway_parameters/_form.html.haml | 7 +++++++ app/views/gateway_parameters/_form_core.html.haml | 6 ++++++ app/views/gateway_parameters/_index_core.html.haml | 17 +++++++++++++++++ app/views/gateway_parameters/edit.html.haml | 3 +++ app/views/gateway_parameters/index.html.haml | 6 ++++++ app/views/gateway_parameters/new.html.haml | 3 +++ app/views/gateway_parameters/show.html.haml | 19 +++++++++++++++++++ 7 files changed, 61 insertions(+) create mode 100644 app/views/gateway_parameters/_form.html.haml create mode 100644 app/views/gateway_parameters/_form_core.html.haml create mode 100644 app/views/gateway_parameters/_index_core.html.haml create mode 100644 app/views/gateway_parameters/edit.html.haml create mode 100644 app/views/gateway_parameters/index.html.haml create mode 100644 app/views/gateway_parameters/new.html.haml create mode 100644 app/views/gateway_parameters/show.html.haml diff --git a/app/views/gateway_parameters/_form.html.haml b/app/views/gateway_parameters/_form.html.haml new file mode 100644 index 0000000..490f2a6 --- /dev/null +++ b/app/views/gateway_parameters/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@gateway_parameter) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('gateway_parameters.form.submit') \ No newline at end of file diff --git a/app/views/gateway_parameters/_form_core.html.haml b/app/views/gateway_parameters/_form_core.html.haml new file mode 100644 index 0000000..026e833 --- /dev/null +++ b/app/views/gateway_parameters/_form_core.html.haml @@ -0,0 +1,6 @@ +.inputs + = f.input :gateway_id, :label => t('gateway_parameters.form.gateway_id.label'), :hint => conditional_hint('gateway_parameters.form.gateway_id.hint') + = f.input :name, :label => t('gateway_parameters.form.name.label'), :hint => conditional_hint('gateway_parameters.form.name.hint') + = f.input :value, :label => t('gateway_parameters.form.value.label'), :hint => conditional_hint('gateway_parameters.form.value.hint') + = f.input :class_type, :label => t('gateway_parameters.form.class_type.label'), :hint => conditional_hint('gateway_parameters.form.class_type.hint') + = f.input :description, :label => t('gateway_parameters.form.description.label'), :hint => conditional_hint('gateway_parameters.form.description.hint') diff --git a/app/views/gateway_parameters/_index_core.html.haml b/app/views/gateway_parameters/_index_core.html.haml new file mode 100644 index 0000000..6209f43 --- /dev/null +++ b/app/views/gateway_parameters/_index_core.html.haml @@ -0,0 +1,17 @@ +%table + %tr + %th= t('gateway_parameters.index.gateway_id') + %th= t('gateway_parameters.index.name') + %th= t('gateway_parameters.index.value') + %th= t('gateway_parameters.index.class_type') + %th= t('gateway_parameters.index.description') + + - reset_cycle + - for gateway_parameter in gateway_parameters + %tr{:class => cycle('odd', 'even')} + %td= gateway_parameter.gateway_id + %td= gateway_parameter.name + %td= gateway_parameter.value + %td= gateway_parameter.class_type + %td= gateway_parameter.description + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gateway_parameter} \ No newline at end of file diff --git a/app/views/gateway_parameters/edit.html.haml b/app/views/gateway_parameters/edit.html.haml new file mode 100644 index 0000000..86fe979 --- /dev/null +++ b/app/views/gateway_parameters/edit.html.haml @@ -0,0 +1,3 @@ +- title t("gateway_parameters.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/gateway_parameters/index.html.haml b/app/views/gateway_parameters/index.html.haml new file mode 100644 index 0000000..1234cff --- /dev/null +++ b/app/views/gateway_parameters/index.html.haml @@ -0,0 +1,6 @@ +- title t("gateway_parameters.index.page_title") + +- if @gateway_parameters && @gateway_parameters.count > 0 + = render "index_core", :gateway_parameters => @gateway_parameters + += render :partial => 'shared/create_link', :locals => {:child_class => GatewayParameter} \ No newline at end of file diff --git a/app/views/gateway_parameters/new.html.haml b/app/views/gateway_parameters/new.html.haml new file mode 100644 index 0000000..5844088 --- /dev/null +++ b/app/views/gateway_parameters/new.html.haml @@ -0,0 +1,3 @@ +- title t("gateway_parameters.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/gateway_parameters/show.html.haml b/app/views/gateway_parameters/show.html.haml new file mode 100644 index 0000000..87ba10d --- /dev/null +++ b/app/views/gateway_parameters/show.html.haml @@ -0,0 +1,19 @@ +- title t("gateway_parameters.show.page_title") + +%p + %strong= t('gateway_parameters.show.gateway_id') + ":" + = @gateway_parameter.gateway_id +%p + %strong= t('gateway_parameters.show.name') + ":" + = @gateway_parameter.name +%p + %strong= t('gateway_parameters.show.value') + ":" + = @gateway_parameter.value +%p + %strong= t('gateway_parameters.show.class_type') + ":" + = @gateway_parameter.class_type +%p + %strong= t('gateway_parameters.show.description') + ":" + = @gateway_parameter.description + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway_parameter } \ No newline at end of file -- cgit v1.2.3 From b31a5fdecf45de8a6b0de948e431880de0adbe80 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:38:04 +0000 Subject: gateway locales --- config/locales/views/gateways/de.yml | 60 ++++++++++++++++++++++++++++++++++++ config/locales/views/gateways/en.yml | 60 ++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 config/locales/views/gateways/de.yml create mode 100644 config/locales/views/gateways/en.yml diff --git a/config/locales/views/gateways/de.yml b/config/locales/views/gateways/de.yml new file mode 100644 index 0000000..cfe5615 --- /dev/null +++ b/config/locales/views/gateways/de.yml @@ -0,0 +1,60 @@ +de: + gateways: + name: 'Gateway' + controller: + successfuly_created: 'Gateway wurde angelegt.' + successfuly_updated: 'Gateway wurde aktualisiert.' + successfuly_destroyed: 'Gateway wurde gelöscht.' + index: + page_title: 'Übersicht von Gateway' + name: 'Name' + technology: 'Technology' + inbound: 'Inbound' + outbound: 'Outbound' + description: 'Description' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Gateway' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Gateway neu anlegen für %{resource}' + show: + page_title: 'Gateway bearbeiten' + name: 'Name' + technology: 'Technology' + inbound: 'Inbound' + outbound: 'Outbound' + description: 'Description' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Gateway neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Gateway bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + name: + label: 'Name' + hint: '' + technology: + label: 'Technology' + hint: '' + inbound: + label: 'Inbound' + hint: '' + outbound: + label: 'Outbound' + hint: '' + description: + label: 'Description' + hint: '' + button: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/gateways/en.yml b/config/locales/views/gateways/en.yml new file mode 100644 index 0000000..2abf0f2 --- /dev/null +++ b/config/locales/views/gateways/en.yml @@ -0,0 +1,60 @@ +en: + gateways: + name: 'Gateway' + controller: + successfuly_created: 'Successfully created Gateway.' + successfuly_updated: 'Successfully updated Gateway.' + successfuly_destroyed: 'Successfully destroyed Gateway.' + index: + page_title: 'Listing Gateway' + name: 'Name' + technology: 'Technology' + inbound: 'Inbound' + outbound: 'Outbound' + description: 'Description' + actions: + confirm: 'Are you sure you want to delete this Gateway?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Gateway for %{resource}' + show: + page_title: 'Show Gateway' + name: 'Name' + technology: 'Technology' + inbound: 'Inbound' + outbound: 'Outbound' + description: 'Description' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Gateway' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Gateway' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + name: + label: 'Name' + hint: '' + technology: + label: 'Technology' + hint: '' + inbound: + label: 'Inbound' + hint: '' + outbound: + label: 'Outbound' + hint: '' + description: + label: 'Description' + hint: '' + button: 'Submit' \ No newline at end of file -- cgit v1.2.3 From 68e819dac27c262e918950f740b75a7739901aee Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:38:19 +0000 Subject: gateway settings locales --- config/locales/views/gateway_settings/de.yml | 60 ++++++++++++++++++++++++++++ config/locales/views/gateway_settings/en.yml | 60 ++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 config/locales/views/gateway_settings/de.yml create mode 100644 config/locales/views/gateway_settings/en.yml diff --git a/config/locales/views/gateway_settings/de.yml b/config/locales/views/gateway_settings/de.yml new file mode 100644 index 0000000..b008e5e --- /dev/null +++ b/config/locales/views/gateway_settings/de.yml @@ -0,0 +1,60 @@ +de: + gateway_settings: + name: 'Gatewaysetting' + controller: + successfuly_created: 'Gatewaysetting wurde angelegt.' + successfuly_updated: 'Gatewaysetting wurde aktualisiert.' + successfuly_destroyed: 'Gatewaysetting wurde gelöscht.' + index: + page_title: 'Übersicht von Gatewaysetting' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Gatewaysetting' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Gatewaysetting neu anlegen für %{resource}' + show: + page_title: 'Gatewaysetting bearbeiten' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Gatewaysetting neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Gatewaysetting bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + gateway_id: + label: 'Gateway' + hint: '' + name: + label: 'Name' + hint: '' + value: + label: 'Value' + hint: '' + class_type: + label: 'Class type' + hint: '' + description: + label: 'Description' + hint: '' + button: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/gateway_settings/en.yml b/config/locales/views/gateway_settings/en.yml new file mode 100644 index 0000000..3072eb9 --- /dev/null +++ b/config/locales/views/gateway_settings/en.yml @@ -0,0 +1,60 @@ +en: + gateway_settings: + name: 'Gatewaysetting' + controller: + successfuly_created: 'Successfully created Gatewaysetting.' + successfuly_updated: 'Successfully updated Gatewaysetting.' + successfuly_destroyed: 'Successfully destroyed Gatewaysetting.' + index: + page_title: 'Listing Gatewaysetting' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Are you sure you want to delete this Gatewaysetting?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Gatewaysetting for %{resource}' + show: + page_title: 'Show Gatewaysetting' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Gatewaysetting' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Gatewaysetting' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + gateway_id: + label: 'Gateway' + hint: '' + name: + label: 'Name' + hint: '' + value: + label: 'Value' + hint: '' + class_type: + label: 'Class type' + hint: '' + description: + label: 'Description' + hint: '' + button: 'Submit' \ No newline at end of file -- cgit v1.2.3 From 9847f54b4ee56c87c0b215df003493ae723d1edf Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:38:31 +0000 Subject: gateway parameters locales --- config/locales/views/gateway_parameters/de.yml | 60 ++++++++++++++++++++++++++ config/locales/views/gateway_parameters/en.yml | 60 ++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 config/locales/views/gateway_parameters/de.yml create mode 100644 config/locales/views/gateway_parameters/en.yml diff --git a/config/locales/views/gateway_parameters/de.yml b/config/locales/views/gateway_parameters/de.yml new file mode 100644 index 0000000..9c1cc3b --- /dev/null +++ b/config/locales/views/gateway_parameters/de.yml @@ -0,0 +1,60 @@ +de: + gateway_parameters: + name: 'Gatewayparameter' + controller: + successfuly_created: 'Gatewayparameter wurde angelegt.' + successfuly_updated: 'Gatewayparameter wurde aktualisiert.' + successfuly_destroyed: 'Gatewayparameter wurde gelöscht.' + index: + page_title: 'Übersicht von Gatewayparameter' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Gatewayparameter' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Gatewayparameter neu anlegen für %{resource}' + show: + page_title: 'Gatewayparameter bearbeiten' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Gatewayparameter neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Gatewayparameter bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + gateway_id: + label: 'Gateway' + hint: '' + name: + label: 'Name' + hint: '' + value: + label: 'Value' + hint: '' + class_type: + label: 'Class type' + hint: '' + description: + label: 'Description' + hint: '' + button: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/gateway_parameters/en.yml b/config/locales/views/gateway_parameters/en.yml new file mode 100644 index 0000000..8d84298 --- /dev/null +++ b/config/locales/views/gateway_parameters/en.yml @@ -0,0 +1,60 @@ +en: + gateway_parameters: + name: 'Gatewayparameter' + controller: + successfuly_created: 'Successfully created Gatewayparameter.' + successfuly_updated: 'Successfully updated Gatewayparameter.' + successfuly_destroyed: 'Successfully destroyed Gatewayparameter.' + index: + page_title: 'Listing Gatewayparameter' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Are you sure you want to delete this Gatewayparameter?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Gatewayparameter for %{resource}' + show: + page_title: 'Show Gatewayparameter' + gateway_id: 'Gateway' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Gatewayparameter' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Gatewayparameter' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + gateway_id: + label: 'Gateway' + hint: '' + name: + label: 'Name' + hint: '' + value: + label: 'Value' + hint: '' + class_type: + label: 'Class type' + hint: '' + description: + label: 'Description' + hint: '' + button: 'Submit' \ No newline at end of file -- cgit v1.2.3 From a5922502d5d1ec053375c07ba12af0475d30adbe Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:39:33 +0000 Subject: gateway tests --- test/functional/gateways_controller_test.rb | 49 +++++++++++++++++++++++++++++ test/unit/gateway_test.rb | 7 +++++ 2 files changed, 56 insertions(+) create mode 100644 test/functional/gateways_controller_test.rb create mode 100644 test/unit/gateway_test.rb diff --git a/test/functional/gateways_controller_test.rb b/test/functional/gateways_controller_test.rb new file mode 100644 index 0000000..e0928dd --- /dev/null +++ b/test/functional/gateways_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class GatewaysControllerTest < ActionController::TestCase + setup do + @gateway = gateways(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:gateways) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create gateway" do + assert_difference('Gateway.count') do + post :create, gateway: @gateway.attributes + end + + assert_redirected_to gateway_path(assigns(:gateway)) + end + + test "should show gateway" do + get :show, id: @gateway.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @gateway.to_param + assert_response :success + end + + test "should update gateway" do + put :update, id: @gateway.to_param, gateway: @gateway.attributes + assert_redirected_to gateway_path(assigns(:gateway)) + end + + test "should destroy gateway" do + assert_difference('Gateway.count', -1) do + delete :destroy, id: @gateway.to_param + end + + assert_redirected_to gateways_path + end +end diff --git a/test/unit/gateway_test.rb b/test/unit/gateway_test.rb new file mode 100644 index 0000000..4c40dc9 --- /dev/null +++ b/test/unit/gateway_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GatewayTest < ActiveSupport::TestCase + def test_should_be_valid + assert Gateway.new.valid? + end +end -- cgit v1.2.3 From c07463f6d2b2d1e7467af31b8849c7085deabec3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:39:54 +0000 Subject: gateway settings tests --- .../functional/gateway_settings_controller_test.rb | 49 ++++++++++++++++++++++ test/unit/gateway_setting_test.rb | 7 ++++ 2 files changed, 56 insertions(+) create mode 100644 test/functional/gateway_settings_controller_test.rb create mode 100644 test/unit/gateway_setting_test.rb diff --git a/test/functional/gateway_settings_controller_test.rb b/test/functional/gateway_settings_controller_test.rb new file mode 100644 index 0000000..c416528 --- /dev/null +++ b/test/functional/gateway_settings_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class GatewaySettingsControllerTest < ActionController::TestCase + setup do + @gateway_setting = gateway_settings(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:gateway_settings) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create gateway_setting" do + assert_difference('GatewaySetting.count') do + post :create, gateway_setting: @gateway_setting.attributes + end + + assert_redirected_to gateway_setting_path(assigns(:gateway_setting)) + end + + test "should show gateway_setting" do + get :show, id: @gateway_setting.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @gateway_setting.to_param + assert_response :success + end + + test "should update gateway_setting" do + put :update, id: @gateway_setting.to_param, gateway_setting: @gateway_setting.attributes + assert_redirected_to gateway_setting_path(assigns(:gateway_setting)) + end + + test "should destroy gateway_setting" do + assert_difference('GatewaySetting.count', -1) do + delete :destroy, id: @gateway_setting.to_param + end + + assert_redirected_to gateway_settings_path + end +end diff --git a/test/unit/gateway_setting_test.rb b/test/unit/gateway_setting_test.rb new file mode 100644 index 0000000..86176b4 --- /dev/null +++ b/test/unit/gateway_setting_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GatewaySettingTest < ActiveSupport::TestCase + def test_should_be_valid + assert GatewaySetting.new.valid? + end +end -- cgit v1.2.3 From 7cfb1fd6beabf26ffe7726e7a04c0bdf37bc044a Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:40:16 +0000 Subject: gateway parameters tests --- .../gateway_parameters_controller_test.rb | 49 ++++++++++++++++++++++ test/unit/gateway_parameter_test.rb | 7 ++++ 2 files changed, 56 insertions(+) create mode 100644 test/functional/gateway_parameters_controller_test.rb create mode 100644 test/unit/gateway_parameter_test.rb diff --git a/test/functional/gateway_parameters_controller_test.rb b/test/functional/gateway_parameters_controller_test.rb new file mode 100644 index 0000000..6f6ce40 --- /dev/null +++ b/test/functional/gateway_parameters_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class GatewayParametersControllerTest < ActionController::TestCase + setup do + @gateway_parameter = gateway_parameters(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:gateway_parameters) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create gateway_parameter" do + assert_difference('GatewayParameter.count') do + post :create, gateway_parameter: @gateway_parameter.attributes + end + + assert_redirected_to gateway_parameter_path(assigns(:gateway_parameter)) + end + + test "should show gateway_parameter" do + get :show, id: @gateway_parameter.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @gateway_parameter.to_param + assert_response :success + end + + test "should update gateway_parameter" do + put :update, id: @gateway_parameter.to_param, gateway_parameter: @gateway_parameter.attributes + assert_redirected_to gateway_parameter_path(assigns(:gateway_parameter)) + end + + test "should destroy gateway_parameter" do + assert_difference('GatewayParameter.count', -1) do + delete :destroy, id: @gateway_parameter.to_param + end + + assert_redirected_to gateway_parameters_path + end +end diff --git a/test/unit/gateway_parameter_test.rb b/test/unit/gateway_parameter_test.rb new file mode 100644 index 0000000..cec1e1a --- /dev/null +++ b/test/unit/gateway_parameter_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GatewayParameterTest < ActiveSupport::TestCase + def test_should_be_valid + assert GatewayParameter.new.valid? + end +end -- cgit v1.2.3 From 9c3f6bfe2b5ae7d1dc05de432ce4fe202940d84d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:40:43 +0000 Subject: gateway model migration --- db/migrate/20130113072126_create_gateways.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 db/migrate/20130113072126_create_gateways.rb diff --git a/db/migrate/20130113072126_create_gateways.rb b/db/migrate/20130113072126_create_gateways.rb new file mode 100644 index 0000000..e6c3f77 --- /dev/null +++ b/db/migrate/20130113072126_create_gateways.rb @@ -0,0 +1,16 @@ +class CreateGateways < ActiveRecord::Migration + def self.up + create_table :gateways do |t| + t.string :name + t.string :technology + t.boolean :inbound + t.boolean :outbound + t.string :description + t.timestamps + end + end + + def self.down + drop_table :gateways + end +end -- cgit v1.2.3 From 4cacd9a6ccc2caa0606a7cb6db0002c67dbae33b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:40:57 +0000 Subject: gateway settings model migration --- db/migrate/20130113073323_create_gateway_settings.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 db/migrate/20130113073323_create_gateway_settings.rb diff --git a/db/migrate/20130113073323_create_gateway_settings.rb b/db/migrate/20130113073323_create_gateway_settings.rb new file mode 100644 index 0000000..0200ae7 --- /dev/null +++ b/db/migrate/20130113073323_create_gateway_settings.rb @@ -0,0 +1,16 @@ +class CreateGatewaySettings < ActiveRecord::Migration + def self.up + create_table :gateway_settings do |t| + t.integer :gateway_id + t.string :name + t.string :value + t.string :class_type + t.string :description + t.timestamps + end + end + + def self.down + drop_table :gateway_settings + end +end -- cgit v1.2.3 From 2e8f2f2b51303ad1ad677a606e877b1fd3d7219b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 13 Jan 2013 16:41:13 +0000 Subject: gateway parameters model migration --- db/migrate/20130113090705_create_gateway_parameters.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 db/migrate/20130113090705_create_gateway_parameters.rb diff --git a/db/migrate/20130113090705_create_gateway_parameters.rb b/db/migrate/20130113090705_create_gateway_parameters.rb new file mode 100644 index 0000000..bbf5f54 --- /dev/null +++ b/db/migrate/20130113090705_create_gateway_parameters.rb @@ -0,0 +1,16 @@ +class CreateGatewayParameters < ActiveRecord::Migration + def self.up + create_table :gateway_parameters do |t| + t.integer :gateway_id + t.string :name + t.string :value + t.string :class_type + t.string :description + t.timestamps + end + end + + def self.down + drop_table :gateway_parameters + end +end -- cgit v1.2.3 From f10b264bbae53a7128b22c385201161d21a9000f Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 13 Jan 2013 20:28:46 +0100 Subject: validations --- app/models/gateway.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/models/gateway.rb b/app/models/gateway.rb index 6a7514c..72cf72c 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -1,6 +1,17 @@ class Gateway < ActiveRecord::Base + TECHNOLOGIES = ['sip'] + attr_accessible :name, :technology, :inbound, :outbound, :description has_many :gateway_settings, :dependent => :destroy has_many :gateway_parameters, :dependent => :destroy + + validates :name, + :presence => true, + :uniqueness => true + + validates :technology, + :presence => true, + :inclusion => { :in => TECHNOLOGIES } + end -- cgit v1.2.3 From 86c322181ac1aeed7fa8dde7f7c03b570359917b Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 13 Jan 2013 20:33:32 +0100 Subject: validations --- app/models/gateway_setting.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index c6c0b9a..bc676a4 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -2,4 +2,12 @@ class GatewaySetting < ActiveRecord::Base attr_accessible :gateway_id, :name, :value, :class_type, :description belongs_to :gateway + + validates :name, + :presence => true, + :uniqueness => true + + validates :class_type, + :presence => true, + :inclusion => { :in => ['String', 'Integer', 'Boolean'] } end -- cgit v1.2.3 From 6ae1b0df2648ccc02afa8fe375693e15117736fa Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 13 Jan 2013 20:33:35 +0100 Subject: validations --- app/models/gateway_parameter.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/gateway_parameter.rb b/app/models/gateway_parameter.rb index efa52df..1875863 100644 --- a/app/models/gateway_parameter.rb +++ b/app/models/gateway_parameter.rb @@ -2,4 +2,12 @@ class GatewayParameter < ActiveRecord::Base attr_accessible :gateway_id, :name, :value, :class_type, :description belongs_to :gateway + + validates :name, + :presence => true, + :uniqueness => true + + validates :class_type, + :presence => true, + :inclusion => { :in => ['String', 'Integer', 'Boolean'] } end -- cgit v1.2.3 From bfacc7b5de2f3a5a9d09a16683a9ba1fcf184d98 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 13 Jan 2013 22:11:11 +0100 Subject: Fixed some gateway stuff. --- app/controllers/gateway_settings_controller.rb | 15 +++++------ app/models/gateway.rb | 11 ++++++++ app/views/gateway_settings/_index_core.html.haml | 4 +-- app/views/gateway_settings/show.html.haml | 4 +-- config/hirb.yml | 9 ++++++- db/schema.rb | 32 +++++++++++++++++++++++- 6 files changed, 62 insertions(+), 13 deletions(-) diff --git a/app/controllers/gateway_settings_controller.rb b/app/controllers/gateway_settings_controller.rb index 04af795..5d9f7e5 100644 --- a/app/controllers/gateway_settings_controller.rb +++ b/app/controllers/gateway_settings_controller.rb @@ -3,6 +3,7 @@ class GatewaySettingsController < ApplicationController load_and_authorize_resource :gateway_setting, :through => [:gateway] def index + @gateway_settings = @gateway.gateway_settings end def show @@ -13,30 +14,30 @@ class GatewaySettingsController < ApplicationController end def create - @gateway_setting = GatewaySetting.new(params[:gateway_setting]) + @gateway_setting = @gateway.gateway_settings.build(params[:gateway_setting]) if @gateway_setting.save - redirect_to @gateway_setting, :notice => t('gateway_settings.controller.successfuly_created') + redirect_to [@gateway, @gateway_setting], :notice => t('gateway_settings.controller.successfuly_created') else render :new end end def edit - @gateway_setting = GatewaySetting.find(params[:id]) + @gateway_setting = @gateway.gateway_settings.find(params[:id]) end def update - @gateway_setting = GatewaySetting.find(params[:id]) + @gateway_setting = @gateway.gateway_settings.find(params[:id]) if @gateway_setting.update_attributes(params[:gateway_setting]) - redirect_to @gateway_setting, :notice => t('gateway_settings.controller.successfuly_updated') + redirect_to [@gateway, @gateway_setting], :notice => t('gateway_settings.controller.successfuly_updated') else render :edit end end def destroy - @gateway_setting = GatewaySetting.find(params[:id]) + @gateway_setting = @gateway.gateway_settings.find(params[:id]) @gateway_setting.destroy - redirect_to gateway_settings_url, :notice => t('gateway_settings.controller.successfuly_destroyed') + redirect_to gateway_gateway_settings_path(@gateway), :notice => t('gateway_settings.controller.successfuly_destroyed') end end diff --git a/app/models/gateway.rb b/app/models/gateway.rb index 72cf72c..d879fe9 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -14,4 +14,15 @@ class Gateway < ActiveRecord::Base :presence => true, :inclusion => { :in => TECHNOLOGIES } + before_validation :downcase_technology + + def to_s + name + end + + private + def downcase_technology + technology = technology.downcase + end + end diff --git a/app/views/gateway_settings/_index_core.html.haml b/app/views/gateway_settings/_index_core.html.haml index 1b8e443..5b93f16 100644 --- a/app/views/gateway_settings/_index_core.html.haml +++ b/app/views/gateway_settings/_index_core.html.haml @@ -9,9 +9,9 @@ - reset_cycle - for gateway_setting in gateway_settings %tr{:class => cycle('odd', 'even')} - %td= gateway_setting.gateway_id + %td= gateway_setting.gateway %td= gateway_setting.name %td= gateway_setting.value %td= gateway_setting.class_type %td= gateway_setting.description - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gateway_setting} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_setting.gateway, :child_class => gateway_setting} \ No newline at end of file diff --git a/app/views/gateway_settings/show.html.haml b/app/views/gateway_settings/show.html.haml index 4f38e0b..14de6de 100644 --- a/app/views/gateway_settings/show.html.haml +++ b/app/views/gateway_settings/show.html.haml @@ -2,7 +2,7 @@ %p %strong= t('gateway_settings.show.gateway_id') + ":" - = @gateway_setting.gateway_id + = @gateway_setting.gateway %p %strong= t('gateway_settings.show.name') + ":" = @gateway_setting.name @@ -16,4 +16,4 @@ %strong= t('gateway_settings.show.description') + ":" = @gateway_setting.description -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway_setting } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @gateway_setting.gateway, :child_class => @gateway_setting} \ No newline at end of file diff --git a/config/hirb.yml b/config/hirb.yml index f011c9d..da7c083 100644 --- a/config/hirb.yml +++ b/config/hirb.yml @@ -198,4 +198,11 @@ - first_name - user_name - user - + GatewaySetting: + :options: + :fields: + - id + - gateway + - name + - value + - class_type diff --git a/db/schema.rb b/db/schema.rb index a6aae9b..bc51504 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 => 20130112103337) do +ActiveRecord::Schema.define(:version => 20130113090705) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -490,6 +490,36 @@ ActiveRecord::Schema.define(:version => 20130112103337) do t.integer "stop_time", :default => 0, :null => false end + create_table "gateway_parameters", :force => true do |t| + t.integer "gateway_id" + t.string "name" + t.string "value" + t.string "class_type" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "gateway_settings", :force => true do |t| + t.integer "gateway_id" + t.string "name" + t.string "value" + t.string "class_type" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "gateways", :force => true do |t| + t.string "name" + t.string "technology" + t.boolean "inbound" + t.boolean "outbound" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "gemeinschaft_setups", :force => true do |t| t.integer "user_id" t.integer "sip_domain_id" -- cgit v1.2.3 From 57097d16d2a7e86f9e03625fd2fb6796504c32a2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 13 Jan 2013 22:26:28 +0100 Subject: Bugfixes for gateway stuff. --- app/controllers/gateway_parameters_controller.rb | 23 ++++++++++++---------- app/models/gateway_parameter.rb | 8 ++++++-- app/models/gateway_setting.rb | 6 +++++- app/views/gateway_parameters/_form.html.haml | 2 +- app/views/gateway_parameters/_form_core.html.haml | 3 +-- app/views/gateway_parameters/_index_core.html.haml | 4 ++-- app/views/gateway_parameters/index.html.haml | 2 +- app/views/gateway_parameters/show.html.haml | 4 ++-- app/views/gateway_settings/_form_core.html.haml | 2 +- app/views/gateway_settings/_index_core.html.haml | 2 +- app/views/gateway_settings/show.html.haml | 2 +- app/views/gateways/_form_core.html.haml | 2 +- 12 files changed, 35 insertions(+), 25 deletions(-) diff --git a/app/controllers/gateway_parameters_controller.rb b/app/controllers/gateway_parameters_controller.rb index a5066d0..565b575 100644 --- a/app/controllers/gateway_parameters_controller.rb +++ b/app/controllers/gateway_parameters_controller.rb @@ -1,41 +1,44 @@ class GatewayParametersController < ApplicationController + load_and_authorize_resource :gateway + load_and_authorize_resource :gateway_parameter, :through => [:gateway] + def index - @gateway_parameters = GatewayParameter.all + @gateway_parameters = @gateway.gateway_parameters end def show - @gateway_parameter = GatewayParameter.find(params[:id]) + @gateway_parameter = @gateway.gateway_parameters.find(params[:id]) end def new - @gateway_parameter = GatewayParameter.new + @gateway_parameter = @gateway.gateway_parameters.build end def create - @gateway_parameter = GatewayParameter.new(params[:gateway_parameter]) + @gateway_parameter = @gateway.gateway_parameters.build(params[:gateway_parameter]) if @gateway_parameter.save - redirect_to @gateway_parameter, :notice => t('gateway_parameters.controller.successfuly_created') + redirect_to [@gateway, @gateway_parameter], :notice => t('gateway_parameters.controller.successfuly_created') else render :new end end def edit - @gateway_parameter = GatewayParameter.find(params[:id]) + @gateway_parameter = @gateway.gateway_parameters.find(params[:id]) end def update - @gateway_parameter = GatewayParameter.find(params[:id]) + @gateway_parameter = @gateway.gateway_parameters.find(params[:id]) if @gateway_parameter.update_attributes(params[:gateway_parameter]) - redirect_to @gateway_parameter, :notice => t('gateway_parameters.controller.successfuly_updated') + redirect_to [@gateway, @gateway_parameter], :notice => t('gateway_parameters.controller.successfuly_updated') else render :edit end end def destroy - @gateway_parameter = GatewayParameter.find(params[:id]) + @gateway_parameter = @gateway.gateway_parameters.find(params[:id]) @gateway_parameter.destroy - redirect_to gateway_parameters_url, :notice => t('gateway_parameters.controller.successfuly_destroyed') + redirect_to gateway_gateway_parameters_path(@gateway), :notice => t('gateway_parameters.controller.successfuly_destroyed') end end diff --git a/app/models/gateway_parameter.rb b/app/models/gateway_parameter.rb index 1875863..3dd2a95 100644 --- a/app/models/gateway_parameter.rb +++ b/app/models/gateway_parameter.rb @@ -1,13 +1,17 @@ class GatewayParameter < ActiveRecord::Base attr_accessible :gateway_id, :name, :value, :class_type, :description - belongs_to :gateway + belongs_to :gateway, :touch => true validates :name, :presence => true, - :uniqueness => true + :uniqueness => {:scope => :gateway_id} validates :class_type, :presence => true, :inclusion => { :in => ['String', 'Integer', 'Boolean'] } + + def to_s + name + end end diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index bc676a4..078901f 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -5,9 +5,13 @@ class GatewaySetting < ActiveRecord::Base validates :name, :presence => true, - :uniqueness => true + :uniqueness => {:scope => :gateway_id} validates :class_type, :presence => true, :inclusion => { :in => ['String', 'Integer', 'Boolean'] } + + def to_s + name + end end diff --git a/app/views/gateway_parameters/_form.html.haml b/app/views/gateway_parameters/_form.html.haml index 490f2a6..79342d2 100644 --- a/app/views/gateway_parameters/_form.html.haml +++ b/app/views/gateway_parameters/_form.html.haml @@ -1,4 +1,4 @@ -= simple_form_for(@gateway_parameter) do |f| += simple_form_for([@gateway, @gateway_parameter]) do |f| = f.error_notification = render "form_core", :f => f diff --git a/app/views/gateway_parameters/_form_core.html.haml b/app/views/gateway_parameters/_form_core.html.haml index 026e833..ee30238 100644 --- a/app/views/gateway_parameters/_form_core.html.haml +++ b/app/views/gateway_parameters/_form_core.html.haml @@ -1,6 +1,5 @@ .inputs - = f.input :gateway_id, :label => t('gateway_parameters.form.gateway_id.label'), :hint => conditional_hint('gateway_parameters.form.gateway_id.hint') - = f.input :name, :label => t('gateway_parameters.form.name.label'), :hint => conditional_hint('gateway_parameters.form.name.hint') + = f.input :name, :label => t('gateway_parameters.form.name.label'), :hint => conditional_hint('gateway_parameters.form.name.hint'), :autofocus => true = f.input :value, :label => t('gateway_parameters.form.value.label'), :hint => conditional_hint('gateway_parameters.form.value.hint') = f.input :class_type, :label => t('gateway_parameters.form.class_type.label'), :hint => conditional_hint('gateway_parameters.form.class_type.hint') = f.input :description, :label => t('gateway_parameters.form.description.label'), :hint => conditional_hint('gateway_parameters.form.description.hint') diff --git a/app/views/gateway_parameters/_index_core.html.haml b/app/views/gateway_parameters/_index_core.html.haml index 6209f43..3d4b6df 100644 --- a/app/views/gateway_parameters/_index_core.html.haml +++ b/app/views/gateway_parameters/_index_core.html.haml @@ -9,9 +9,9 @@ - reset_cycle - for gateway_parameter in gateway_parameters %tr{:class => cycle('odd', 'even')} - %td= gateway_parameter.gateway_id + %td= gateway_parameter.gateway %td= gateway_parameter.name %td= gateway_parameter.value %td= gateway_parameter.class_type %td= gateway_parameter.description - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gateway_parameter} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_parameter.gateway, :child => gateway_parameter} \ No newline at end of file diff --git a/app/views/gateway_parameters/index.html.haml b/app/views/gateway_parameters/index.html.haml index 1234cff..14b94b0 100644 --- a/app/views/gateway_parameters/index.html.haml +++ b/app/views/gateway_parameters/index.html.haml @@ -3,4 +3,4 @@ - if @gateway_parameters && @gateway_parameters.count > 0 = render "index_core", :gateway_parameters => @gateway_parameters -= render :partial => 'shared/create_link', :locals => {:child_class => GatewayParameter} \ No newline at end of file += render :partial => 'shared/create_link', :locals => {:parent => @gateway, :child_class => GatewayParameter} \ No newline at end of file diff --git a/app/views/gateway_parameters/show.html.haml b/app/views/gateway_parameters/show.html.haml index 87ba10d..982ffac 100644 --- a/app/views/gateway_parameters/show.html.haml +++ b/app/views/gateway_parameters/show.html.haml @@ -2,7 +2,7 @@ %p %strong= t('gateway_parameters.show.gateway_id') + ":" - = @gateway_parameter.gateway_id + = @gateway_parameter.gateway %p %strong= t('gateway_parameters.show.name') + ":" = @gateway_parameter.name @@ -16,4 +16,4 @@ %strong= t('gateway_parameters.show.description') + ":" = @gateway_parameter.description -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway_parameter } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @gateway, :child => @gateway_parameter } \ No newline at end of file diff --git a/app/views/gateway_settings/_form_core.html.haml b/app/views/gateway_settings/_form_core.html.haml index 3880113..90f4eba 100644 --- a/app/views/gateway_settings/_form_core.html.haml +++ b/app/views/gateway_settings/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs - = f.input :name, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint') + = f.input :name, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint'), :autofocus => true = f.input :value, :label => t('gateway_settings.form.value.label'), :hint => conditional_hint('gateway_settings.form.value.hint') = f.input :class_type, :label => t('gateway_settings.form.class_type.label'), :hint => conditional_hint('gateway_settings.form.class_type.hint') = f.input :description, :label => t('gateway_settings.form.description.label'), :hint => conditional_hint('gateway_settings.form.description.hint') diff --git a/app/views/gateway_settings/_index_core.html.haml b/app/views/gateway_settings/_index_core.html.haml index 5b93f16..ca4ce09 100644 --- a/app/views/gateway_settings/_index_core.html.haml +++ b/app/views/gateway_settings/_index_core.html.haml @@ -14,4 +14,4 @@ %td= gateway_setting.value %td= gateway_setting.class_type %td= gateway_setting.description - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_setting.gateway, :child_class => gateway_setting} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_setting.gateway, :child => gateway_setting} \ No newline at end of file diff --git a/app/views/gateway_settings/show.html.haml b/app/views/gateway_settings/show.html.haml index 14de6de..7a9ecc3 100644 --- a/app/views/gateway_settings/show.html.haml +++ b/app/views/gateway_settings/show.html.haml @@ -16,4 +16,4 @@ %strong= t('gateway_settings.show.description') + ":" = @gateway_setting.description -= render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @gateway_setting.gateway, :child_class => @gateway_setting} \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @gateway_setting.gateway, :child => @gateway_setting} \ No newline at end of file diff --git a/app/views/gateways/_form_core.html.haml b/app/views/gateways/_form_core.html.haml index 3545772..13ed8b1 100644 --- a/app/views/gateways/_form_core.html.haml +++ b/app/views/gateways/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs - = f.input :name, :label => t('gateways.form.name.label'), :hint => conditional_hint('gateways.form.name.hint') + = f.input :name, :label => t('gateways.form.name.label'), :hint => conditional_hint('gateways.form.name.hint'), :autofocus => true = f.input :technology, :label => t('gateways.form.technology.label'), :hint => conditional_hint('gateways.form.technology.hint') = f.input :inbound, :label => t('gateways.form.inbound.label'), :hint => conditional_hint('gateways.form.inbound.hint') = f.input :outbound, :label => t('gateways.form.outbound.label'), :hint => conditional_hint('gateways.form.outbound.hint') -- cgit v1.2.3 From 191649e6bad92940fc502582f8fcdd842807b8e1 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 13 Jan 2013 22:55:06 +0100 Subject: Restart FreeSWITCH after initial setup. --- app/controllers/gemeinschaft_setups_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 81faf2a..7205a86 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -46,6 +46,10 @@ class GemeinschaftSetupsController < ApplicationController 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") + # Restart FreeSWITCH + require 'freeswitch_event' + FreeswitchAPI.execute('fsctl', 'shutdown restart') + # Auto-Login: session[:user_id] = user.id -- cgit v1.2.3 From 1ddeac8a2d7066323dc388bfbdf31a005d4e562f Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 13 Jan 2013 23:45:21 +0100 Subject: gateway view display settings/parameters --- app/views/gateways/show.html.haml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml index c9942dd..3460c58 100644 --- a/app/views/gateways/show.html.haml +++ b/app/views/gateways/show.html.haml @@ -16,4 +16,17 @@ %strong= t('gateways.show.description') + ":" = @gateway.description -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway } + + +%h2= t('gateway_settings.index.page_title') +- if @gateway.gateway_settings.any? + = render "gateway_settings/index_core", :gateway_settings => @gateway.gateway_settings + %br += render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewaySetting } + +%h2= t('gateway_parameters.index.page_title') +- if @gateway.gateway_parameters.any? + = render "gateway_parameters/index_core", :gateway_parameters => @gateway.gateway_parameters + %br += render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewayParameter } -- cgit v1.2.3 From 19a2a280765df3118e46f943628a378f1a4984ba Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 00:11:17 +0100 Subject: redirect to gateway view --- app/controllers/gateway_parameters_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/gateway_parameters_controller.rb b/app/controllers/gateway_parameters_controller.rb index 565b575..d5ade9e 100644 --- a/app/controllers/gateway_parameters_controller.rb +++ b/app/controllers/gateway_parameters_controller.rb @@ -17,7 +17,7 @@ class GatewayParametersController < ApplicationController def create @gateway_parameter = @gateway.gateway_parameters.build(params[:gateway_parameter]) if @gateway_parameter.save - redirect_to [@gateway, @gateway_parameter], :notice => t('gateway_parameters.controller.successfuly_created') + redirect_to @gateway, :notice => t('gateway_parameters.controller.successfuly_created') else render :new end @@ -30,7 +30,7 @@ class GatewayParametersController < ApplicationController def update @gateway_parameter = @gateway.gateway_parameters.find(params[:id]) if @gateway_parameter.update_attributes(params[:gateway_parameter]) - redirect_to [@gateway, @gateway_parameter], :notice => t('gateway_parameters.controller.successfuly_updated') + redirect_to @gateway, :notice => t('gateway_parameters.controller.successfuly_updated') else render :edit end @@ -39,6 +39,6 @@ class GatewayParametersController < ApplicationController def destroy @gateway_parameter = @gateway.gateway_parameters.find(params[:id]) @gateway_parameter.destroy - redirect_to gateway_gateway_parameters_path(@gateway), :notice => t('gateway_parameters.controller.successfuly_destroyed') + redirect_to gateway_path(@gateway), :notice => t('gateway_parameters.controller.successfuly_destroyed') end end -- cgit v1.2.3 From 7aac2daa0010293fc27e96f4f767d82ab88abea6 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 00:11:30 +0100 Subject: redirect to gateway view --- app/controllers/gateway_settings_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/gateway_settings_controller.rb b/app/controllers/gateway_settings_controller.rb index 5d9f7e5..4d19b35 100644 --- a/app/controllers/gateway_settings_controller.rb +++ b/app/controllers/gateway_settings_controller.rb @@ -16,7 +16,7 @@ class GatewaySettingsController < ApplicationController def create @gateway_setting = @gateway.gateway_settings.build(params[:gateway_setting]) if @gateway_setting.save - redirect_to [@gateway, @gateway_setting], :notice => t('gateway_settings.controller.successfuly_created') + redirect_to @gateway, :notice => t('gateway_settings.controller.successfuly_created') else render :new end @@ -29,7 +29,7 @@ class GatewaySettingsController < ApplicationController def update @gateway_setting = @gateway.gateway_settings.find(params[:id]) if @gateway_setting.update_attributes(params[:gateway_setting]) - redirect_to [@gateway, @gateway_setting], :notice => t('gateway_settings.controller.successfuly_updated') + redirect_to @gateway, :notice => t('gateway_settings.controller.successfuly_updated') else render :edit end @@ -38,6 +38,6 @@ class GatewaySettingsController < ApplicationController def destroy @gateway_setting = @gateway.gateway_settings.find(params[:id]) @gateway_setting.destroy - redirect_to gateway_gateway_settings_path(@gateway), :notice => t('gateway_settings.controller.successfuly_destroyed') + redirect_to gateway_path(@gateway), :notice => t('gateway_settings.controller.successfuly_destroyed') end end -- cgit v1.2.3 From d0d9b60686a3cc044dc53b626403f799b3d4f703 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 00:13:17 +0100 Subject: gateway_parameter views --- app/models/gateway_parameter.rb | 4 +++- app/views/gateway_parameters/_form_core.html.haml | 2 +- app/views/gateway_parameters/_index_core.html.haml | 6 +----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/gateway_parameter.rb b/app/models/gateway_parameter.rb index 3dd2a95..a66af75 100644 --- a/app/models/gateway_parameter.rb +++ b/app/models/gateway_parameter.rb @@ -1,4 +1,6 @@ class GatewayParameter < ActiveRecord::Base + CLASS_TYPES = ['String', 'Integer', 'Boolean'] + attr_accessible :gateway_id, :name, :value, :class_type, :description belongs_to :gateway, :touch => true @@ -9,7 +11,7 @@ class GatewayParameter < ActiveRecord::Base validates :class_type, :presence => true, - :inclusion => { :in => ['String', 'Integer', 'Boolean'] } + :inclusion => { :in => CLASS_TYPES } def to_s name diff --git a/app/views/gateway_parameters/_form_core.html.haml b/app/views/gateway_parameters/_form_core.html.haml index ee30238..206645d 100644 --- a/app/views/gateway_parameters/_form_core.html.haml +++ b/app/views/gateway_parameters/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs = f.input :name, :label => t('gateway_parameters.form.name.label'), :hint => conditional_hint('gateway_parameters.form.name.hint'), :autofocus => true = f.input :value, :label => t('gateway_parameters.form.value.label'), :hint => conditional_hint('gateway_parameters.form.value.hint') - = f.input :class_type, :label => t('gateway_parameters.form.class_type.label'), :hint => conditional_hint('gateway_parameters.form.class_type.hint') + = f.input :class_type, :collection => GatewayParameter::CLASS_TYPES, :label => t('gateway_parameters.form.class_type.label'), :hint => conditional_hint('gateway_parameters.form.class_type.hint'), :include_blank => false = f.input :description, :label => t('gateway_parameters.form.description.label'), :hint => conditional_hint('gateway_parameters.form.description.hint') diff --git a/app/views/gateway_parameters/_index_core.html.haml b/app/views/gateway_parameters/_index_core.html.haml index 3d4b6df..c22093d 100644 --- a/app/views/gateway_parameters/_index_core.html.haml +++ b/app/views/gateway_parameters/_index_core.html.haml @@ -1,17 +1,13 @@ %table %tr - %th= t('gateway_parameters.index.gateway_id') %th= t('gateway_parameters.index.name') %th= t('gateway_parameters.index.value') - %th= t('gateway_parameters.index.class_type') %th= t('gateway_parameters.index.description') - reset_cycle - for gateway_parameter in gateway_parameters %tr{:class => cycle('odd', 'even')} - %td= gateway_parameter.gateway %td= gateway_parameter.name %td= gateway_parameter.value - %td= gateway_parameter.class_type %td= gateway_parameter.description - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_parameter.gateway, :child => gateway_parameter} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_parameter.gateway, :child => gateway_parameter} -- cgit v1.2.3 From 4670a33c504f36ddb93cf8ed846c65ceb6810c82 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 00:13:45 +0100 Subject: gateway_setting views --- app/models/gateway_setting.rb | 4 +++- app/views/gateway_settings/_form_core.html.haml | 2 +- app/views/gateway_settings/_index_core.html.haml | 6 +----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index 078901f..cf1292d 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -1,4 +1,6 @@ class GatewaySetting < ActiveRecord::Base + CLASS_TYPES = ['String', 'Integer', 'Boolean'] + attr_accessible :gateway_id, :name, :value, :class_type, :description belongs_to :gateway @@ -9,7 +11,7 @@ class GatewaySetting < ActiveRecord::Base validates :class_type, :presence => true, - :inclusion => { :in => ['String', 'Integer', 'Boolean'] } + :inclusion => { :in => CLASS_TYPES } def to_s name diff --git a/app/views/gateway_settings/_form_core.html.haml b/app/views/gateway_settings/_form_core.html.haml index 90f4eba..3d93509 100644 --- a/app/views/gateway_settings/_form_core.html.haml +++ b/app/views/gateway_settings/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs = f.input :name, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint'), :autofocus => true = f.input :value, :label => t('gateway_settings.form.value.label'), :hint => conditional_hint('gateway_settings.form.value.hint') - = f.input :class_type, :label => t('gateway_settings.form.class_type.label'), :hint => conditional_hint('gateway_settings.form.class_type.hint') + = f.input :class_type, :collection => GatewaySetting::CLASS_TYPES, :label => t('gateway_settings.form.class_type.label'), :hint => conditional_hint('gateway_settings.form.class_type.hint'), :include_blank => false = f.input :description, :label => t('gateway_settings.form.description.label'), :hint => conditional_hint('gateway_settings.form.description.hint') diff --git a/app/views/gateway_settings/_index_core.html.haml b/app/views/gateway_settings/_index_core.html.haml index ca4ce09..40946f5 100644 --- a/app/views/gateway_settings/_index_core.html.haml +++ b/app/views/gateway_settings/_index_core.html.haml @@ -1,17 +1,13 @@ %table %tr - %th= t('gateway_settings.index.gateway_id') %th= t('gateway_settings.index.name') %th= t('gateway_settings.index.value') - %th= t('gateway_settings.index.class_type') %th= t('gateway_settings.index.description') - reset_cycle - for gateway_setting in gateway_settings %tr{:class => cycle('odd', 'even')} - %td= gateway_setting.gateway %td= gateway_setting.name %td= gateway_setting.value - %td= gateway_setting.class_type %td= gateway_setting.description - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_setting.gateway, :child => gateway_setting} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => gateway_setting.gateway, :child => gateway_setting} -- cgit v1.2.3 From da861ac74a66bf3a8a13613bab5e6c72d487edb7 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 14 Jan 2013 08:17:17 +0100 Subject: Bugfix. #99 --- app/models/gateway.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/gateway.rb b/app/models/gateway.rb index d879fe9..01309e6 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -22,7 +22,7 @@ class Gateway < ActiveRecord::Base private def downcase_technology - technology = technology.downcase + technology = technology.downcase if !technology.blank? end end -- cgit v1.2.3 From f22d65c6fc22b8c60965c318dbeab919ec62aae6 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 14 Jan 2013 08:18:47 +0100 Subject: Bugfix #99 --- app/models/gateway.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/gateway.rb b/app/models/gateway.rb index 01309e6..21dc831 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -22,7 +22,7 @@ class Gateway < ActiveRecord::Base private def downcase_technology - technology = technology.downcase if !technology.blank? + self.technology = self.technology.downcase if !self.technology.blank? end end -- cgit v1.2.3 From 24a60c41586dbfa64da30acea1749376bebbef46 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 09:47:22 +0100 Subject: register setting --- misc/freeswitch/scripts/common/gateway.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 2c50c0f..9c09a22 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -108,6 +108,10 @@ function Gateway.parameters_build(self, gateway_id) parameters.register = true; end + if not common.str.blank(settings.register) then + parameters.register = common.str.to_b(settings.register); + end + if common.str.blank(settings.password) then parameters.password = 'gateway' .. gateway_id; else -- cgit v1.2.3 From effdf42ddf751d3973b44465168078344a414982 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 09:47:51 +0100 Subject: available gateway_settings --- app/models/gateway_setting.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index cf1292d..cb430d1 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -1,5 +1,8 @@ class GatewaySetting < ActiveRecord::Base CLASS_TYPES = ['String', 'Integer', 'Boolean'] + GATEWAY_SETTINGS = { + 'sip' => { 'domain' => 'String', 'username' => 'String', 'password' => 'String', 'register' => 'Boolean' }, + } attr_accessible :gateway_id, :name, :value, :class_type, :description -- cgit v1.2.3 From ece6303fa2a5aad373fdd4f1393366b846fd374e Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 09:48:24 +0100 Subject: save class_type --- app/controllers/gateway_settings_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/gateway_settings_controller.rb b/app/controllers/gateway_settings_controller.rb index 4d19b35..0304411 100644 --- a/app/controllers/gateway_settings_controller.rb +++ b/app/controllers/gateway_settings_controller.rb @@ -15,6 +15,7 @@ class GatewaySettingsController < ApplicationController def create @gateway_setting = @gateway.gateway_settings.build(params[:gateway_setting]) + @gateway_setting.class_type = GatewaySetting::GATEWAY_SETTINGS[@gateway.technology][@gateway_setting.name] if @gateway_setting.save redirect_to @gateway, :notice => t('gateway_settings.controller.successfuly_created') else -- cgit v1.2.3 From cb5fdade73a9e06ce25cb0c688ac9be4ea7f1e49 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 09:48:46 +0100 Subject: make gateway_parameters less prominent --- app/views/gateways/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml index 3460c58..ebf75a5 100644 --- a/app/views/gateways/show.html.haml +++ b/app/views/gateways/show.html.haml @@ -25,8 +25,8 @@ %br = render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewaySetting } -%h2= t('gateway_parameters.index.page_title') - if @gateway.gateway_parameters.any? + %h2= t('gateway_parameters.index.page_title') = render "gateway_parameters/index_core", :gateway_parameters => @gateway.gateway_parameters %br = render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewayParameter } -- cgit v1.2.3 From 9452ebcbe1f04d15105e1cd21890cd1a60cdeb8f Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 09:49:43 +0100 Subject: selection --- app/views/gateway_settings/_form_core.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/gateway_settings/_form_core.html.haml b/app/views/gateway_settings/_form_core.html.haml index 3d93509..3e7dc49 100644 --- a/app/views/gateway_settings/_form_core.html.haml +++ b/app/views/gateway_settings/_form_core.html.haml @@ -1,5 +1,4 @@ .inputs - = f.input :name, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint'), :autofocus => true + = f.input :name, :collection => GatewaySetting::GATEWAY_SETTINGS['sip'].keys, :label => t('gateway_settings.form.name.label'), :hint => conditional_hint('gateway_settings.form.name.hint'), :autofocus => true, :include_blank => false = f.input :value, :label => t('gateway_settings.form.value.label'), :hint => conditional_hint('gateway_settings.form.value.hint') - = f.input :class_type, :collection => GatewaySetting::CLASS_TYPES, :label => t('gateway_settings.form.class_type.label'), :hint => conditional_hint('gateway_settings.form.class_type.hint'), :include_blank => false = f.input :description, :label => t('gateway_settings.form.description.label'), :hint => conditional_hint('gateway_settings.form.description.hint') -- cgit v1.2.3 From d23a161907f64421a6d49b9867859d519188281c Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 17:13:05 +0100 Subject: allow header based authentication for gateways --- app/models/gateway_setting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index cb430d1..96410f4 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -1,7 +1,7 @@ class GatewaySetting < ActiveRecord::Base CLASS_TYPES = ['String', 'Integer', 'Boolean'] GATEWAY_SETTINGS = { - 'sip' => { 'domain' => 'String', 'username' => 'String', 'password' => 'String', 'register' => 'Boolean' }, + 'sip' => { 'domain' => 'String', 'username' => 'String', 'password' => 'String', 'register' => 'Boolean', 'auth_source' => 'String', 'auth_pattern' => 'String' }, } attr_accessible :gateway_id, :name, :value, :class_type, :description -- cgit v1.2.3 From 64c8b78bbf5880c2b8948cf7588ffe7d0a843357 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 17:15:02 +0100 Subject: display contacht host --- misc/freeswitch/scripts/dialplan_default.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 91ad4e4..1c0a52e 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -42,7 +42,7 @@ start_caller:init_channel_variables(); -- session:execute('info','notice'); if not start_dialplan:check_auth() then - log:debug('AUTHENTICATION_REQUIRED - domain: ', start_dialplan.domain); + log:debug('AUTHENTICATION_REQUIRED - host: ' , start_caller.sip_contact_host, ', domain: ', start_dialplan.domain); start_dialplan:hangup(407, start_dialplan.domain); return false; end -- cgit v1.2.3 From e0064941bc73303e83f1fbd9374c3a731b1d3c0b Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 17:15:51 +0100 Subject: allow header based authentication --- misc/freeswitch/scripts/common/gateway.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 9c09a22..9cddd7c 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -61,6 +61,28 @@ function Gateway.find_by_name(self, name) end +function Gateway.authenticate(self, technology, caller) + local sql_query = 'SELECT `c`.`name`, `c`.`id`, `a`.`value` `auth_source`, `b`.`value` `auth_pattern` \ + FROM `gateway_settings` `a` \ + INNER JOIN `gateway_settings` `b` \ + ON (`a`.`gateway_id` = `b`.`gateway_id` AND `a`.`name` = "auth_source" AND `b`.`name` = "auth_pattern" ) \ + LEFT JOIN `gateways` `c` \ + ON (`a`.`gateway_id` = `c`.`id`) \ + WHERE `c`.`inbound` IS TRUE AND `c`.`technology` = "' .. tostring(technology) .. '"'; + + local gateway = false; + + self.database:query(sql_query, function(entry) + if caller:to_s(entry.auth_source):match(entry.auth_pattern) then + gateway = entry; + return; + end + end) + + return gateway; +end + + function Gateway.profile_get(self, gateway_id) local sql_query = 'SELECT `value` FROM `gateway_settings` WHERE `gateway_id` = ' .. tonumber(gateway_id) .. ' AND `name` = "profile" LIMIT 1'; -- cgit v1.2.3 From 9292aa909881b7f21192f9278b8ce5eb8fe442de Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 17:16:38 +0100 Subject: allow header based authentication --- misc/freeswitch/scripts/dialplan/dialplan.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 07b8f4f..aa6b8c8 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -127,17 +127,15 @@ function Dialplan.check_auth(self) self.log:info('AUTH_FIRST_STAGE - gateway autheticated by name/password: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name); authenticated = true; else - local gateways = common.configuration_file.get('/opt/freeswitch/scripts/ini/gateways.ini', false); - if not gateways then - return false; - end - for gateway, gateway_parameters in pairs(gateways) do - if common.str.to_s(gateway_parameters.proxy) == self.caller.sip_contact_host then - self.caller.gateway_name = gateway; - self.caller.from_gateway = true; - self.log:info('AUTH_FIRST_STAGE - gateway autheticated by ip: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name, ', ip: ', self.caller.sip_contact_host); - authenticated = true; - end + require 'common.gateway' + local gateway = common.gateway.Gateway:new{ log = self.log, database = self.database}:authenticate('sip', self.caller); + + if gateway then + self.caller.gateway_name = gateway.name; + self.caller.gateway_id = gateway.id; + self.caller.from_gateway = true; + self.log:info('AUTH_FIRST_STAGE - gateway autheticated by ip: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name, ', ip: ', self.caller.sip_contact_host); + authenticated = true; end end @@ -876,6 +874,10 @@ function Dialplan.run(self, destination) end end + require 'dialplan.router' + local router = dialplan.router.Router:new{ log = self.log, database = self.database }; + router:table_load(); + self.routes = common.configuration_file.get('/opt/freeswitch/scripts/ini/routes.ini'); self.caller.domain_local = self.domain; self:retrieve_caller_data(); -- cgit v1.2.3 From 5ad2029e3e9beb4d581940a440d5a2ac455a163e Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 17:19:51 +0100 Subject: premature inclusion removed --- misc/freeswitch/scripts/dialplan/dialplan.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index aa6b8c8..2c6f4e0 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -874,10 +874,6 @@ function Dialplan.run(self, destination) end end - require 'dialplan.router' - local router = dialplan.router.Router:new{ log = self.log, database = self.database }; - router:table_load(); - self.routes = common.configuration_file.get('/opt/freeswitch/scripts/ini/routes.ini'); self.caller.domain_local = self.domain; self:retrieve_caller_data(); -- cgit v1.2.3 From 160a510a6638b1e58f6460ae9c03ab64ef6ced75 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 14 Jan 2013 17:31:31 +0100 Subject: log line --- misc/freeswitch/scripts/dialplan/dialplan.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 2c6f4e0..3073aca 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -134,7 +134,7 @@ function Dialplan.check_auth(self) self.caller.gateway_name = gateway.name; self.caller.gateway_id = gateway.id; self.caller.from_gateway = true; - self.log:info('AUTH_FIRST_STAGE - gateway autheticated by ip: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name, ', ip: ', self.caller.sip_contact_host); + self.log:info('AUTH_FIRST_STAGE - gateway autheticated by: ', gateway.auth_source, ' ~ ', gateway.auth_pattern, ', gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name, ', ip: ', self.caller.sip_contact_host); authenticated = true; end end -- cgit v1.2.3 From 857f3de83628c1de8d1c65ce2aea36ab7bd8e8c5 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 12:28:21 +0100 Subject: gateway settings added --- app/models/gateway_setting.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index 96410f4..c01f0a8 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -1,7 +1,16 @@ class GatewaySetting < ActiveRecord::Base CLASS_TYPES = ['String', 'Integer', 'Boolean'] GATEWAY_SETTINGS = { - 'sip' => { 'domain' => 'String', 'username' => 'String', 'password' => 'String', 'register' => 'Boolean', 'auth_source' => 'String', 'auth_pattern' => 'String' }, + 'sip' => { + 'domain' => 'String', + 'username' => 'String', + 'password' => 'String', + 'contact' => 'String', + 'register' => 'Boolean', + 'auth_source' => 'String', + 'auth_pattern' => 'String', + 'number_source' => 'String', + }, } attr_accessible :gateway_id, :name, :value, :class_type, :description -- cgit v1.2.3 From 82ab2c07fbc494bad3ffdde30dbb3ce0d98c4e19 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 12:29:12 +0100 Subject: gateway settings --- misc/freeswitch/scripts/common/gateway.lua | 32 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 9cddd7c..6e9fbfb 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -32,32 +32,22 @@ function Gateway.list(self, technology) end -function Gateway.find_by_sql(self, where) - local sql_query = 'SELECT * FROM `gateways` WHERE ' .. where .. ' LIMIT 1'; +function Gateway.find_by_id(self, id) + local sql_query = 'SELECT * FROM `gateways` WHERE `id`= ' .. tonumber(id) .. ' LIMIT 1'; local gateway = nil; self.database:query(sql_query, function(entry) gateway = Gateway:new(self); gateway.record = entry; gateway.id = tonumber(entry.id); - gateway.uuid = entry.uuid; + gateway.name = entry.name; end) - return gateway; -end - - --- find gateway by id -function Gateway.find_by_id(self, id) - local sql_query = '`id`= ' .. tonumber(id); - return self:find_by_sql(sql_query); -end - --- find gateway name -function Gateway.find_by_name(self, name) - local sql_query = '`name`= "' .. name .. '"'; + if gateway then + gateway.settings = self:config_table_get('gateway_settings', gateway.id); + end - return self:find_by_sql(sql_query); + return gateway; end @@ -140,6 +130,14 @@ function Gateway.parameters_build(self, gateway_id) parameters.password = settings.password; end + parameters['extension-in-contact'] = true; + + if common.str.blank(settings.contact) then + parameters['extension'] = 'gateway' .. gateway_id; + else + parameters['extension'] = settings.contact; + end + for key, value in pairs(self:config_table_get('gateway_parameters', gateway_id)) do parameters[key] = value; end -- cgit v1.2.3 From 4ce6146b0883fd9f7557d6ccf118a4dac7adbbe9 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 12:29:38 +0100 Subject: retrieve sip_network_ip --- misc/freeswitch/scripts/dialplan/session.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/freeswitch/scripts/dialplan/session.lua b/misc/freeswitch/scripts/dialplan/session.lua index 7174b24..20fef88 100644 --- a/misc/freeswitch/scripts/dialplan/session.lua +++ b/misc/freeswitch/scripts/dialplan/session.lua @@ -46,6 +46,7 @@ function Session.init_channel_variables(self) self.account_uuid = self:to_s('gs_account_uuid'); self.account_type = self:to_s('gs_account_type'); self.sip_contact_host = self:to_s('sip_contact_host'); + self.sip_network_ip = self:to_s('sip_network_ip'); self.clir = self:to_b('gs_clir'); self.call_timeout = self:to_i('gs_call_timeout'); self.auth_account_type = self:to_s('gs_auth_account_type'); -- cgit v1.2.3 From b713c19f0a7727a14b5ea4d72f8ddaaf01736027 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 12:30:29 +0100 Subject: tweaking authentication --- misc/freeswitch/scripts/dialplan/dialplan.lua | 70 +++++++++++---------------- misc/freeswitch/scripts/dialplan_default.lua | 29 ++++++++--- 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 3073aca..88670ca 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -113,55 +113,34 @@ function Dialplan.hangup(self, code, phrase, cause) end -function Dialplan.check_auth(self) - local authenticated = false; - - require 'common.str' - if self.caller.from_node then - self.log:info('AUTH_FIRST_STAGE - node authenticated - node_id: ', self.caller.node_id); - authenticated = true; - elseif not common.str.blank(self.caller.auth_account_type) then - self.log:info('AUTH_FIRST_STAGE - sipaccount autheticated by name/password: ', self.caller.auth_account_type, '=', self.caller.account_id, '/', self.caller.account_uuid); - authenticated = true; - elseif self.caller.from_gateway then - self.log:info('AUTH_FIRST_STAGE - gateway autheticated by name/password: gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name); - authenticated = true; - else - require 'common.gateway' - local gateway = common.gateway.Gateway:new{ log = self.log, database = self.database}:authenticate('sip', self.caller); - - if gateway then - self.caller.gateway_name = gateway.name; - self.caller.gateway_id = gateway.id; - self.caller.from_gateway = true; - self.log:info('AUTH_FIRST_STAGE - gateway autheticated by: ', gateway.auth_source, ' ~ ', gateway.auth_pattern, ', gateway=', self.caller.gateway_id, ', name: ', self.caller.gateway_name, ', ip: ', self.caller.sip_contact_host); - authenticated = true; - end - end - - return authenticated; -end - - -function Dialplan.check_auth_node(self) +function Dialplan.auth_node(self) require 'common.node' local node = common.node.Node:new{ log = self.log, database = self.database }:find_by_address(self.caller.sip_contact_host); - return (node ~= nil); + if node then + self.log:info('AUTH_NODE - node_id: ', self.caller.node_id, ', contact address:', self.caller.sip_contact_host); + return true; + end end -function Dialplan.check_auth_ip(self) - self.log:info('AUTH - node: ', self.caller.from_node, ', auth_account: ', self.caller.auth_account_type, ', gateway: ', self.caller.from_gateway); +function Dialplan.auth_sip_account(self) require 'common.str' - if self.caller.from_node then + if not common.str.blank(self.caller.auth_account_type) then + self.log:info('AUTH_SIP_ACCOUNT - ', self.caller.auth_account_type, '=', self.caller.account_id, '/', self.caller.account_uuid); return true; - elseif not common.str.blank(self.caller.auth_account_type) then - return true; - elseif self.caller.from_gateway then - return true; - else - return nil; + end +end + + +function Dialplan.auth_gateway(self) + require 'common.gateway' + local gateway_class = common.gateway.Gateway:new{ log = self.log, database = self.database}; + local gateway = gateway_class:authenticate('sip', self.caller); + + if gateway then + log:info('AUTH_GATEWAY - ', gateway.auth_source, ' ~ ', gateway.auth_pattern, ', gateway=', gateway.id, ', name: ', gateway.name, ', ip: ', self.caller.sip_contact_host); + return gateway_class:find_by_id(gateway.id); end end @@ -859,6 +838,8 @@ end function Dialplan.run(self, destination) + require 'common.str'; + self.caller:set_variable('hangup_after_bridge', false); self.caller:set_variable('bridge_early_media', 'true'); self.caller:set_variable('default_language', self.default_language); @@ -882,7 +863,12 @@ function Dialplan.run(self, destination) require 'dialplan.route' local route = nil; - if self.caller.from_gateway then + if self.caller.gateway then + if not common.str.blank(self.caller.gateway.settings.number_source) then + self.log:debug('INBOUND_NUMBER: number_source: ', self.caller.gateway.settings.number_source, ', number: ', self.caller:to_s(self.caller.gateway.settings.number_source)); + self.caller.destination_number = self.caller:to_s(self.caller.gateway.settings.number_source); + end + local route_object = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = self.routes }; route = route_object:inbound(self.caller, self.caller.destination_number); local inbound_caller_id_number = route_object:inbound_cid_number(self.caller, self.caller.gateway_name, 'gateway'); diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 1c0a52e..42271b9 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -34,20 +34,37 @@ end -- dialplan object require 'dialplan.dialplan' -start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database }; +local start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database }; start_dialplan:configuration_read(); start_caller.local_node_id = start_dialplan.node_id; start_caller:init_channel_variables(); -- session:execute('info','notice'); -if not start_dialplan:check_auth() then - log:debug('AUTHENTICATION_REQUIRED - host: ' , start_caller.sip_contact_host, ', domain: ', start_dialplan.domain); - start_dialplan:hangup(407, start_dialplan.domain); - return false; +if start_caller.from_node and not start_dialplan:auth_node() then + log:debug('DIALPLAN_DEFAULT - node unauthorized - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); + start_dialplan:hangup(401, start_dialplan.domain); +else + if not start_dialplan:auth_sip_account() then + local gateway = start_dialplan:auth_gateway() + + if gateway then + start_caller.gateway_name = gateway.name; + start_caller.gateway_id = gateway.id; + start_caller.from_gateway = true; + start_caller.gateway = gateway; + else + log:debug('AUTHENTICATION_REQUIRED_SIP_ACCOUNT - contact host: ' , start_caller.sip_contact_host, ', ip: ', start_caller.sip_network_ip, ', domain: ', start_dialplan.domain); + start_dialplan:hangup(407, start_dialplan.domain); + if database then + database:release(); + end + return; + end + end end -if start_caller.from_node and not start_dialplan:check_auth_node() then +if start_caller.from_node then log:debug('AUTHENTICATION_REQUIRED_NODE - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); start_dialplan:hangup(407, start_dialplan.domain); else -- cgit v1.2.3 From 042e13773647764c4f55b5e60008ce96c45e34d5 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 13:52:10 +0100 Subject: locales --- config/locales/views/gateway_settings/de.yml | 26 +++++++++++++------------- config/locales/views/gateway_settings/en.yml | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/config/locales/views/gateway_settings/de.yml b/config/locales/views/gateway_settings/de.yml index b008e5e..698a81a 100644 --- a/config/locales/views/gateway_settings/de.yml +++ b/config/locales/views/gateway_settings/de.yml @@ -1,42 +1,42 @@ de: gateway_settings: - name: 'Gatewaysetting' + name: 'Gateway Einstellungen' controller: - successfuly_created: 'Gatewaysetting wurde angelegt.' - successfuly_updated: 'Gatewaysetting wurde aktualisiert.' - successfuly_destroyed: 'Gatewaysetting wurde gelöscht.' + successfuly_created: 'Gateway Einstellung wurde angelegt.' + successfuly_updated: 'Gateway Einstellung wurde aktualisiert.' + successfuly_destroyed: 'Gateway Einstellung wurde gelöscht.' index: - page_title: 'Übersicht von Gatewaysetting' + page_title: 'Gateway Einstellungen' gateway_id: 'Gateway' name: 'Name' value: 'Value' class_type: 'Class type' - description: 'Description' + description: 'Beschreibung' actions: - confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Gatewaysetting' + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Gateway Einstellungen' destroy: 'Löschen' edit: 'Bearbeiten' show: 'Anzeigen' create: 'Neu anlegen' - create_for: 'Gatewaysetting neu anlegen für %{resource}' + create_for: 'Gateway Einstellungen neu anlegen für %{resource}' show: - page_title: 'Gatewaysetting bearbeiten' + page_title: 'Gateway Einstellungen bearbeiten' gateway_id: 'Gateway' name: 'Name' value: 'Value' class_type: 'Class type' - description: 'Description' + description: 'Beschreibung' actions: confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' destroy: 'Löschen' edit: 'Bearbeiten' view_all: 'Alle anzeigen' new: - page_title: 'Gatewaysetting neu anlegen' + page_title: 'Gateway Einstellungen neu anlegen' actions: back_to_list: 'Zurück zur Übersicht' edit: - page_title: 'Gatewaysetting bearbeiten' + page_title: 'Gateway Einstellungen bearbeiten' actions: back_to_list: 'Zurück zur Übersicht' edit: 'Bearbeiten' @@ -55,6 +55,6 @@ de: label: 'Class type' hint: '' description: - label: 'Description' + label: 'Beschreibung' hint: '' button: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/gateway_settings/en.yml b/config/locales/views/gateway_settings/en.yml index 3072eb9..63c1609 100644 --- a/config/locales/views/gateway_settings/en.yml +++ b/config/locales/views/gateway_settings/en.yml @@ -2,23 +2,23 @@ en: gateway_settings: name: 'Gatewaysetting' controller: - successfuly_created: 'Successfully created Gatewaysetting.' - successfuly_updated: 'Successfully updated Gatewaysetting.' - successfuly_destroyed: 'Successfully destroyed Gatewaysetting.' + successfuly_created: 'Successfully created entry.' + successfuly_updated: 'Successfully updated entry.' + successfuly_destroyed: 'Successfully destroyed entry.' index: - page_title: 'Listing Gatewaysetting' + page_title: 'Gateway settings' gateway_id: 'Gateway' name: 'Name' value: 'Value' class_type: 'Class type' description: 'Description' actions: - confirm: 'Are you sure you want to delete this Gatewaysetting?' + confirm: 'Are you sure you want to delete this entry?' destroy: 'Delete' edit: 'Edit' show: 'View' create: 'New' - create_for: 'New Gatewaysetting for %{resource}' + create_for: 'New settings entry for %{resource}' show: page_title: 'Show Gatewaysetting' gateway_id: 'Gateway' @@ -32,11 +32,11 @@ en: edit: 'Edit' view_all: 'View All' new: - page_title: 'New Gatewaysetting' + page_title: 'New Gateway settings entry' actions: back_to_list: 'Back to Index' edit: - page_title: 'Editing Gatewaysetting' + page_title: 'Editing Gateway settings' actions: back_to_list: 'Back to Index' edit: 'Edit' -- cgit v1.2.3 From f984b76b33c4a371f5c34eab4399b21caeabbff9 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 13:58:09 +0100 Subject: locales --- config/locales/views/gateways/de.yml | 3 ++- config/locales/views/gateways/en.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/locales/views/gateways/de.yml b/config/locales/views/gateways/de.yml index cfe5615..28bc46c 100644 --- a/config/locales/views/gateways/de.yml +++ b/config/locales/views/gateways/de.yml @@ -20,7 +20,8 @@ de: create: 'Neu anlegen' create_for: 'Gateway neu anlegen für %{resource}' show: - page_title: 'Gateway bearbeiten' + page_title: 'Gateway' + id: 'ID' name: 'Name' technology: 'Technology' inbound: 'Inbound' diff --git a/config/locales/views/gateways/en.yml b/config/locales/views/gateways/en.yml index 2abf0f2..7732da1 100644 --- a/config/locales/views/gateways/en.yml +++ b/config/locales/views/gateways/en.yml @@ -20,7 +20,8 @@ en: create: 'New' create_for: 'New Gateway for %{resource}' show: - page_title: 'Show Gateway' + page_title: 'Gateway' + id: 'ID' name: 'Name' technology: 'Technology' inbound: 'Inbound' -- cgit v1.2.3 From a248db30eb469f1fd99508df0cfbf47c4ad80b8c Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 15 Jan 2013 14:00:19 +0100 Subject: display id --- app/views/gateways/show.html.haml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml index ebf75a5..a9b0d18 100644 --- a/app/views/gateways/show.html.haml +++ b/app/views/gateways/show.html.haml @@ -1,5 +1,8 @@ - title t("gateways.show.page_title") +%p + %strong= t('gateways.show.id') + ":" + = @gateway.id %p %strong= t('gateways.show.name') + ":" = @gateway.name @@ -19,14 +22,14 @@ = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway } -%h2= t('gateway_settings.index.page_title') +%h3= t('gateway_settings.index.page_title') - if @gateway.gateway_settings.any? = render "gateway_settings/index_core", :gateway_settings => @gateway.gateway_settings %br = render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewaySetting } - if @gateway.gateway_parameters.any? - %h2= t('gateway_parameters.index.page_title') + %h3= t('gateway_parameters.index.page_title') = render "gateway_parameters/index_core", :gateway_parameters => @gateway.gateway_parameters %br = render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewayParameter } -- cgit v1.2.3 From 801f53f49f5440acaeba70c65df8d3e611c0b4c4 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 17:24:13 +0100 Subject: Fixed not rendered link to create a new SIP account. --- app/views/tenants/_sip_accounts_and_phones.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml index f9d26f9..618236f 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -18,7 +18,7 @@ =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} + = 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') -- cgit v1.2.3 From 2928e0342ef45d5b6ecf27faf2940b424c8bd513 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 17:24:38 +0100 Subject: Temporarily fix. @span needs to have a look here. --- app/controllers/gemeinschaft_setups_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 7205a86..89a82cb 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -47,8 +47,8 @@ class GemeinschaftSetupsController < ApplicationController GsParameter.where(:name => 'user_image_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}/uploads/user/image") # Restart FreeSWITCH - require 'freeswitch_event' - FreeswitchAPI.execute('fsctl', 'shutdown restart') + # require 'freeswitch_event' + # FreeswitchAPI.execute('fsctl', 'shutdown restart') # Auto-Login: session[:user_id] = user.id -- cgit v1.2.3 From bdad29d001523a2ba4f515e6202babaa61739fc9 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 18:02:06 +0100 Subject: Refactoring and caching. --- app/views/tenants/_admin_area.de.html.haml | 6 ++ app/views/tenants/_admin_area.html.haml | 7 +- app/views/tenants/_gs_parameter_table.html.haml | 24 ++++++ app/views/tenants/_table_of_functions.html.haml | 98 +++++++++++------------ app/views/tenants/_table_of_phone_books.html.haml | 1 - 5 files changed, 81 insertions(+), 55 deletions(-) create mode 100644 app/views/tenants/_gs_parameter_table.html.haml diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index d111c9d..4b8a9e6 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -27,8 +27,14 @@ = succeed '.' do =link_to manufacturer, manufacturer_path(manufacturer) +%h2 Admin Bereich = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +%h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} +%h2 Gemeinschaft Konfiguration += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} + +%h2=t("phone_books.index.page_title") = 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 b479995..b1b17a3 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -26,9 +26,14 @@ = succeed '.' do =link_to manufacturer, manufacturer_path(manufacturer) +%h2 Admin Area = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +%h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} -= render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} +%h2 Gemeinschaft Configuration += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} +%h2=t("phone_books.index.page_title") += render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} \ No newline at end of file diff --git a/app/views/tenants/_gs_parameter_table.html.haml b/app/views/tenants/_gs_parameter_table.html.haml new file mode 100644 index 0000000..7663f46 --- /dev/null +++ b/app/views/tenants/_gs_parameter_table.html.haml @@ -0,0 +1,24 @@ +- cache([I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do + %table + %tr{:class => 'even'} + %th + Funktion + %th + Anzahl + %th + Letztes Update + + %tr{:class => 'odd'} + %td + = t("gui_functions.name") + %td + = link_to GuiFunction.count.to_s, gui_functions_path + %td + = l GuiFunction.order(:updated_at).last.updated_at, :format => :short + %tr{:class => 'even'} + %td + = t("gs_parameters.name") + %td + = link_to GsParameter.count.to_s, gs_parameters_path + %td + = l GsParameter.order(:updated_at).last.updated_at, :format => :short diff --git a/app/views/tenants/_table_of_functions.html.haml b/app/views/tenants/_table_of_functions.html.haml index 79ea2b1..ef2a2d0 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).last]) do +- cache([I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last, tenant.conferences.count, tenant.conferences.order(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do %table %tr{:class => 'even'} %th @@ -6,55 +6,47 @@ %th Anzahl %th - %tr{:class => 'odd'} - %td - = t("callthroughs.name") - %td - - if tenant.callthroughs.any? - = link_to tenant.callthroughs.count.to_s, tenant_callthroughs_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Callthrough} - %tr{:class => 'even'} - %td - = t("conferences.name") - %td - - if tenant.conferences.any? - = link_to tenant.conferences.count.to_s, tenant_conferences_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Conference} - %tr{:class => 'odd'} - %td - = t("hunt_groups.name") - %td - - if tenant.hunt_groups.any? - = link_to tenant.hunt_groups.count.to_s, tenant_hunt_groups_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => HuntGroup} - %tr{:class => 'even'} - %td - = t("automatic_call_distributors.name") - %td - - if tenant.automatic_call_distributors.any? - = link_to tenant.automatic_call_distributors.count.to_s, tenant_automatic_call_distributors_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => AutomaticCallDistributor} - %tr{:class => 'odd'} - %td - = t("gui_functions.name") - %td - = link_to GuiFunction.count.to_s, gui_functions_path - %td - %tr{:class => 'even'} - %td - = t("gs_parameters.name") - %td - = link_to GsParameter.count.to_s, gs_parameters_path - %td \ No newline at end of file + - cache([I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last]) do + %tr{:class => 'odd'} + %td + = t("callthroughs.name") + %td + - if tenant.callthroughs.any? + = link_to tenant.callthroughs.count.to_s, tenant_callthroughs_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Callthrough} + - cache([I18n.locale, tenant, tenant.conferences.count, tenant.conferences.order(:updated_at).last]) do + %tr{:class => 'even'} + %td + = t("conferences.name") + %td + - if tenant.conferences.any? + = link_to tenant.conferences.count.to_s, tenant_conferences_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Conference} + - cache([I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last]) do + %tr{:class => 'odd'} + %td + = t("hunt_groups.name") + %td + - if tenant.hunt_groups.any? + = link_to tenant.hunt_groups.count.to_s, tenant_hunt_groups_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => HuntGroup} + - cache([I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do + %tr{:class => 'even'} + %td + = t("automatic_call_distributors.name") + %td + - if tenant.automatic_call_distributors.any? + = link_to tenant.automatic_call_distributors.count.to_s, tenant_automatic_call_distributors_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => AutomaticCallDistributor} \ No newline at end of file diff --git a/app/views/tenants/_table_of_phone_books.html.haml b/app/views/tenants/_table_of_phone_books.html.haml index 811fe26..a963bf4 100644 --- a/app/views/tenants/_table_of_phone_books.html.haml +++ b/app/views/tenants/_table_of_phone_books.html.haml @@ -3,6 +3,5 @@ -# - if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) - if can?( :index, PhoneBook ) - %h2=t("phone_books.index.page_title") = render "phone_books/index_core", :phone_books => tenant.phone_books = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => PhoneBook} \ No newline at end of file -- cgit v1.2.3 From 8cea5d1c88e2e13ed99a5c54a1e1b69a5d6a2d01 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 19:05:01 +0100 Subject: Refactoring users#view and added caching. --- app/models/phone_book_entry.rb | 2 +- app/views/users/_conferences.html.haml | 7 ++ app/views/users/_fax_accounts.html.haml | 7 ++ app/views/users/_phone_books.html.haml | 7 ++ app/views/users/_phones.html.haml | 7 ++ app/views/users/_sip_accounts.html.haml | 7 ++ app/views/users/_tenants.html.haml | 5 ++ app/views/users/_user_groups.html.haml | 8 ++ app/views/users/show.html.haml | 128 ++++++++++++-------------------- 9 files changed, 95 insertions(+), 83 deletions(-) create mode 100644 app/views/users/_conferences.html.haml create mode 100644 app/views/users/_fax_accounts.html.haml create mode 100644 app/views/users/_phone_books.html.haml create mode 100644 app/views/users/_phones.html.haml create mode 100644 app/views/users/_sip_accounts.html.haml create mode 100644 app/views/users/_tenants.html.haml create mode 100644 app/views/users/_user_groups.html.haml diff --git a/app/models/phone_book_entry.rb b/app/models/phone_book_entry.rb index db2b44b..275c7b6 100644 --- a/app/models/phone_book_entry.rb +++ b/app/models/phone_book_entry.rb @@ -6,7 +6,7 @@ class PhoneBookEntry < ActiveRecord::Base attr_accessible :first_name, :middle_name, :last_name, :title, :nickname, :organization, :is_organization, :department, :job_title, :is_male, :birthday, :birth_name, :description, :homepage_personal, :homepage_organization, :twitter_account, :facebook_account, :google_plus_account, :xing_account, :linkedin_account, :mobileme_account, :image - belongs_to :phone_book + belongs_to :phone_book, :touch => true has_many :conference_invitees, :dependent => :destroy acts_as_list :scope => :phone_book diff --git a/app/views/users/_conferences.html.haml b/app/views/users/_conferences.html.haml new file mode 100644 index 0000000..b9592b6 --- /dev/null +++ b/app/views/users/_conferences.html.haml @@ -0,0 +1,7 @@ +-# Conferences +-# +- if (can?( :index, Conference ) && user.conferences.count > 0 ) || can?( :create, Conference ) + %h2= t('conferences.index.page_title') + - if can?( :index, Conference ) && user.conferences.count > 0 + = render "conferences/index_core", :conferences => user.conferences + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Conference} \ No newline at end of file diff --git a/app/views/users/_fax_accounts.html.haml b/app/views/users/_fax_accounts.html.haml new file mode 100644 index 0000000..044b8f9 --- /dev/null +++ b/app/views/users/_fax_accounts.html.haml @@ -0,0 +1,7 @@ +-# FaxAccount +-# +- if (can?( :index, FaxAccount ) && user.fax_accounts.count > 0 ) || can?( :create, FaxAccount ) + %h2= t('fax_accounts.index.page_title') + - if can?( :index, FaxAccount ) && user.fax_accounts.count > 0 + = render "fax_accounts/index_core", {:fax_accounts => user.fax_accounts, :fax_accountable => user} + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => FaxAccount} \ No newline at end of file diff --git a/app/views/users/_phone_books.html.haml b/app/views/users/_phone_books.html.haml new file mode 100644 index 0000000..4943bc6 --- /dev/null +++ b/app/views/users/_phone_books.html.haml @@ -0,0 +1,7 @@ +-# Phone books +-# +- if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) + - if can?( :index, PhoneBook ) + %h2=t("phone_books.index.page_title") + = render "phone_books/index_core", :phone_books => phone_books + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => PhoneBook} \ No newline at end of file diff --git a/app/views/users/_phones.html.haml b/app/views/users/_phones.html.haml new file mode 100644 index 0000000..e001eae --- /dev/null +++ b/app/views/users/_phones.html.haml @@ -0,0 +1,7 @@ +-# Phones +-# +- if (can?( :index, Phone, :phoneable => user ) && user.phones.count > 0 ) || can?( :create, Phone, :phoneable => user ) + %h2= t('phones.index.page_title') + - if can?( :index, Phone, :phoneable => user ) && user.phones.count > 0 + = render "phones/index_core", :phones => user.phones + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Phone} \ No newline at end of file diff --git a/app/views/users/_sip_accounts.html.haml b/app/views/users/_sip_accounts.html.haml new file mode 100644 index 0000000..1861105 --- /dev/null +++ b/app/views/users/_sip_accounts.html.haml @@ -0,0 +1,7 @@ +-# SIP accounts +-# +- if (can?( :index, SipAccount ) && user.sip_accounts.count > 0 ) || can?( :create, SipAccount ) + %h2= t('sip_accounts.index.page_title') + - if can?( :index, SipAccount ) && user.sip_accounts.count > 0 + = render "sip_accounts/index_core", :sip_accounts => user.sip_accounts + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => SipAccount} \ No newline at end of file diff --git a/app/views/users/_tenants.html.haml b/app/views/users/_tenants.html.haml new file mode 100644 index 0000000..49a2d9b --- /dev/null +++ b/app/views/users/_tenants.html.haml @@ -0,0 +1,5 @@ +-# Tenants +-# +- if can?( :index, Tenant ) && user.tenants.count > 1 + %h2=t("tenants.index.page_title") + = render "tenants/index_core", :tenants => user.tenants \ No newline at end of file diff --git a/app/views/users/_user_groups.html.haml b/app/views/users/_user_groups.html.haml new file mode 100644 index 0000000..7e206b6 --- /dev/null +++ b/app/views/users/_user_groups.html.haml @@ -0,0 +1,8 @@ +-# User groups (only if the current user can edit or destroy them) +-# +- if user.user_groups.map{ |x| can?( :edit, x ) || can?( :destroy, x ) }.include?(true) + - if can?( :index, UserGroup ) + %h2=t("user_groups.index.page_title") + - if user.user_groups.count > 0 + = render "user_groups/index_core", :user_groups => user.user_groups.where(:tenant_id => tenant.id).order(:name) + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => UserGroup} \ No newline at end of file diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 7730447..5650b13 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -2,95 +2,59 @@ #user-show %aside - = image_tag @user.image_url(:small).to_s, class: 'display' if @user.image? && @user.image_url(:small) - %p - %strong= t('users.show.user_name') + ":" - = @user.user_name - %p - %strong= t('users.show.email') + ":" - = @user.email - - %p.controls - = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @tenant, :child => @user } - - - @user.sip_accounts.each do |sip_account| - - phone_number = sip_account.phone_numbers.order(:number).last - - if phone_number && !phone_number.number.blank? && phone_number.number[0] != '+' - %p - %strong= sip_account.phone_numbers.order(:number).last.number - %p - =link_to t("call_histories.index.page_title"), sip_account_call_histories_path(sip_account) - %br - =link_to t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(sip_account) - %br - =link_to t("call_forwards.index.page_title"), phone_number_call_forwards_path(phone_number) - %br - =link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) - %br - =link_to t("softkeys.index.page_title"), sip_account_softkeys_path(sip_account) - %br - =link_to t("ringtones.show.page_title"), phone_number_ringtones_path(phone_number) - - - if @user.conferences.any? + - cache([I18n.locale, 'show_aside', @user, @user.sip_accounts, @user.conferences]) do + = image_tag @user.image_url(:small).to_s, class: 'display' if @user.image? && @user.image_url(:small) + %p + %strong= t('users.show.user_name') + ":" + = @user.user_name %p - %strong= t("conferences.index.page_title") - - @user.conferences.each do |conference| + %strong= t('users.show.email') + ":" + = @user.email + + %p.controls + = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @tenant, :child => @user } + + - @user.sip_accounts.each do |sip_account| + - phone_number = sip_account.phone_numbers.order(:number).last + - if phone_number && !phone_number.number.blank? && phone_number.number[0] != '+' + %p + %strong= sip_account.phone_numbers.order(:number).last.number + %p + =link_to t("call_histories.index.page_title"), sip_account_call_histories_path(sip_account) + %br + =link_to t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(sip_account) + %br + =link_to t("call_forwards.index.page_title"), phone_number_call_forwards_path(phone_number) + %br + =link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) + %br + =link_to t("softkeys.index.page_title"), sip_account_softkeys_path(sip_account) + %br + =link_to t("ringtones.show.page_title"), phone_number_ringtones_path(phone_number) + + - if @user.conferences.any? %p - =link_to conference, edit_user_conference_path(@user, conference) + %strong= t("conferences.index.page_title") + - @user.conferences.each do |conference| + %p + =link_to conference, edit_user_conference_path(@user, conference) %section - -# Phone books - -# - - if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) - - if can?( :index, PhoneBook ) - %h2=t("phone_books.index.page_title") - = render "phone_books/index_core", :phone_books => @phone_books - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => PhoneBook} - - -# User groups (only if the current user can edit or destroy them) - -# - - if @user.user_groups.map{ |x| can?( :edit, x ) || can?( :destroy, x ) }.include?(true) - - if can?( :index, UserGroup ) - %h2=t("user_groups.index.page_title") - - if @user.user_groups.count > 0 - = render "user_groups/index_core", :user_groups => @user.user_groups.where(:tenant_id => @tenant.id).order(:name) - = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => UserGroup} + = render :partial => 'phone_books', :locals => {:user => @user, :phone_books => @phone_books} - -# SIP accounts - -# - - if (can?( :index, SipAccount ) && @user.sip_accounts.count > 0 ) || can?( :create, SipAccount ) - %h2= t('sip_accounts.index.page_title') - - if can?( :index, SipAccount ) && @user.sip_accounts.count > 0 - = render "sip_accounts/index_core", :sip_accounts => @user.sip_accounts - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => SipAccount} + - cache([I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - cache([I18n.locale, @user, @user.user_groups]) do + = render :partial => 'user_groups', :locals => {:user => @user, :tenant => @tenant} - -# Phones - -# - - if (can?( :index, Phone, :phoneable => @user ) && @user.phones.count > 0 ) || can?( :create, Phone, :phoneable => @user ) - %h2= t('phones.index.page_title') - - if can?( :index, Phone, :phoneable => @user ) && @user.phones.count > 0 - = render "phones/index_core", :phones => @user.phones - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => Phone} + - cache([I18n.locale, @user, @user.sip_accounts]) do + = render :partial => 'sip_accounts', :locals => {:user => @user} - -# FaxAccount - -# - - if (can?( :index, FaxAccount ) && @user.fax_accounts.count > 0 ) || can?( :create, FaxAccount ) - %h2= t('fax_accounts.index.page_title') - - if can?( :index, FaxAccount ) && @user.fax_accounts.count > 0 - = render "fax_accounts/index_core", {:fax_accounts => @user.fax_accounts, :fax_accountable => @user} - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => FaxAccount} + - cache([I18n.locale, @user, @user.phones]) do + = render :partial => 'phones', :locals => {:user => @user} - -# Conferences - -# - - if (can?( :index, Conference ) && @user.conferences.count > 0 ) || can?( :create, Conference ) - %h2= t('conferences.index.page_title') - - if can?( :index, Conference ) && @user.conferences.count > 0 - = render "conferences/index_core", :conferences => @user.conferences - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => Conference} + - cache([I18n.locale, @user, @user.fax_accounts]) do + = render :partial => 'fax_accounts', :locals => {:user => @user} - -# Tenants - -# - - if can?( :index, Tenant ) && @user.tenants.count > 1 - %h2=t("tenants.index.page_title") - = render "tenants/index_core", :tenants => @user.tenants \ No newline at end of file + - cache([I18n.locale, @user, @user.conferences]) do + = render :partial => 'conferences', :locals => {:user => @user} -- cgit v1.2.3 From 078e90282bab4b76d6eb0678c9e5f69d7ae86748 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 19:13:44 +0100 Subject: Added caching for the phone_book_entries table. --- .../phone_book_entries/_index_core.de.html.haml | 72 ++++++++++----------- app/views/phone_book_entries/_index_core.html.haml | 73 +++++++++++----------- 2 files changed, 75 insertions(+), 70 deletions(-) diff --git a/app/views/phone_book_entries/_index_core.de.html.haml b/app/views/phone_book_entries/_index_core.de.html.haml index 0c6e74b..e460888 100644 --- a/app/views/phone_book_entries/_index_core.de.html.haml +++ b/app/views/phone_book_entries/_index_core.de.html.haml @@ -2,39 +2,41 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - reset_cycle - %table - - for entry in phone_book_entries - ~# Dear IE7, - ~# Because of you we have to do this with a table. - ~# With Love, - ~# Mario. - %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} - %td.thumbnail - = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') - %td.user - - if entry.is_organization == true - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - - else - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization - %td.contact - - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first - - elsif entry.phone_numbers.first - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first - - if entry.phone_numbers.count > 1 - %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) - %td.extra - - if !entry.description.blank? - %strong Beschreibung: - %div - = entry.description - - if !entry.homepage_organization.blank? - %br - =link_to entry.homepage_organization, entry.homepage_organization - - if can? :edit, entry - %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) - - if can? :destroy, entry - %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete + - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - reset_cycle + %table + - for entry in phone_book_entries + - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + ~# Dear IE7, + ~# Because of you we have to do this with a table. + ~# With Love, + ~# Mario. + %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} + %td.thumbnail + = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') + %td.user + - if entry.is_organization == true + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + - else + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization + %td.contact + - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first + - elsif entry.phone_numbers.first + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first + - if entry.phone_numbers.count > 1 + %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) + %td.extra + - if !entry.description.blank? + %strong Beschreibung: + %div + = entry.description + - if !entry.homepage_organization.blank? + %br + =link_to entry.homepage_organization, entry.homepage_organization + - if can? :edit, entry + %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) + - if can? :destroy, entry + %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete %footer.entries-nav= render :partial => "phone_book_entries/navigation" diff --git a/app/views/phone_book_entries/_index_core.html.haml b/app/views/phone_book_entries/_index_core.html.haml index 9054833..37ad905 100644 --- a/app/views/phone_book_entries/_index_core.html.haml +++ b/app/views/phone_book_entries/_index_core.html.haml @@ -2,39 +2,42 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - reset_cycle - %table - - for entry in phone_book_entries - ~# Dear IE7, - ~# Because of you we have to do this with a table. - ~# With Love, - ~# Mario. - %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} - %td.thumbnail - = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') - %td.user - - if entry.is_organization == true - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - - else - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization - %td.contact - - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first - - elsif entry.phone_numbers.first - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first - - if entry.phone_numbers.count > 1 - %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) - %td.extra - - if !entry.description.blank? - %strong Description: - %div - = entry.description - - if !entry.homepage_organization.blank? - %br - =link_to entry.homepage_organization, entry.homepage_organization - - if can? :edit, entry - %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) - - if can? :destroy, entry - %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete + - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - reset_cycle + - reset_cycle + %table + - for entry in phone_book_entries + - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + ~# Dear IE7, + ~# Because of you we have to do this with a table. + ~# With Love, + ~# Mario. + %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} + %td.thumbnail + = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') + %td.user + - if entry.is_organization == true + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + - else + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization + %td.contact + - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first + - elsif entry.phone_numbers.first + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first + - if entry.phone_numbers.count > 1 + %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) + %td.extra + - if !entry.description.blank? + %strong Description: + %div + = entry.description + - if !entry.homepage_organization.blank? + %br + =link_to entry.homepage_organization, entry.homepage_organization + - if can? :edit, entry + %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) + - if can? :destroy, entry + %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete %footer.entries-nav= render :partial => "phone_book_entries/navigation" -- cgit v1.2.3 From 4fbda07c7b593dcc22b90f571d1b85b1bdc47528 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 19:48:22 +0100 Subject: Check if Rails.env.production? before restarting FreeSWITCH. #101 --- app/controllers/gemeinschaft_setups_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 89a82cb..dbe8ff5 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -47,8 +47,10 @@ class GemeinschaftSetupsController < ApplicationController GsParameter.where(:name => 'user_image_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}/uploads/user/image") # Restart FreeSWITCH - # require 'freeswitch_event' - # FreeswitchAPI.execute('fsctl', 'shutdown restart') + if Rails.env.production? + require 'freeswitch_event' + FreeswitchAPI.execute('fsctl', 'shutdown restart') + end # Auto-Login: session[:user_id] = user.id -- cgit v1.2.3 From 5a49e044fe3a5bdeff40c15d363af6d0c36fa27a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:27:39 +0100 Subject: Fixed breadcrumbs. --- app/controllers/gui_functions_controller.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/gui_functions_controller.rb b/app/controllers/gui_functions_controller.rb index 2ab2c5e..0cb7898 100644 --- a/app/controllers/gui_functions_controller.rb +++ b/app/controllers/gui_functions_controller.rb @@ -1,4 +1,6 @@ class GuiFunctionsController < ApplicationController + load_resource :gui_function + before_filter :load_user_groups before_filter :spread_breadcrumbs @@ -60,14 +62,10 @@ class GuiFunctionsController < ApplicationController end def spread_breadcrumbs - if @tenant - add_breadcrumb t("user_groups.index.page_title"), tenant_user_groups_path(@tenant) - if @user_group && !@user_group.new_record? - add_breadcrumb @user_group, tenant_user_group_path(@tenant, @user_group) - end - end - add_breadcrumb t("gui_functions.index.page_title"), gui_functions_path + if @gui_function && !@gui_function.new_record? + add_breadcrumb @gui_function, gui_function_path(@gui_function) + end end end -- cgit v1.2.3 From ca77ad70f4c2df28f6460e0160f23d115174440d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:42:02 +0100 Subject: Optimized caching. --- app/controllers/gs_parameters_controller.rb | 2 +- app/views/gs_parameters/_index_core.html.haml | 6 +++--- app/views/gs_parameters/index.html.haml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index a7813dc..0966132 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -1,6 +1,6 @@ class GsParametersController < ApplicationController def index - @ps_parameters_unordered = GsParameter.scoped + @gs_parameters_unordered = GsParameter.scoped @gs_parameters = GsParameter.order([:section, :name]) @sections = @gs_parameters.pluck(:section).uniq.sort end diff --git a/app/views/gs_parameters/_index_core.html.haml b/app/views/gs_parameters/_index_core.html.haml index 0c36560..a3f8e1c 100644 --- a/app/views/gs_parameters/_index_core.html.haml +++ b/app/views/gs_parameters/_index_core.html.haml @@ -1,4 +1,4 @@ -- cache([gs_parameters.first.section, gs_parameters.reorder(:updated_at).last, gs_parameters.pluck(:id)]) do +- cache(['gs_parameters_table_section', gs_parameters.first.section, gs_parameters.reorder(:updated_at).last, gs_parameters.pluck(:id)]) do %tr %th= t('gs_parameters.index.name') - if !@sections @@ -7,10 +7,10 @@ - reset_cycle - for gs_parameter in gs_parameters - - cache(gs_parameter) do + - cache(['gs_parameters_table_single_row', gs_parameter]) do %tr{:class => cycle('odd', 'even')} %td= gs_parameter.name - if !@sections %td= gs_parameter.section - %td= gs_parameter.value + %td= truncate(gs_parameter.value, :length => 50) =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/index.html.haml b/app/views/gs_parameters/index.html.haml index b4a53e8..c7a6b70 100644 --- a/app/views/gs_parameters/index.html.haml +++ b/app/views/gs_parameters/index.html.haml @@ -1,7 +1,7 @@ - title t("gs_parameters.index.page_title") - if @gs_parameters && @gs_parameters.count > 0 - - cache([@ps_parameters_unordered.order(:updated_at).last, @ps_parameters_unordered.count]) do + - cache(['gs_parameters_table', @gs_parameters_unordered.order(:updated_at).last, @gs_parameters_unordered.count]) do - if @sections %table - @sections.each do |section| -- cgit v1.2.3 From 907d081bf1b45e876f9d5833bfe1f4d6319aeb81 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:44:19 +0100 Subject: Added breadcrumbs for GsParameter. --- app/controllers/gs_parameters_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index 0966132..7ca4e8e 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -1,4 +1,8 @@ class GsParametersController < ApplicationController + load_resource :gs_parameter + + before_filter :spread_breadcrumbs + def index @gs_parameters_unordered = GsParameter.scoped @gs_parameters = GsParameter.order([:section, :name]) @@ -30,4 +34,11 @@ class GsParametersController < ApplicationController def gs_parameter_params params.require(:gs_parameter).permit(:value, :class_type, :description) end + + def spread_breadcrumbs + add_breadcrumb t("gs_parameters.index.page_title"), gs_parameters_path + if @gs_parameter && !@gs_parameter.new_record? + add_breadcrumb @gs_parameter, gs_parameter_path(@gs_parameter) + end + end end -- cgit v1.2.3 From 7b5c903f96e1c97ad788962c88d6d285852d890e Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:50:18 +0100 Subject: Fixed caching. --- app/views/tenants/_gs_parameter_table.html.haml | 2 +- app/views/tenants/_table_of_functions.html.haml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/tenants/_gs_parameter_table.html.haml b/app/views/tenants/_gs_parameter_table.html.haml index 7663f46..3af06cf 100644 --- a/app/views/tenants/_gs_parameter_table.html.haml +++ b/app/views/tenants/_gs_parameter_table.html.haml @@ -1,4 +1,4 @@ -- cache([I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do +- cache(['gs_parameters_tenant_overview_table', 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_functions.html.haml b/app/views/tenants/_table_of_functions.html.haml index ef2a2d0..75b2332 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, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last, tenant.conferences.count, tenant.conferences.order(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do +- cache(['table_of_pbx_features', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last, tenant.conferences.count, tenant.conferences.order(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do %table %tr{:class => 'even'} %th @@ -6,7 +6,7 @@ %th Anzahl %th - - cache([I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last]) do + - cache(['table_of_pbx_features_callthroughs_row', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last]) do %tr{:class => 'odd'} %td = t("callthroughs.name") @@ -17,7 +17,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Callthrough} - - cache([I18n.locale, tenant, tenant.conferences.count, tenant.conferences.order(:updated_at).last]) do + - cache(['table_of_pbx_features_conferences_row', I18n.locale, tenant, tenant.conferences.count, tenant.conferences.order(:updated_at).last]) do %tr{:class => 'even'} %td = t("conferences.name") @@ -28,7 +28,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Conference} - - cache([I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last]) do + - cache(['table_of_pbx_features_hunt_groups_row', I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last]) do %tr{:class => 'odd'} %td = t("hunt_groups.name") @@ -39,7 +39,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => HuntGroup} - - cache([I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do + - cache(['table_of_pbx_features_automatic_call_distributors_row', I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do %tr{:class => 'even'} %td = t("automatic_call_distributors.name") -- cgit v1.2.3 From 6b7cbac8a2a274c1839e8ea6aa293d0e6e49d370 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 21:38:22 +0100 Subject: Fixes caching bugs. --- app/views/users/show.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 5650b13..c3af173 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -2,7 +2,7 @@ #user-show %aside - - cache([I18n.locale, 'show_aside', @user, @user.sip_accounts, @user.conferences]) do + - cache(['user_show_aside', I18n.locale, @user, @user.sip_accounts, @user.conferences]) do = image_tag @user.image_url(:small).to_s, class: 'display' if @user.image? && @user.image_url(:small) %p %strong= t('users.show.user_name') + ":" @@ -43,18 +43,18 @@ %section = render :partial => 'phone_books', :locals => {:user => @user, :phone_books => @phone_books} - - cache([I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do - - cache([I18n.locale, @user, @user.user_groups]) do + - cache(['user_show_overview', I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - cache(['user_show_user_groups_overview', I18n.locale, @user, @user.user_groups]) do = render :partial => 'user_groups', :locals => {:user => @user, :tenant => @tenant} - - cache([I18n.locale, @user, @user.sip_accounts]) do + - cache(['user_show_sip_accounts_overview', I18n.locale, @user, @user.sip_accounts]) do = render :partial => 'sip_accounts', :locals => {:user => @user} - - cache([I18n.locale, @user, @user.phones]) do + - cache(['user_show_phones_overview', I18n.locale, @user, @user.phones]) do = render :partial => 'phones', :locals => {:user => @user} - - cache([I18n.locale, @user, @user.fax_accounts]) do + - cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do = render :partial => 'fax_accounts', :locals => {:user => @user} - - cache([I18n.locale, @user, @user.conferences]) do + - cache(['user_show_conferences_overview', I18n.locale, @user, @user.conferences]) do = render :partial => 'conferences', :locals => {:user => @user} -- cgit v1.2.3 From 96fc4789d9991548b9fd1144f185da1f3464f156 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 21:47:26 +0100 Subject: Fixed caching bugs. --- app/views/phone_book_entries/_index_core.de.html.haml | 4 ++-- app/views/phone_book_entries/_index_core.html.haml | 4 ++-- app/views/tenants/_admin_area.de.html.haml | 2 +- app/views/tenants/_admin_area.html.haml | 2 +- app/views/tenants/_sip_accounts_and_phones.html.haml | 4 ++-- app/views/tenants/_table_of_phone_books.html.haml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/phone_book_entries/_index_core.de.html.haml b/app/views/phone_book_entries/_index_core.de.html.haml index e460888..43d62f6 100644 --- a/app/views/phone_book_entries/_index_core.de.html.haml +++ b/app/views/phone_book_entries/_index_core.de.html.haml @@ -2,11 +2,11 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - cache(['phone_book_entries_table', I18n.locale, current_user, phone_book_entries]) do - reset_cycle %table - for entry in phone_book_entries - - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + - cache(['phone_book_entries_table_tr', I18n.locale, current_user, entry]) do ~# Dear IE7, ~# Because of you we have to do this with a table. ~# With Love, diff --git a/app/views/phone_book_entries/_index_core.html.haml b/app/views/phone_book_entries/_index_core.html.haml index 37ad905..e98e8d5 100644 --- a/app/views/phone_book_entries/_index_core.html.haml +++ b/app/views/phone_book_entries/_index_core.html.haml @@ -2,12 +2,12 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - cache(['phone_book_entries_table', I18n.locale, current_user, phone_book_entries]) do - reset_cycle - reset_cycle %table - for entry in phone_book_entries - - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + - cache(['phone_book_entries_table_tr', I18n.locale, current_user, entry]) do ~# Dear IE7, ~# Because of you we have to do this with a table. ~# With Love, diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 4b8a9e6..beab94e 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.all]) do +- cache(['tenant_show_admin_area', 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')) diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index b1b17a3..65810e7 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.all]) do +- cache(['tenant_show_admin_area', 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 618236f..c698fef 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -12,7 +12,7 @@ - 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 + - cache(['tenant_show_tenant_sip_accounts',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) @@ -44,7 +44,7 @@ - if tenant.phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') = link_to tenant.phones.count.to_s, tenant_phones_path(tenant) - else - - cache([I18n.locale, tenant, tenant.phones]) do + - cache(['tenant_show_tenant_phones', 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) diff --git a/app/views/tenants/_table_of_phone_books.html.haml b/app/views/tenants/_table_of_phone_books.html.haml index a963bf4..6baca58 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, tenant.phone_books]) do +- cache(['user_show_phone_books', I18n.locale, tenant, tenant.phone_books]) do -# Phone books -# - if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) -- cgit v1.2.3 From bf9c8cdfb5d2754e53b15560242cc7c43603155a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 21:53:22 +0100 Subject: GuiFunction can not be deleted or created on the GUI. --- app/models/ability.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 0fa40c8..cd91a8a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -74,9 +74,10 @@ class Ability cannot :manage, PhoneNumberRange end - # GsParameter can't be created or deleted via the GUI + # GsParameter and GuiFunction can't be created or deleted via the GUI # cannot [:create, :destroy], GsParameter + cannot [:create, :destroy], GuiFunction else # Any user can do the following stuff. # -- cgit v1.2.3 From d44b8c81f939deb1e83e17d19c580b3bf6ac9ab6 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:00:45 +0100 Subject: Optimized caching. --- app/views/gs_parameters/index.html.haml | 2 +- app/views/gui_functions/_index_core.html.haml | 29 ++++++++++++++------------- app/views/gui_functions/index.html.haml | 3 ++- app/views/gui_functions/show.html.haml | 29 ++++++++++++++------------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/app/views/gs_parameters/index.html.haml b/app/views/gs_parameters/index.html.haml index c7a6b70..37fe825 100644 --- a/app/views/gs_parameters/index.html.haml +++ b/app/views/gs_parameters/index.html.haml @@ -1,7 +1,7 @@ - title t("gs_parameters.index.page_title") - if @gs_parameters && @gs_parameters.count > 0 - - cache(['gs_parameters_table', @gs_parameters_unordered.order(:updated_at).last, @gs_parameters_unordered.count]) do + - cache(['gs_parameters_table', I18n.locale, @gs_parameters_unordered.order(:updated_at).last, @gs_parameters_unordered.count]) do - if @sections %table - @sections.each do |section| diff --git a/app/views/gui_functions/_index_core.html.haml b/app/views/gui_functions/_index_core.html.haml index 093a0d7..815b9c3 100644 --- a/app/views/gui_functions/_index_core.html.haml +++ b/app/views/gui_functions/_index_core.html.haml @@ -8,19 +8,20 @@ - reset_cycle - for gui_function in gui_functions %tr{:class => cycle('odd', 'even')} - %td= gui_function.category - %td - = gui_function.name - - if !gui_function.description.blank? - %br - %i= gui_function.description - - @user_groups.each do |user_group| - - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id) - - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id).activated == true - %td= 'x' + - cache(['gui_functions_table_row', I18n.locale, gui_function]) do + %td= gui_function.category + %td + = gui_function.name + - if !gui_function.description.blank? + %br + %i= gui_function.description + - @user_groups.each do |user_group| + - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id) + - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id).activated == true + %td= 'x' + - else + %td= '' - else - %td= '' - - else - %td= 'x' + %td= 'x' - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gui_function} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gui_function} \ No newline at end of file diff --git a/app/views/gui_functions/index.html.haml b/app/views/gui_functions/index.html.haml index ef909f0..9b53918 100644 --- a/app/views/gui_functions/index.html.haml +++ b/app/views/gui_functions/index.html.haml @@ -1,6 +1,7 @@ - title t("gui_functions.index.page_title") - if @gui_functions && @gui_functions.count > 0 - = render "index_core", :gui_functions => @gui_functions + - cache(['gui_functions_table', I18n.locale, @gui_functions.reorder(:updated_at).last, @gui_functions.count]) do + = render "index_core", :gui_functions => @gui_functions = render :partial => 'shared/create_link', :locals => {:child_class => GuiFunction} \ No newline at end of file diff --git a/app/views/gui_functions/show.html.haml b/app/views/gui_functions/show.html.haml index 0fc2dd9..8af329a 100644 --- a/app/views/gui_functions/show.html.haml +++ b/app/views/gui_functions/show.html.haml @@ -1,18 +1,19 @@ - title t("gui_functions.show.page_title") -%p - %strong= t('gui_functions.show.name') + ":" - = @gui_function.name -%p - %strong= t('gui_functions.show.description') + ":" - = @gui_function.description - -- @user_groups.each do |user_group| +- cache(['gui_function_show', I18n.locale, @gui_function]) do + %p + %strong= t('gui_functions.show.name') + ":" + = @gui_function.name %p - %strong= "#{user_group}:" - - if @gui_function.gui_function_memberships.where(:user_group_id => user_group.id, :activated => true).count > 0 - = 'x' - - else - = 'not activated' + %strong= t('gui_functions.show.description') + ":" + = @gui_function.description + + - @user_groups.each do |user_group| + %p + %strong= "#{user_group}:" + - if @gui_function.gui_function_memberships.where(:user_group_id => user_group.id, :activated => true).count > 0 + = 'x' + - else + = 'not activated' -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gui_function } \ No newline at end of file + = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gui_function } \ No newline at end of file -- cgit v1.2.3 From 0820f0e79a28aaa22ff98e969cd202ed422298ff Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:06:30 +0100 Subject: Redirect root_url to user#show. --- app/controllers/page_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb index 4ea4d25..dc5f57b 100644 --- a/app/controllers/page_controller.rb +++ b/app/controllers/page_controller.rb @@ -5,7 +5,12 @@ class PageController < ApplicationController before_filter :if_fresh_system_then_go_to_wizard skip_before_filter :home_breadcrumb, :only => [:index] - def index;end + def index + if current_user + redirect_to [current_user.current_tenant, current_user] + end + end + def conference;end def beginners_intro;end -- cgit v1.2.3 From a0569f5546781b8e87011a79e2fccaae8c06e862 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:42:03 +0100 Subject: s/Benutzer/User/g --- config/locales/views/users/de.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/locales/views/users/de.yml b/config/locales/views/users/de.yml index 951600d..e4a0ae2 100644 --- a/config/locales/views/users/de.yml +++ b/config/locales/views/users/de.yml @@ -1,15 +1,15 @@ de: users: - name: "Benutzer" + name: "User" controller: - successfuly_created: 'Der Benutzer %{resource} wurde erstellt.' - successfuly_created_and_login: 'Der Benutzer %{resource} wurde erstellt. Sie sind jetzt als dieser Benutzer angemeldet.' - successfuly_updated: 'Benutzer-Daten aktualisiert.' - successfuly_destroyed: 'Der Benutzer wurde gelöscht.' + successfuly_created: 'Der User %{resource} wurde erstellt.' + successfuly_created_and_login: 'Der User %{resource} wurde erstellt. Sie sind jetzt als dieser User angemeldet.' + successfuly_updated: 'User-Daten aktualisiert.' + successfuly_destroyed: 'Der User wurde gelöscht.' avatar_destroyed: 'Der Avatar wurde gelöscht.' index: - page_title: 'Benutzer' - user_name: 'Benutzer-Name' + page_title: 'User' + user_name: 'User-Name' email: 'E-Mail Adresse' first_name: 'Vorname' middle_name: 'Zweiter Vorname' @@ -20,15 +20,15 @@ de: language_id: 'Sprache' send_voicemail_as_email_attachment: 'Sprachnachrichten per E-Mail' actions: - confirm: 'Sind Sie sicher, dass Sie diesen Benutzer löschen möchten?' + confirm: 'Sind Sie sicher, dass Sie diesen User löschen möchten?' destroy: 'Löschen' edit: 'Bearbeiten' show: 'Anzeigen' - create: 'Neuen Benutzer anlegen' - create_for: 'Neuen Benutzer für %{resource} anlegen' + create: 'Neuen User anlegen' + create_for: 'Neuen User für %{resource} anlegen' show: - page_title: 'Benutzer anzeigen' - user_name: 'Benutzer-Name' + page_title: 'User anzeigen' + user_name: 'User-Name' email: 'E-Mail Adresse' first_name: 'Vorname' middle_name: 'Zweiter Vorname' @@ -39,17 +39,17 @@ de: language_id: 'Sprache' send_voicemail_as_email_attachment: 'Sprachnachrichten per E-Mail' actions: - confirm: 'Sind Sie sicher, dass Sie diesen Benutzer löschen möchten?' + confirm: 'Sind Sie sicher, dass Sie diesen User löschen möchten?' destroy: 'Löschen' edit: 'Bearbeiten' - view_all: 'Alle Benutzer anzeigen' + view_all: 'Alle User anzeigen' new: - page_title: 'Neuen Benutzer anlegen' + page_title: 'Neuen User anlegen' edit: - page_title: 'Benutzer %{resource} bearbeiten' + page_title: 'User %{resource} bearbeiten' form: user_name: - label: 'Benutzer-Name' + label: 'User-Name' hint: '' email: label: 'E-Mail Adresse' -- cgit v1.2.3 From 8d622f127f8d951c50bbf3fd0921626fd3746dae Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:42:15 +0100 Subject: Optimized caching. --- .../tenants/_sip_accounts_and_phones.html.haml | 64 ++++++++++++---------- app/views/tenants/show.html.haml | 15 ++--- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml index c698fef..e322b67 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -1,24 +1,40 @@ %table %tr{:class => 'even'} %th - %th - = tenant - %th= t("users.index.page_title") + %th= t("sip_accounts.index.page_title") + %th= t("phones.index.page_title") - %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(['tenant_show_tenant_sip_accounts',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} + - cache(['tenant_show_admin_area_sip_accounts_and_phones_row', I18n.locale, @tenant, @tenant.sip_accounts.count, @tenant.sip_accounts.reorder(:updated_at).last, @tenant.phones.count, @tenant.phones.reorder(:updated_at).last]) do + + %tr{:class => 'odd'} + %td= tenant + - cache(['tenant_show_admin_area_sip_accounts_table_cell', I18n.locale, @tenant, @tenant.sip_accounts.count, @tenant.sip_accounts.reorder(: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} + + - cache(['tenant_show_admin_area_sip_accounts_table_cell', I18n.locale, @tenant, @tenant.phones.count, @tenant.phones.reorder(: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) + - else + - cache(['tenant_show_tenant_phones', 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} + + %tr{:class => 'even'} + %td= t("users.index.page_title") %td - if tenant.users_sip_accounts.any? - if tenant.users_sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') @@ -37,18 +53,6 @@ - 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 - - cache(['tenant_show_tenant_phones', 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') @@ -61,4 +65,4 @@ - 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/show.html.haml b/app/views/tenants/show.html.haml index cb2b895..10845cf 100644 --- a/app/views/tenants/show.html.haml +++ b/app/views/tenants/show.html.haml @@ -1,14 +1,15 @@ - title t("tenants.show.page_title") -%p - %strong= t('tenants.show.name') + ":" - = @tenant.name -- if !@tenant.description.blank? +- cache(['tenant_show_name_and_description', I18n.locale, @tenant, current_user]) do %p - %strong= t('tenants.show.description') + ":" - = @tenant.description + %strong= t('tenants.show.name') + ":" + = @tenant.name + - if !@tenant.description.blank? + %p + %strong= t('tenants.show.description') + ":" + = @tenant.description -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @tenant } + = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @tenant } - if @tenant.user_groups.where(:name => 'Admins').count > 0 && @tenant.user_groups.where(:name => 'Admins').first.users.include?(current_user) = render 'admin_area' \ No newline at end of file -- cgit v1.2.3 From 6635621faeebbc8dd744e0ad71741f9e82aed1f8 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 07:21:11 +0100 Subject: Show the user_groups in User#view only for Admins. --- app/views/users/show.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index c3af173..f74d0a5 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -43,10 +43,12 @@ %section = render :partial => 'phone_books', :locals => {:user => @user, :phone_books => @phone_books} - - cache(['user_show_overview', I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - if current_user.user_groups.where(:name => 'Admins').any? - cache(['user_show_user_groups_overview', I18n.locale, @user, @user.user_groups]) do = render :partial => 'user_groups', :locals => {:user => @user, :tenant => @tenant} + - cache(['user_show_overview_for_sip_account_phones_fax_accounts_and_conferences', I18n.locale, @user, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - cache(['user_show_sip_accounts_overview', I18n.locale, @user, @user.sip_accounts]) do = render :partial => 'sip_accounts', :locals => {:user => @user} -- cgit v1.2.3 From 1debae060b1c4a816f4565ad55490fee61c6472b Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 09:28:38 +0100 Subject: dump_variables dialplan option added --- misc/freeswitch/scripts/dialplan_default.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 42271b9..eb80ae4 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -39,7 +39,9 @@ start_dialplan:configuration_read(); start_caller.local_node_id = start_dialplan.node_id; start_caller:init_channel_variables(); --- session:execute('info','notice'); +if start_dialplan.config.parameters.dump_variables then + start_caller:execute('info', 'notice'); +end if start_caller.from_node and not start_dialplan:auth_node() then log:debug('DIALPLAN_DEFAULT - node unauthorized - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); -- cgit v1.2.3 From 9c23099b8f93e0ace47caba051204eb6624b8c95 Mon Sep 17 00:00:00 2001 From: "Mario \"Kuroir\" Ricalde" Date: Wed, 16 Jan 2013 02:45:18 -0600 Subject: Updates Rails to 3.2.9 --- Gemfile | 4 +- Gemfile.lock | 166 +++++++++++---------- app/assets/stylesheets/application.css.scss | 2 +- .../vendor/fancy-buttons/_fancy-buttons.scss | 12 +- config/application.rb | 14 +- 5 files changed, 97 insertions(+), 101 deletions(-) diff --git a/Gemfile b/Gemfile index d505227..c3d86f9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.2.2' +gem 'rails', '3.2.9' gem 'bcrypt-ruby' gem 'sqlite3' gem 'mysql2' @@ -23,7 +23,7 @@ gem "nokogiri" # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', '~> 3.2.3' + gem 'sass-rails' gem 'coffee-rails', '~> 3.2.1' gem 'compass-rails' gem 'uglifier', '>= 1.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 77d09fe..dd98f2d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,176 +1,178 @@ GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.2) - actionpack (= 3.2.2) - mail (~> 2.4.0) - actionpack (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + actionmailer (3.2.9) + actionpack (= 3.2.9) + mail (~> 2.4.4) + actionpack (3.2.9) + activemodel (= 3.2.9) + activesupport (= 3.2.9) builder (~> 3.0.0) erubis (~> 2.7.0) - journey (~> 1.0.1) + journey (~> 1.0.4) rack (~> 1.4.0) - rack-cache (~> 1.1) + rack-cache (~> 1.2) rack-test (~> 0.6.1) - sprockets (~> 2.1.2) - activemodel (3.2.2) - activesupport (= 3.2.2) + sprockets (~> 2.2.1) + activemodel (3.2.9) + activesupport (= 3.2.9) builder (~> 3.0.0) - activerecord (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + activerecord (3.2.9) + activemodel (= 3.2.9) + activesupport (= 3.2.9) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) - activesupport (3.2.2) + activeresource (3.2.9) + activemodel (= 3.2.9) + activesupport (= 3.2.9) + activesupport (3.2.9) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_list (0.1.5) - addressable (2.2.7) + acts_as_list (0.1.9) + addressable (2.3.2) arel (3.0.2) bcrypt-ruby (3.0.1) - breadcrumbs_on_rails (2.2.0) - builder (3.0.0) + breadcrumbs_on_rails (2.3.0) + builder (3.0.4) cache_digests (0.2.0) actionpack (>= 3.2) - cancan (1.6.7) - carrierwave (0.5.8) - activesupport (~> 3.0) - chunky_png (1.2.5) + cancan (1.6.8) + carrierwave (0.8.0) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + chunky_png (1.2.7) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) - compass (0.12.rc.1) + coffee-script-source (1.4.0) + compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.0.rc.3) - compass (~> 0.12.rc.0) + compass-rails (1.0.3) + compass (>= 0.12.2, < 0.14) cookiejar (0.3.0) dalli (2.6.0) - delayed_job (3.0.1) + delayed_job (3.0.4) activesupport (~> 3.0) - delayed_job_active_record (0.3.2) - activerecord (> 2.1.0) - delayed_job (~> 3.0.0) - em-http-request (1.0.1) + delayed_job_active_record (0.3.3) + activerecord (>= 2.1.0, < 4) + delayed_job (~> 3.0) + em-http-request (1.0.3) addressable (>= 2.2.3) cookiejar em-socksify eventmachine (>= 1.0.0.beta.4) http_parser.rb (>= 0.5.3) - em-socksify (0.1.0) - eventmachine + em-socksify (0.2.1) + eventmachine (>= 1.0.0.beta.4) erubis (2.7.0) - eventmachine (1.0.0.beta.4) + eventmachine (1.0.0) execjs (1.4.0) multi_json (~> 1.0) - factory_girl (2.6.4) - activesupport (>= 2.3.9) - factory_girl_rails (1.7.0) - factory_girl (~> 2.6.0) + factory_girl (4.1.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.1.0) + factory_girl (~> 4.1.0) railties (>= 3.0.0) - faye (0.8.0) + faye (0.8.8) cookiejar (>= 0.3.0) em-http-request (>= 0.3.0) eventmachine (>= 0.12.0) faye-websocket (>= 0.4.0) rack (>= 1.0.0) yajl-ruby (>= 1.0.0) - faye-websocket (0.4.1) + faye-websocket (0.4.6) eventmachine (>= 0.12.0) - fssm (0.2.8.1) + fssm (0.2.9) haml (3.1.7) hike (1.2.1) - hirb (0.6.1) + hirb (0.7.0) http_accept_language (1.0.2) http_parser.rb (0.5.3) i18n (0.6.1) inifile (2.0.2) - journey (1.0.3) - jquery-rails (2.0.1) - railties (>= 3.2.0, < 5.0) - thor (~> 0.14) - json (1.6.5) + journey (1.0.4) + jquery-rails (2.1.4) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + json (1.7.6) macaddr (1.6.1) systemu (~> 2.5.0) - mail (2.4.3) + mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.17.2) + mime-types (1.19) mini_magick (3.4) subexec (~> 0.2.1) multi_json (1.5.0) mysql2 (0.3.11) - nokogiri (1.5.5) + nokogiri (1.5.6) polyglot (0.3.3) - private_pub (1.0.1) + private_pub (1.0.3) faye - rack (1.4.1) + rack (1.4.4) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) - rails (3.2.2) - actionmailer (= 3.2.2) - actionpack (= 3.2.2) - activerecord (= 3.2.2) - activeresource (= 3.2.2) - activesupport (= 3.2.2) + rails (3.2.9) + actionmailer (= 3.2.9) + actionpack (= 3.2.9) + activerecord (= 3.2.9) + activeresource (= 3.2.9) + activesupport (= 3.2.9) bundler (~> 1.0) - railties (= 3.2.2) - railties (3.2.2) - actionpack (= 3.2.2) - activesupport (= 3.2.2) + railties (= 3.2.9) + railties (3.2.9) + actionpack (= 3.2.9) + activesupport (= 3.2.9) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.6) - rake (0.9.2.2) + thor (>= 0.14.6, < 2.0) + rake (10.0.3) rdoc (3.12) json (~> 1.4) - sass (3.1.15) - sass-rails (3.2.4) + sass (3.2.5) + sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - sprockets (2.1.2) + sprockets (2.2.2) hike (~> 1.2) + multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.7) state_machine (1.1.2) strong_parameters (0.1.6) actionpack (~> 3.0) activemodel (~> 3.0) railties (~> 3.0) - subexec (0.2.1) - systemu (2.5.1) - thor (0.14.6) + subexec (0.2.2) + systemu (2.5.2) + thor (0.16.0) tilt (1.3.3) - treetop (1.4.10) + treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) + tzinfo (0.3.35) uglifier (1.3.0) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) - uuid (2.3.5) + uuid (2.3.6) macaddr (~> 1.0) - will_paginate (3.0.3) + will_paginate (3.0.4) yajl-ruby (1.1.0) PLATFORMS @@ -200,8 +202,8 @@ DEPENDENCIES mysql2 nokogiri private_pub - rails (= 3.2.2) - sass-rails (~> 3.2.3) + rails (= 3.2.9) + sass-rails simple_form (= 2.0.1) sqlite3 state_machine diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 32e54f4..2aabd17 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -114,4 +114,4 @@ a.button { margin:10px 0;} @import "app/layouts/conference"; // Compatibility.. oh jeez. - @import "app/shared/ie"; \ No newline at end of file + @import "app/shared/ie"; diff --git a/app/assets/stylesheets/vendor/fancy-buttons/_fancy-buttons.scss b/app/assets/stylesheets/vendor/fancy-buttons/_fancy-buttons.scss index 2e85caf..7676dc8 100644 --- a/app/assets/stylesheets/vendor/fancy-buttons/_fancy-buttons.scss +++ b/app/assets/stylesheets/vendor/fancy-buttons/_fancy-buttons.scss @@ -1,9 +1,3 @@ -@import "compass/css3/gradient"; -@import "compass/css3/border-radius"; -@import "compass/css3/opacity"; -@import "compass/css3/text-shadow"; -@import "compass/css3/box-shadow"; -@import "compass/css3/background-clip"; @import "fancy-gradient"; $fb-gradient-style: glossy !default; @@ -60,19 +54,19 @@ $fb-line-height: 1.2em !default; @mixin fancy-button-matte($color: $fb-color, $font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width) { @include fancy-button-structure($font-size, $radius, $border-width); - @include fancy-button-colors-matte($color); + @include fancy-button-colors-matte($color); } @mixin fancy-button-custom($color: $fb-color, $font-size: $fb-font-size, $radius: $fb-radius, $border-width: $fb-border-width) { @include fancy-button-structure($font-size, $radius, $border-width); - @include fancy-button-colors-custom($color, $font-size, $radius, $border-width); + @include fancy-button-colors-custom($color, $font-size, $radius, $border-width); } @mixin fancy-button-colors-matte($color: $fb-color, $hover: 0, $active: 0) { $fb-current-style: $fb-gradient-style; $fb-gradient-style: matte; @include fancy-button-colors($color, $hover, $active); - $fb-gradient-style: $fb-current-style; + $fb-gradient-style: $fb-current-style; } @mixin fancy-button-colors-custom($color: $fb-color, $hover: 0, $active: 0) { diff --git a/config/application.rb b/config/application.rb index d09cf24..776cf81 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,7 +4,7 @@ require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require *Rails.groups(:assets => %w(development test)) + Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end @@ -21,19 +21,19 @@ module Gemeinschaft42c # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - + # --- rather use Apache + Passenger for SSL -----{ #config.plugins = [ :exception_notification, :ssl_requirement, :all ] - + #config.middleware.insert_before ActionDispatch::Static, "Rack::SSL" #config.middleware.insert_before ActionDispatch::Static, Rack::SSL, :exclude => proc { |env| env['HTTPS'] != 'on' } #config.force_ssl = true - + #require 'rack/ssl' #config.middleware.use Rack::SSL # -----------------------------------------------} - - + + # Activate observers that should always be running. # config.active_record.observers = :cacher, :garbage_collector, :forum_observer @@ -58,7 +58,7 @@ module Gemeinschaft42c # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' - + # Load the PhoneControllers config.autoload_paths += %W(#{config.root}/lib/phone_controllers) end -- cgit v1.2.3 From 473e6c52eff0576829138b59b99f83917ff6b0e9 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 10:31:01 +0100 Subject: faster try function --- misc/freeswitch/scripts/common/str.lua | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/misc/freeswitch/scripts/common/str.lua b/misc/freeswitch/scripts/common/str.lua index ca6dcd9..c366fda 100644 --- a/misc/freeswitch/scripts/common/str.lua +++ b/misc/freeswitch/scripts/common/str.lua @@ -5,23 +5,13 @@ module(...,package.seeall) function try(array, arguments) - local argument = arguments:match('^(.-)%.') or arguments; - local remaining_arguments = arguments:match('%.(.-)$'); - argument = tonumber(argument) or argument; + local result = array; - if argument and type(array) == 'table' then - if remaining_arguments then - if type(array[argument]) == 'table' then - return try(array[argument], remaining_arguments); - else - return nil; - end - else - return array[argument]; - end - end - - return nil; + arguments:gsub('([^%.]+)', function(entry) + local success, result = pcall(function() result = (result[tonumber(entry) or entry]); end); + end); + + return result; end -- to number -- cgit v1.2.3 From 1cf48357d936056e383a52a3410f87b89e1a9829 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 10:59:10 +0100 Subject: Upgraded Rails to 3.2.11 --- Gemfile | 2 +- Gemfile.lock | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Gemfile b/Gemfile index c3d86f9..6e020a2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.2.9' +gem 'rails', '3.2.11' gem 'bcrypt-ruby' gem 'sqlite3' gem 'mysql2' diff --git a/Gemfile.lock b/Gemfile.lock index dd98f2d..d82d82f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.9) - actionpack (= 3.2.9) + actionmailer (3.2.11) + actionpack (= 3.2.11) mail (~> 2.4.4) - actionpack (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) + actionpack (3.2.11) + activemodel (= 3.2.11) + activesupport (= 3.2.11) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) @@ -14,18 +14,18 @@ GEM rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) - activemodel (3.2.9) - activesupport (= 3.2.9) + activemodel (3.2.11) + activesupport (= 3.2.11) builder (~> 3.0.0) - activerecord (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) + activerecord (3.2.11) + activemodel (= 3.2.11) + activesupport (= 3.2.11) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) - activesupport (3.2.9) + activeresource (3.2.11) + activemodel (= 3.2.11) + activesupport (= 3.2.11) + activesupport (3.2.11) i18n (~> 0.6) multi_json (~> 1.0) acts_as_list (0.1.9) @@ -122,17 +122,17 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.9) - actionmailer (= 3.2.9) - actionpack (= 3.2.9) - activerecord (= 3.2.9) - activeresource (= 3.2.9) - activesupport (= 3.2.9) + rails (3.2.11) + actionmailer (= 3.2.11) + actionpack (= 3.2.11) + activerecord (= 3.2.11) + activeresource (= 3.2.11) + activesupport (= 3.2.11) bundler (~> 1.0) - railties (= 3.2.9) - railties (3.2.9) - actionpack (= 3.2.9) - activesupport (= 3.2.9) + railties (= 3.2.11) + railties (3.2.11) + actionpack (= 3.2.11) + activesupport (= 3.2.11) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -202,7 +202,7 @@ DEPENDENCIES mysql2 nokogiri private_pub - rails (= 3.2.9) + rails (= 3.2.11) sass-rails simple_form (= 2.0.1) sqlite3 -- cgit v1.2.3 From 962e07e58451f5d21cab9804191139be0f20189b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 11:39:35 +0100 Subject: Downgraded CanCan to version 1.6.7 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- app/controllers/users_controller.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 6e020a2..9f0fe8e 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gem 'rails', '3.2.11' gem 'bcrypt-ruby' gem 'sqlite3' gem 'mysql2' -gem 'cancan' +gem 'cancan', '1.6.7' gem 'state_machine' gem 'acts_as_list' gem 'dalli' # memcached diff --git a/Gemfile.lock b/Gemfile.lock index d82d82f..e4deaeb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,7 +36,7 @@ GEM builder (3.0.4) cache_digests (0.2.0) actionpack (>= 3.2) - cancan (1.6.8) + cancan (1.6.7) carrierwave (0.8.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -183,7 +183,7 @@ DEPENDENCIES bcrypt-ruby breadcrumbs_on_rails cache_digests - cancan + cancan (= 1.6.7) carrierwave coffee-rails (~> 3.2.1) compass-rails diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 454c26b..7af8e68 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,7 +10,7 @@ class UsersController < ApplicationController end def show - @phone_books = PhoneBook.accessible_by( Ability.new( @user ) ).all + @phone_books = PhoneBook.accessible_by( Ability.new( @user ), :read ) end def new -- cgit v1.2.3 From 57776d8aede3769dabd886d99ffb6bad2fd6eba0 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 11:53:17 +0100 Subject: Added a cache for the top nav and the footer. --- app/views/layouts/application.html.haml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c1a56f2..a2afbf8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -3,8 +3,7 @@ -%html.no-js{ :lang => "en" } - ~#OPTIMIZE Make html lang attribute reflect the actual language. +%html.no-js{ :lang => I18n.locale.to_s } %header %meta{ :charset => "utf-8" }/ @@ -19,7 +18,8 @@ %body #container - = render :partial => "shared/header" + - cache(['application_header', I18n.locale, current_user]) do + = render :partial => "shared/header" = render :partial => "shared/flash", :locals => { :flash => flash} #content{:role => 'main'} @@ -30,18 +30,19 @@ %h1= yield(:title) = yield - %footer#main - %ul - %li - %a{:href => "http://amooma.de/gemeinschaft/gs5"} Gemeinschaft #{GsParameter.get('GEMEINSCHAFT_VERSION')} - - if GuiFunction.display?('amooma_commercial_support_link_in_footer', current_user) + - cache(['application_footer', I18n.locale]) do + %footer#main + %ul %li - %a{:href => "http://amooma.de"} Kommerzieller Support und Consulting - - if GuiFunction.display?('gemeinschaft_mailinglist_link_in_footer', current_user) - %li - %a{:href => "https://groups.google.com/group/gs5-users/"} Kostenlose Mailingliste + %a{:href => "http://amooma.de/gemeinschaft/gs5"} Gemeinschaft #{GsParameter.get('GEMEINSCHAFT_VERSION')} + - if GuiFunction.display?('amooma_commercial_support_link_in_footer', current_user) + %li + %a{:href => "http://amooma.de"} Kommerzieller Support und Consulting + - if GuiFunction.display?('gemeinschaft_mailinglist_link_in_footer', current_user) + %li + %a{:href => "https://groups.google.com/group/gs5-users/"} Kostenlose Mailingliste - .amooma-logo - %span brought to you by - %a{ :target => '_blank', :href => "http://amooma.de/" } Amooma + .amooma-logo + %span brought to you by + %a{ :target => '_blank', :href => "http://amooma.de/" } Amooma -- cgit v1.2.3 From 113e3c6c6117fbeca7b9bf1f0e6dc26b0db9c407 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 16 Jan 2013 08:33:45 -0500 Subject: call_routes added --- app/controllers/call_routes_controller.rb | 41 +++++ app/helpers/call_routes_helper.rb | 2 + app/models/call_route.rb | 3 + app/views/call_routes/_form.html.haml | 7 + app/views/call_routes/_form_core.html.haml | 6 + app/views/call_routes/_index_core.html.haml | 17 ++ app/views/call_routes/edit.html.haml | 3 + app/views/call_routes/index.html.haml | 6 + app/views/call_routes/new.html.haml | 3 + app/views/call_routes/show.html.haml | 19 +++ config/locales/views/call_routes/de.yml | 60 +++++++ config/locales/views/call_routes/en.yml | 60 +++++++ config/routes.rb | 2 + db/migrate/20130116133243_create_call_routes.rb | 16 ++ misc/freeswitch/scripts/dialplan/router.lua | 203 ++++++++++++++++++++++++ test/functional/call_routes_controller_test.rb | 49 ++++++ test/unit/call_route_test.rb | 7 + 17 files changed, 504 insertions(+) create mode 100644 app/controllers/call_routes_controller.rb create mode 100644 app/helpers/call_routes_helper.rb create mode 100644 app/models/call_route.rb create mode 100644 app/views/call_routes/_form.html.haml create mode 100644 app/views/call_routes/_form_core.html.haml create mode 100644 app/views/call_routes/_index_core.html.haml create mode 100644 app/views/call_routes/edit.html.haml create mode 100644 app/views/call_routes/index.html.haml create mode 100644 app/views/call_routes/new.html.haml create mode 100644 app/views/call_routes/show.html.haml create mode 100644 config/locales/views/call_routes/de.yml create mode 100644 config/locales/views/call_routes/en.yml create mode 100644 db/migrate/20130116133243_create_call_routes.rb create mode 100644 misc/freeswitch/scripts/dialplan/router.lua create mode 100644 test/functional/call_routes_controller_test.rb create mode 100644 test/unit/call_route_test.rb diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb new file mode 100644 index 0000000..631339b --- /dev/null +++ b/app/controllers/call_routes_controller.rb @@ -0,0 +1,41 @@ +class CallRoutesController < ApplicationController + def index + @call_routes = CallRoute.all + end + + def show + @call_route = CallRoute.find(params[:id]) + end + + def new + @call_route = CallRoute.new + end + + def create + @call_route = CallRoute.new(params[:call_route]) + if @call_route.save + redirect_to @call_route, :notice => t('call_routes.controller.successfuly_created') + else + render :new + end + end + + def edit + @call_route = CallRoute.find(params[:id]) + end + + def update + @call_route = CallRoute.find(params[:id]) + if @call_route.update_attributes(params[:call_route]) + redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @call_route = CallRoute.find(params[:id]) + @call_route.destroy + redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed') + end +end diff --git a/app/helpers/call_routes_helper.rb b/app/helpers/call_routes_helper.rb new file mode 100644 index 0000000..dfe87dd --- /dev/null +++ b/app/helpers/call_routes_helper.rb @@ -0,0 +1,2 @@ +module CallRoutesHelper +end diff --git a/app/models/call_route.rb b/app/models/call_route.rb new file mode 100644 index 0000000..4cf2445 --- /dev/null +++ b/app/models/call_route.rb @@ -0,0 +1,3 @@ +class CallRoute < ActiveRecord::Base + attr_accessible :table, :name, :endpoint_type, :endpoint_id, :position +end diff --git a/app/views/call_routes/_form.html.haml b/app/views/call_routes/_form.html.haml new file mode 100644 index 0000000..1415852 --- /dev/null +++ b/app/views/call_routes/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@call_route) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('call_routes.form.submit') \ No newline at end of file diff --git a/app/views/call_routes/_form_core.html.haml b/app/views/call_routes/_form_core.html.haml new file mode 100644 index 0000000..4b97434 --- /dev/null +++ b/app/views/call_routes/_form_core.html.haml @@ -0,0 +1,6 @@ +.inputs + = f.input :table, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint') + = f.input :name, :label => t('call_routes.form.name.label'), :hint => conditional_hint('call_routes.form.name.hint') + = f.input :endpoint_type, :label => t('call_routes.form.endpoint_type.label'), :hint => conditional_hint('call_routes.form.endpoint_type.hint') + = f.input :endpoint_id, :label => t('call_routes.form.endpoint_id.label'), :hint => conditional_hint('call_routes.form.endpoint_id.hint') + = f.input :position, :label => t('call_routes.form.position.label'), :hint => conditional_hint('call_routes.form.position.hint') diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml new file mode 100644 index 0000000..6ea3af7 --- /dev/null +++ b/app/views/call_routes/_index_core.html.haml @@ -0,0 +1,17 @@ +%table + %tr + %th= t('call_routes.index.table') + %th= t('call_routes.index.name') + %th= t('call_routes.index.endpoint_type') + %th= t('call_routes.index.endpoint_id') + %th= t('call_routes.index.position') + + - reset_cycle + - for call_route in call_routes + %tr{:class => cycle('odd', 'even')} + %td= call_route.table + %td= call_route.name + %td= call_route.endpoint_type + %td= call_route.endpoint_id + %td= call_route.position + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route} \ No newline at end of file diff --git a/app/views/call_routes/edit.html.haml b/app/views/call_routes/edit.html.haml new file mode 100644 index 0000000..0ad46c5 --- /dev/null +++ b/app/views/call_routes/edit.html.haml @@ -0,0 +1,3 @@ +- title t("call_routes.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/call_routes/index.html.haml b/app/views/call_routes/index.html.haml new file mode 100644 index 0000000..687a9dc --- /dev/null +++ b/app/views/call_routes/index.html.haml @@ -0,0 +1,6 @@ +- title t("call_routes.index.page_title") + +- if @call_routes && @call_routes.count > 0 + = render "index_core", :call_routes => @call_routes + += render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} \ No newline at end of file diff --git a/app/views/call_routes/new.html.haml b/app/views/call_routes/new.html.haml new file mode 100644 index 0000000..0796d7f --- /dev/null +++ b/app/views/call_routes/new.html.haml @@ -0,0 +1,3 @@ +- title t("call_routes.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml new file mode 100644 index 0000000..31c3cb0 --- /dev/null +++ b/app/views/call_routes/show.html.haml @@ -0,0 +1,19 @@ +- title t("call_routes.show.page_title") + +%p + %strong= t('call_routes.show.table') + ":" + = @call_route.table +%p + %strong= t('call_routes.show.name') + ":" + = @call_route.name +%p + %strong= t('call_routes.show.endpoint_type') + ":" + = @call_route.endpoint_type +%p + %strong= t('call_routes.show.endpoint_id') + ":" + = @call_route.endpoint_id +%p + %strong= t('call_routes.show.position') + ":" + = @call_route.position + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route } \ No newline at end of file diff --git a/config/locales/views/call_routes/de.yml b/config/locales/views/call_routes/de.yml new file mode 100644 index 0000000..34af575 --- /dev/null +++ b/config/locales/views/call_routes/de.yml @@ -0,0 +1,60 @@ +de: + call_routes: + name: 'Call route' + controller: + successfuly_created: 'Call route wurde angelegt.' + successfuly_updated: 'Call route wurde aktualisiert.' + successfuly_destroyed: 'Call route wurde gelöscht.' + index: + page_title: 'Übersicht von Call route' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Call route' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Call route neu anlegen für %{resource}' + show: + page_title: 'Call route bearbeiten' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Call route neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Call route bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + table: + label: 'Table' + hint: '' + name: + label: 'Name' + hint: '' + endpoint_type: + label: 'Endpoint type' + hint: '' + endpoint_id: + label: 'Endpoint' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/call_routes/en.yml b/config/locales/views/call_routes/en.yml new file mode 100644 index 0000000..251f76e --- /dev/null +++ b/config/locales/views/call_routes/en.yml @@ -0,0 +1,60 @@ +en: + call_routes: + name: 'Call route' + controller: + successfuly_created: 'Successfully created Call route.' + successfuly_updated: 'Successfully updated Call route.' + successfuly_destroyed: 'Successfully destroyed Call route.' + index: + page_title: 'Listing Call route' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this Call route?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Call route for %{resource}' + show: + page_title: 'Show Call route' + table: 'Table' + name: 'Name' + endpoint_type: 'Endpoint type' + endpoint_id: 'Endpoint' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Call route' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Call route' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + table: + label: 'Table' + hint: '' + name: + label: 'Name' + hint: '' + endpoint_type: + label: 'Endpoint type' + hint: '' + endpoint_id: + label: 'Endpoint' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Submit' \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4e812c0..2834d69 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Gemeinschaft42c::Application.routes.draw do + resources :call_routes + resources :gateways do resources :gateway_settings resources :gateway_parameters diff --git a/db/migrate/20130116133243_create_call_routes.rb b/db/migrate/20130116133243_create_call_routes.rb new file mode 100644 index 0000000..c2d3f45 --- /dev/null +++ b/db/migrate/20130116133243_create_call_routes.rb @@ -0,0 +1,16 @@ +class CreateCallRoutes < ActiveRecord::Migration + def self.up + create_table :call_routes do |t| + t.string :table + t.string :name + t.string :endpoint_type + t.integer :endpoint_id + t.integer :position + t.timestamps + end + end + + def self.down + drop_table :call_routes + end +end diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua new file mode 100644 index 0000000..76d7ada --- /dev/null +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -0,0 +1,203 @@ +-- Gemeinschaft 5 module: call router class +-- (c) AMOOMA GmbH 2013 +-- + +module(...,package.seeall) + +Router = {} + +-- create route object +function Router.new(self, arg) + arg = arg or {} + object = arg.object or {} + setmetatable(object, self); + self.__index = self; + self.class = 'router'; + self.log = arg.log; + self.database = arg.database; + self.routes = arg.routes or {}; + self.caller = arg.caller; + self.variables = arg.variables or {}; + return object; +end + +function Router.build_tables(self) + local elements = { + { var_in = 'group', var_out = '', pattern = '^users$', replacement = '', action = 'not_match', mandatory = true }, + { var_in = 'destination_number', var_out = 'destination_number', pattern = '^1$', replacement = '+123456', action = 'not_match', mandatory = true }, + { var_in = 'caller_id_number', var_out = 'caller_id_number', pattern = '^100$', replacement = '+4930100', action = 'set_route_var', mandatory = false }, + } + + local elements2 = { + { var_in = 'group', var_out = '', pattern = '^users$', replacement = '', action = 'match', mandatory = true }, + { var_in = 'destination_number', var_out = 'destination_number', pattern = '^1$', replacement = '+123456', action = 'not_match', mandatory = true }, + { var_in = 'caller_id_number', var_out = 'caller_id_number', pattern = '^100$', replacement = '+4930100', action = 'set_route_var', mandatory = false }, + } + + local elements3 = { + { var_in = 'destination_number', var_out = 'destination_number', pattern = '^#31#(%d+)$', replacement = 'f-dcliron-%1', action = 'set_route_var', mandatory = false }, + } + + local elements4 = { + { var_in = 'destination_number', var_out = 'destination_number', pattern = '^(%d+)$', replacement = '%1', action = 'set_route_var', mandatory = true }, + { var_in = 'caller_id_number', var_out = 'caller_id_number', pattern = '^(.+)$', replacement = '+49%1', action = 'set_route_var', mandatory = false }, + } + + local routes = { + prerouting = { + { id = 10, name = 'feature codes', elements = elements3, endpoint_type = 'dialplanfunction', endpoint_id = 0 }, + }, + outbound = { + { id = 1, name = 'no users', elements = elements, endpoint_type = 'gateway', endpoint_id = 1, }, + { id = 2, name = 'all users', elements = elements2, endpoint_type = 'gateway', endpoint_id = 1, }, + { id = 3, name = 'all users', elements = elements2, endpoint_type = 'gateway', endpoint_id = 1, }, + }, + inbound = { + { id = 20, name = 'haeron', elements = elements4, endpoint_type = 'phonenumber', endpoint_id = 1, }, + }, + + }; + + return routes; +end + + +function Router.failover_table(self) + return { + ['603'] = true, + ['480'] = true, + UNALLOCATED_NUMBER = true, + NORMAL_TEMPORARY_FAILURE = true, + } +end + + +function Router.expand_variables(self, line) + return (line:gsub('{([%a%d_]+)}', function(captured) + return variables[captured] or ''; + end)) +end + + +function Router.set_parameter(self, action, name, value) + if action == 'set_session_var' then + self.log:debug('ROUTER_SET_SESSION_VARIABLE - ', name, ' = ', value); + self.caller[name] = value; + elseif action == 'set_channel_var' then + self.log:debug('ROUTER_SET_VARIABLE - ', name, ' = ', value); + self.caller:set_variable(name, value); + elseif action == 'export_channel_var' then + self.log:debug('ROUTER_EXPORT_VARIABLE - ', name, ' = ', value); + self.caller:export_variable(name, value); + elseif action == 'set_header' then + self.log:debug('ROUTER_SIP_HEADER - ', name, ': ', value); + self.caller:export_variable('sip_h_' .. name, value); + else + self.log:error('ROUTER_SET_PARAMERER - unknown action: ', action, ', ', name, ' = ', value); + end +end + + +function Router.element_match(self, pattern, search_string, replacement) + local variables_list = {}; + local success, result = pcall(string.find, search_string, pattern); + + if not success then + self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string); + elseif result then + return true, search_string:gsub(pattern, self:expand_variables(replacement, variables_list)); + end + + return false; +end + + +function Router.route_match(self, route) + local destination = { + gateway = 'gateway' .. route.endpoint_id, + ['type'] = route.endpoint_type, + id = route.endpoint_id, + actions = {} + }; + + local route_matches = false; + + for index=1, #route.elements do + local result = false; + local replacement = nil; + + local element = route.elements[index]; + if element.var_in == 'group' then + local groups = common.str.try(self.caller, 'auth_account.owner.groups'); + if not groups or type(groups) ~= 'table' then + if element.mandatory then + return false; + end + end + + for group_name, value in pairs(groups) do + result, replacement = self:element_match(tostring(element.pattern), tostring(group_name), tostring(element.replacement)); + if result then + break; + end + end + + else + local search_string = tostring(common.str.try(self.caller, element.var_in)) + result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); + end + + if element.action == 'not_match' then + result = not result; + end + + if not result then + if element.mandatory then + return false; + end + elseif element.action ~= 'match' and element.action ~= 'not_match' then + if element.action == 'set_route_var' then + destination[element.var_out] = replacement; + else + table.insert(destination.actions, {action = element.action, name = element.var_out, value = replacement}); + end + end + + if result then + route_matches = true; + end + end + + if route_matches then + return destination; + end; + + return nil; +end + + +function Router.route_run(self, table_name, phone_number, find_first) + local routing_tables = self:build_tables(); + local routing_table = routing_tables[table_name]; + + local routes = {}; + + if type(routing_table) == 'table' then + for index=1, #routing_table do + local route = self:route_match(routing_table[index], phone_number); + if route then + table.insert(routes, route); + self.log:info('ROUTE ', #routes,' - ', table_name,'=', routing_table[index].id, '/', routing_table[index].name, ', destination: ', route.type, '=', route.id); + if find_first then + return route; + end + else + self.log:debug('ROUTE_NO_MATCH - ', table_name, '=', routing_table[index].id, '/', routing_table[index].name); + end + end + end + + if not find_first then + return routes; + end +end diff --git a/test/functional/call_routes_controller_test.rb b/test/functional/call_routes_controller_test.rb new file mode 100644 index 0000000..77c0b2a --- /dev/null +++ b/test/functional/call_routes_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class CallRoutesControllerTest < ActionController::TestCase + setup do + @call_route = call_routes(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:call_routes) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create call_route" do + assert_difference('CallRoute.count') do + post :create, call_route: @call_route.attributes + end + + assert_redirected_to call_route_path(assigns(:call_route)) + end + + test "should show call_route" do + get :show, id: @call_route.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @call_route.to_param + assert_response :success + end + + test "should update call_route" do + put :update, id: @call_route.to_param, call_route: @call_route.attributes + assert_redirected_to call_route_path(assigns(:call_route)) + end + + test "should destroy call_route" do + assert_difference('CallRoute.count', -1) do + delete :destroy, id: @call_route.to_param + end + + assert_redirected_to call_routes_path + end +end diff --git a/test/unit/call_route_test.rb b/test/unit/call_route_test.rb new file mode 100644 index 0000000..5eb2e50 --- /dev/null +++ b/test/unit/call_route_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CallRouteTest < ActiveSupport::TestCase + def test_should_be_valid + assert CallRoute.new.valid? + end +end -- cgit v1.2.3 From 8c83a89c6fbfdb31cae8ea6fcf2fd50c12c076a5 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 16 Jan 2013 08:37:56 -0500 Subject: route_elements added --- app/controllers/route_elements_controller.rb | 41 ++++++++++++ app/helpers/route_elements_helper.rb | 2 + app/models/route_element.rb | 5 ++ app/views/route_elements/_form.html.haml | 7 ++ app/views/route_elements/_form_core.html.haml | 9 +++ app/views/route_elements/_index_core.html.haml | 23 +++++++ app/views/route_elements/edit.html.haml | 3 + app/views/route_elements/index.html.haml | 6 ++ app/views/route_elements/new.html.haml | 3 + app/views/route_elements/show.html.haml | 28 ++++++++ config/locales/views/route_elements/de.yml | 75 ++++++++++++++++++++++ config/locales/views/route_elements/en.yml | 75 ++++++++++++++++++++++ config/routes.rb | 2 + db/migrate/20130116133433_create_route_elements.rb | 19 ++++++ test/functional/route_elements_controller_test.rb | 49 ++++++++++++++ test/unit/route_element_test.rb | 7 ++ 16 files changed, 354 insertions(+) create mode 100644 app/controllers/route_elements_controller.rb create mode 100644 app/helpers/route_elements_helper.rb create mode 100644 app/models/route_element.rb create mode 100644 app/views/route_elements/_form.html.haml create mode 100644 app/views/route_elements/_form_core.html.haml create mode 100644 app/views/route_elements/_index_core.html.haml create mode 100644 app/views/route_elements/edit.html.haml create mode 100644 app/views/route_elements/index.html.haml create mode 100644 app/views/route_elements/new.html.haml create mode 100644 app/views/route_elements/show.html.haml create mode 100644 config/locales/views/route_elements/de.yml create mode 100644 config/locales/views/route_elements/en.yml create mode 100644 db/migrate/20130116133433_create_route_elements.rb create mode 100644 test/functional/route_elements_controller_test.rb create mode 100644 test/unit/route_element_test.rb diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb new file mode 100644 index 0000000..595a20d --- /dev/null +++ b/app/controllers/route_elements_controller.rb @@ -0,0 +1,41 @@ +class RouteElementsController < ApplicationController + def index + @route_elements = RouteElement.all + end + + def show + @route_element = RouteElement.find(params[:id]) + end + + def new + @route_element = RouteElement.new + end + + def create + @route_element = RouteElement.new(params[:route_element]) + if @route_element.save + redirect_to @route_element, :notice => t('route_elements.controller.successfuly_created') + else + render :new + end + end + + def edit + @route_element = RouteElement.find(params[:id]) + end + + def update + @route_element = RouteElement.find(params[:id]) + if @route_element.update_attributes(params[:route_element]) + redirect_to @route_element, :notice => t('route_elements.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @route_element = RouteElement.find(params[:id]) + @route_element.destroy + redirect_to route_elements_url, :notice => t('route_elements.controller.successfuly_destroyed') + end +end diff --git a/app/helpers/route_elements_helper.rb b/app/helpers/route_elements_helper.rb new file mode 100644 index 0000000..4262a50 --- /dev/null +++ b/app/helpers/route_elements_helper.rb @@ -0,0 +1,2 @@ +module RouteElementsHelper +end diff --git a/app/models/route_element.rb b/app/models/route_element.rb new file mode 100644 index 0000000..e845f24 --- /dev/null +++ b/app/models/route_element.rb @@ -0,0 +1,5 @@ +class RouteElement < ActiveRecord::Base + attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position + + belongs_to :call_route +end diff --git a/app/views/route_elements/_form.html.haml b/app/views/route_elements/_form.html.haml new file mode 100644 index 0000000..cfa4c6b --- /dev/null +++ b/app/views/route_elements/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@route_element) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('route_elements.form.submit') \ No newline at end of file diff --git a/app/views/route_elements/_form_core.html.haml b/app/views/route_elements/_form_core.html.haml new file mode 100644 index 0000000..7697cb0 --- /dev/null +++ b/app/views/route_elements/_form_core.html.haml @@ -0,0 +1,9 @@ +.inputs + = f.input :call_route_id, :label => t('route_elements.form.call_route_id.label'), :hint => conditional_hint('route_elements.form.call_route_id.hint') + = f.input :var_in, :label => t('route_elements.form.var_in.label'), :hint => conditional_hint('route_elements.form.var_in.hint') + = f.input :var_out, :label => t('route_elements.form.var_out.label'), :hint => conditional_hint('route_elements.form.var_out.hint') + = f.input :pattern, :label => t('route_elements.form.pattern.label'), :hint => conditional_hint('route_elements.form.pattern.hint') + = f.input :replacement, :label => t('route_elements.form.replacement.label'), :hint => conditional_hint('route_elements.form.replacement.hint') + = f.input :action, :label => t('route_elements.form.action.label'), :hint => conditional_hint('route_elements.form.action.hint') + = f.input :mandatory, :label => t('route_elements.form.mandatory.label'), :hint => conditional_hint('route_elements.form.mandatory.hint') + = f.input :position, :label => t('route_elements.form.position.label'), :hint => conditional_hint('route_elements.form.position.hint') diff --git a/app/views/route_elements/_index_core.html.haml b/app/views/route_elements/_index_core.html.haml new file mode 100644 index 0000000..63665fd --- /dev/null +++ b/app/views/route_elements/_index_core.html.haml @@ -0,0 +1,23 @@ +%table + %tr + %th= t('route_elements.index.call_route_id') + %th= t('route_elements.index.var_in') + %th= t('route_elements.index.var_out') + %th= t('route_elements.index.pattern') + %th= t('route_elements.index.replacement') + %th= t('route_elements.index.action') + %th= t('route_elements.index.mandatory') + %th= t('route_elements.index.position') + + - reset_cycle + - for route_element in route_elements + %tr{:class => cycle('odd', 'even')} + %td= route_element.call_route_id + %td= route_element.var_in + %td= route_element.var_out + %td= route_element.pattern + %td= route_element.replacement + %td= route_element.action + %td= route_element.mandatory + %td= route_element.position + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => route_element} \ No newline at end of file diff --git a/app/views/route_elements/edit.html.haml b/app/views/route_elements/edit.html.haml new file mode 100644 index 0000000..770eb6c --- /dev/null +++ b/app/views/route_elements/edit.html.haml @@ -0,0 +1,3 @@ +- title t("route_elements.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/route_elements/index.html.haml b/app/views/route_elements/index.html.haml new file mode 100644 index 0000000..b05236b --- /dev/null +++ b/app/views/route_elements/index.html.haml @@ -0,0 +1,6 @@ +- title t("route_elements.index.page_title") + +- if @route_elements && @route_elements.count > 0 + = render "index_core", :route_elements => @route_elements + += render :partial => 'shared/create_link', :locals => {:child_class => RouteElement} \ No newline at end of file diff --git a/app/views/route_elements/new.html.haml b/app/views/route_elements/new.html.haml new file mode 100644 index 0000000..903e808 --- /dev/null +++ b/app/views/route_elements/new.html.haml @@ -0,0 +1,3 @@ +- title t("route_elements.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/route_elements/show.html.haml b/app/views/route_elements/show.html.haml new file mode 100644 index 0000000..a439353 --- /dev/null +++ b/app/views/route_elements/show.html.haml @@ -0,0 +1,28 @@ +- title t("route_elements.show.page_title") + +%p + %strong= t('route_elements.show.call_route_id') + ":" + = @route_element.call_route_id +%p + %strong= t('route_elements.show.var_in') + ":" + = @route_element.var_in +%p + %strong= t('route_elements.show.var_out') + ":" + = @route_element.var_out +%p + %strong= t('route_elements.show.pattern') + ":" + = @route_element.pattern +%p + %strong= t('route_elements.show.replacement') + ":" + = @route_element.replacement +%p + %strong= t('route_elements.show.action') + ":" + = @route_element.action +%p + %strong= t('route_elements.show.mandatory') + ":" + = @route_element.mandatory +%p + %strong= t('route_elements.show.position') + ":" + = @route_element.position + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @route_element } \ No newline at end of file diff --git a/config/locales/views/route_elements/de.yml b/config/locales/views/route_elements/de.yml new file mode 100644 index 0000000..d2c6c39 --- /dev/null +++ b/config/locales/views/route_elements/de.yml @@ -0,0 +1,75 @@ +de: + route_elements: + name: 'Route element' + controller: + successfuly_created: 'Route element wurde angelegt.' + successfuly_updated: 'Route element wurde aktualisiert.' + successfuly_destroyed: 'Route element wurde gelöscht.' + index: + page_title: 'Übersicht von Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Route element' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Route element neu anlegen für %{resource}' + show: + page_title: 'Route element bearbeiten' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Route element neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Route element bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + call_route_id: + label: 'Call route' + hint: '' + var_in: + label: 'Var in' + hint: '' + var_out: + label: 'Var out' + hint: '' + pattern: + label: 'Pattern' + hint: '' + replacement: + label: 'Replacement' + hint: '' + action: + label: 'Action' + hint: '' + mandatory: + label: 'Mandatory' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/route_elements/en.yml b/config/locales/views/route_elements/en.yml new file mode 100644 index 0000000..1340309 --- /dev/null +++ b/config/locales/views/route_elements/en.yml @@ -0,0 +1,75 @@ +en: + route_elements: + name: 'Route element' + controller: + successfuly_created: 'Successfully created Route element.' + successfuly_updated: 'Successfully updated Route element.' + successfuly_destroyed: 'Successfully destroyed Route element.' + index: + page_title: 'Listing Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this Route element?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Route element for %{resource}' + show: + page_title: 'Show Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Route element' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Route element' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + call_route_id: + label: 'Call route' + hint: '' + var_in: + label: 'Var in' + hint: '' + var_out: + label: 'Var out' + hint: '' + pattern: + label: 'Pattern' + hint: '' + replacement: + label: 'Replacement' + hint: '' + action: + label: 'Action' + hint: '' + mandatory: + label: 'Mandatory' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Submit' \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2834d69..3874170 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Gemeinschaft42c::Application.routes.draw do + resources :route_elements + resources :call_routes resources :gateways do diff --git a/db/migrate/20130116133433_create_route_elements.rb b/db/migrate/20130116133433_create_route_elements.rb new file mode 100644 index 0000000..72f6894 --- /dev/null +++ b/db/migrate/20130116133433_create_route_elements.rb @@ -0,0 +1,19 @@ +class CreateRouteElements < ActiveRecord::Migration + def self.up + create_table :route_elements do |t| + t.integer :call_route_id + t.string :var_in + t.string :var_out + t.string :pattern + t.string :replacement + t.string :action + t.boolean :mandatory + t.integer :position + t.timestamps + end + end + + def self.down + drop_table :route_elements + end +end diff --git a/test/functional/route_elements_controller_test.rb b/test/functional/route_elements_controller_test.rb new file mode 100644 index 0000000..3d7afaa --- /dev/null +++ b/test/functional/route_elements_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class RouteElementsControllerTest < ActionController::TestCase + setup do + @route_element = route_elements(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:route_elements) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create route_element" do + assert_difference('RouteElement.count') do + post :create, route_element: @route_element.attributes + end + + assert_redirected_to route_element_path(assigns(:route_element)) + end + + test "should show route_element" do + get :show, id: @route_element.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @route_element.to_param + assert_response :success + end + + test "should update route_element" do + put :update, id: @route_element.to_param, route_element: @route_element.attributes + assert_redirected_to route_element_path(assigns(:route_element)) + end + + test "should destroy route_element" do + assert_difference('RouteElement.count', -1) do + delete :destroy, id: @route_element.to_param + end + + assert_redirected_to route_elements_path + end +end diff --git a/test/unit/route_element_test.rb b/test/unit/route_element_test.rb new file mode 100644 index 0000000..807a4ca --- /dev/null +++ b/test/unit/route_element_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RouteElementTest < ActiveSupport::TestCase + def test_should_be_valid + assert RouteElement.new.valid? + end +end -- cgit v1.2.3 From 0bf4d1350f5d2a07db874977674e5ae0ff0d4256 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 16 Jan 2013 08:38:54 -0500 Subject: route_elements belong to route --- app/models/call_route.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 4cf2445..eba247c 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -1,3 +1,5 @@ class CallRoute < ActiveRecord::Base attr_accessible :table, :name, :endpoint_type, :endpoint_id, :position + + has_many :route_elements, :dependent => :destroy end -- cgit v1.2.3 From 27921c7d5515169270b1739a70f10ad1bf4f4cd7 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 16:01:19 +0100 Subject: Added an empty heater rake task. --- lib/tasks/heater.rake | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lib/tasks/heater.rake diff --git a/lib/tasks/heater.rake b/lib/tasks/heater.rake new file mode 100644 index 0000000..7d026d9 --- /dev/null +++ b/lib/tasks/heater.rake @@ -0,0 +1,6 @@ +namespace :heater do + desc "Warm up the cache." + task :preheat => :environment do + + end +end \ No newline at end of file -- cgit v1.2.3 From be11e945ed0983c01b86ba2c598b035cb762f245 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 16:04:46 +0100 Subject: set failover table --- db/migrate/20130116145500_set_routing_variables.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrate/20130116145500_set_routing_variables.rb diff --git a/db/migrate/20130116145500_set_routing_variables.rb b/db/migrate/20130116145500_set_routing_variables.rb new file mode 100644 index 0000000..abd8fa6 --- /dev/null +++ b/db/migrate/20130116145500_set_routing_variables.rb @@ -0,0 +1,12 @@ +class SetRoutingVariables < ActiveRecord::Migration + def up + GsParameter.create(:entity => 'call_route', :section => 'failover', :name => '603', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:entity => 'call_route', :section => 'failover', :name => '480', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:entity => 'call_route', :section => 'failover', :name => 'UNALLOCATED_NUMBER', :value => 'true', :class_type => 'Boolean') + GsParameter.create(:entity => 'call_route', :section => 'failover', :name => 'NORMAL_TEMPORARY_FAILURE', :value => 'true', :class_type => 'Boolean') + end + + def down + GsParameter.where(:entity => 'call_route', :section => 'failover').destroy_all + end +end -- cgit v1.2.3 From ac7ebc61a99cd638d7f23c9c99dcd1329e6040b6 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 16:06:52 +0100 Subject: call router added --- misc/freeswitch/scripts/dialplan/router.lua | 181 ++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 misc/freeswitch/scripts/dialplan/router.lua diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua new file mode 100644 index 0000000..2071288 --- /dev/null +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -0,0 +1,181 @@ +-- Gemeinschaft 5 module: call router class +-- (c) AMOOMA GmbH 2013 +-- + +module(...,package.seeall) + +Router = {} + +-- create route object +function Router.new(self, arg) + arg = arg or {} + object = arg.object or {} + setmetatable(object, self); + self.__index = self; + self.class = 'router'; + self.log = arg.log; + self.database = arg.database; + self.routes = arg.routes or {}; + self.caller = arg.caller; + self.variables = arg.variables or {}; + return object; +end + + +function Router.read_table(self, table_name) + local routing_table = {}; + + local sql_query = 'SELECT * \ + FROM `call_routes` `a` \ + JOIN `route_elements` `b` ON `a`.`id` = `b`.`call_route_id`\ + WHERE `a`.`table` = "' .. table_name .. '" \ + ORDER BY `a`.`position`, `b`.`position`'; + + local last_id = 0; + self.database:query(sql_query, function(route) + if last_id ~= tonumber(route.call_route_id) then + last_id = tonumber(route.call_route_id); + table.insert(routing_table, {id = route.call_route_id, name = route.name, endpoint_type = route.endpoint_type , endpoint_id = route.endpoint_id, elements = {} }); + end + + table.insert(routing_table[#routing_table].elements, { + var_in = route.var_in, + var_out = route.var_out, + pattern = route.pattern, + replacement = route.replacement, + action = route.action, + mandatory = common.str.to_b(route.mandatory), + }); + end); + + return routing_table; +end + + +function Router.expand_variables(self, line) + return (line:gsub('{([%a%d_]+)}', function(captured) + return variables[captured] or ''; + end)) +end + + +function Router.set_parameter(self, action, name, value) + if action == 'set_session_var' then + self.log:debug('ROUTER_SET_SESSION_VARIABLE - ', name, ' = ', value); + self.caller[name] = value; + elseif action == 'set_channel_var' then + self.log:debug('ROUTER_SET_VARIABLE - ', name, ' = ', value); + self.caller:set_variable(name, value); + elseif action == 'export_channel_var' then + self.log:debug('ROUTER_EXPORT_VARIABLE - ', name, ' = ', value); + self.caller:export_variable(name, value); + elseif action == 'set_header' then + self.log:debug('ROUTER_SIP_HEADER - ', name, ': ', value); + self.caller:export_variable('sip_h_' .. name, value); + else + self.log:error('ROUTER_SET_PARAMERER - unknown action: ', action, ', ', name, ' = ', value); + end +end + + +function Router.element_match(self, pattern, search_string, replacement) + local variables_list = {}; + local success, result = pcall(string.find, search_string, pattern); + + if not success then + self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string); + elseif result then + return true, search_string:gsub(pattern, self:expand_variables(replacement, variables_list)); + end + + return false; +end + + +function Router.route_match(self, route) + local destination = { + gateway = 'gateway' .. route.endpoint_id, + ['type'] = route.endpoint_type, + id = route.endpoint_id, + actions = {} + }; + + local route_matches = false; + + for index=1, #route.elements do + local result = false; + local replacement = nil; + + local element = route.elements[index]; + if element.var_in == 'group' then + local groups = common.str.try(self.caller, 'auth_account.owner.groups'); + if not groups or type(groups) ~= 'table' then + if element.mandatory then + return false; + end + end + + for group_name, value in pairs(groups) do + result, replacement = self:element_match(tostring(element.pattern), tostring(group_name), tostring(element.replacement)); + if result then + break; + end + end + + else + local search_string = tostring(common.str.try(self.caller, element.var_in)) + result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); + end + + if element.action == 'not_match' then + result = not result; + end + + if not result then + if element.mandatory then + return false; + end + elseif element.action ~= 'match' and element.action ~= 'not_match' then + if element.action == 'set_route_var' then + destination[element.var_out] = replacement; + else + table.insert(destination.actions, {action = element.action, name = element.var_out, value = replacement}); + end + end + + if result then + route_matches = true; + end + end + + if route_matches then + return destination; + end; + + return nil; +end + + +function Router.route_run(self, table_name, phone_number, find_first) + local routing_table = self:read_table(table_name); + local routes = {}; + + if type(routing_table) == 'table' then + for index=1, #routing_table do + local route = self:route_match(routing_table[index], phone_number); + if route then + table.insert(routes, route); + self.log:info('ROUTE ', #routes,' - ', table_name,'=', routing_table[index].id, '/', routing_table[index].name, ', destination: ', route.type, '=', route.id); + if find_first then + return route; + end + else + self.log:debug('ROUTE_NO_MATCH - ', table_name, '=', routing_table[index].id, '/', routing_table[index].name); + end + end + end + + if not find_first then + return routes; + end +end -- cgit v1.2.3 From d95917ecbc5d0efbc1b4b67c1974d7f0421eebf9 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 16:07:40 +0100 Subject: set gateway prefix --- misc/freeswitch/scripts/common/gateway.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 6e9fbfb..5c76aba 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -16,6 +16,7 @@ function Gateway.new(self, arg) self.log = arg.log; self.database = arg.database; self.record = arg.record; + self.GATEWAY_PREFIX = 'gateway'; return object; end -- cgit v1.2.3 From 7b3582a93d939ae131a608f500654065e8bd18cd Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 16:08:11 +0100 Subject: set gateway name --- misc/freeswitch/scripts/configuration.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/configuration.lua b/misc/freeswitch/scripts/configuration.lua index b4dc0f6..1162e97 100644 --- a/misc/freeswitch/scripts/configuration.lua +++ b/misc/freeswitch/scripts/configuration.lua @@ -49,7 +49,7 @@ function gateways(database, profile_name) gateways_xml = gateways_xml .. xml:element{ 'gateway', - name = gateway.name, + name = gateway_class.GATEWAY_PREFIX .. gateway.id, xml:from_hash('param', parameters, 'name', 'value'), }; end -- cgit v1.2.3 From dc68dbecc380e94322aa2777fcbb5be1f4b0af99 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 16:08:50 +0100 Subject: database driven routing tables --- misc/freeswitch/scripts/dialplan/dialplan.lua | 87 ++++++++++++++++----------- 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 88670ca..32f59c2 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -343,12 +343,6 @@ function Dialplan.destination_new(self, arg) end -function Dialplan.routes_get(self, destination) - require 'dialplan.route' - return dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = self.routes }:outbound(self.caller, destination.number); -end - - function Dialplan.set_caller_picture(self, entry_id, entry_type, image) entry_type = entry_type:lower(); if entry_type == 'user' then @@ -629,9 +623,11 @@ function Dialplan.callthrough(self, destination) return { continue = false, code = 404, phrase = 'No destination' } end - local route = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = self.routes }:prerouting(self.caller, destination_number); - if route and route.value then - destination_number = route.value; + require 'dialplan.router' + local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('prerouting', destination_number, true); + + if route and route.destination_number then + destination_number = route.destination_number; end if not callthrough:whitelist(destination_number) then @@ -760,7 +756,9 @@ function Dialplan.switch(self, destination) return self:dialplanfunction(destination); elseif not common.str.blank(destination.number) then local result = { continue = false, code = 404, phrase = 'No route' } - local routes = self:routes_get(destination); + + require 'dialplan.router' + local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('outbound', destination.number); if not routes or #routes == 0 then self.log:notice('SWITCH - no route - number: ', destination.number); @@ -802,26 +800,26 @@ function Dialplan.switch(self, destination) self.caller:set_callee_id(destination.callee_id_number, destination.callee_id_name); for index, route in ipairs(routes) do - if route.class == 'hangup' then + if route.endpoint_type == 'hangup' then return { continue = false, code = route.endpoint, phrase = route.phrase, cause = route.value } end - if route.class == 'forward' then + if route.endpoint_type == 'forward' then return { continue = true, call_forwarding = { number = route.value, service = 'route', type = 'phonenumber' }} end - destination.gateway = route.endpoint; - destination.type = route.class; - destination.number = route.value; - destination.caller_id_number = route.caller_id_number; - destination.caller_id_name = route.caller_id_name; + + for key, value in pairs(route) do + destination[key] = value; + end + result = self:dial(destination); if result.continue == false then break; end - if common.str.to_b(self.routes.failover[tostring(result.code)]) == true then + if common.str.to_b(self.route_failover[tostring(result.code)]) == true then self.log:info('SWITCH - failover - code: ', result.code); - elseif common.str.to_b(self.routes.failover[tostring(result.cause)]) == true then + elseif common.str.to_b(self.route_failover[tostring(result.cause)]) == true then self.log:info('SWITCH - failover - cause: ', result.cause); else self.log:info('SWITCH - no failover - cause: ', result.cause, ', code: ', result.code); @@ -839,7 +837,8 @@ end function Dialplan.run(self, destination) require 'common.str'; - + require 'dialplan.router'; + self.caller:set_variable('hangup_after_bridge', false); self.caller:set_variable('bridge_early_media', 'true'); self.caller:set_variable('default_language', self.default_language); @@ -855,35 +854,55 @@ function Dialplan.run(self, destination) end end - self.routes = common.configuration_file.get('/opt/freeswitch/scripts/ini/routes.ini'); self.caller.domain_local = self.domain; self:retrieve_caller_data(); + self.route_failover = common.configuration_table.get(self.database, 'call_route', 'failover'); if not destination or destination.type == 'unknown' then - require 'dialplan.route' local route = nil; - if self.caller.gateway then if not common.str.blank(self.caller.gateway.settings.number_source) then self.log:debug('INBOUND_NUMBER: number_source: ', self.caller.gateway.settings.number_source, ', number: ', self.caller:to_s(self.caller.gateway.settings.number_source)); self.caller.destination_number = self.caller:to_s(self.caller.gateway.settings.number_source); end - local route_object = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = self.routes }; - route = route_object:inbound(self.caller, self.caller.destination_number); - local inbound_caller_id_number = route_object:inbound_cid_number(self.caller, self.caller.gateway_name, 'gateway'); - route_object.expandable.caller_id_number = inbound_caller_id_number; - local inbound_caller_id_name = route_object:inbound_cid_name(self.caller, self.caller.gateway_name, 'gateway'); - self.log:info('INBOUND_CALLER_ID_REWRITE - number: ', inbound_caller_id_number, ', name: ', inbound_caller_id_name); - self.caller.caller_id_number = inbound_caller_id_number or self.caller.caller_id_number; - self.caller.caller_id_name = inbound_caller_id_name or self.caller.caller_id_name; - self.caller.caller_phone_numbers[1] = self.caller.caller_id_number; + route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('inbound', self.caller.destination_number, true); + if route then + + local ignore_keys = { + gateway = true, + ['type'] = true, + actions = true, + }; + + for key, value in pairs(route) do + if not ignore_keys[key] then + self.caller[key] = value; + end + end + + self.caller.caller_phone_numbers[1] = self.caller.caller_id_number; + else + self.log:notice('INBOUND - no route'); + end + + if false then + local route_object = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = self.routes }; + route = route_object:inbound(self.caller, self.caller.destination_number); + local inbound_caller_id_number = route_object:inbound_cid_number(self.caller, self.caller.gateway_name, 'gateway'); + route_object.expandable.caller_id_number = inbound_caller_id_number; + local inbound_caller_id_name = route_object:inbound_cid_name(self.caller, self.caller.gateway_name, 'gateway'); + self.log:info('INBOUND_CALLER_ID_REWRITE - number: ', inbound_caller_id_number, ', name: ', inbound_caller_id_name); + self.caller.caller_id_number = inbound_caller_id_number or self.caller.caller_id_number; + self.caller.caller_id_name = inbound_caller_id_name or self.caller.caller_id_name; + self.caller.caller_phone_numbers[1] = self.caller.caller_id_number; + end else - route = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = self.routes }:prerouting(self.caller, self.caller.destination_number); + route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('prerouting', self.caller.destination_number, true); end if route then - destination = self:destination_new{ number = route.value } + destination = self:destination_new{ ['type'] = route.type, id = route.id, number = route.destination_number } self.caller.destination_number = destination.number; self.caller.destination = destination; elseif not destination or destination.type == 'unknown' then -- cgit v1.2.3 From 87aa843f920c2961496da669df4bba035c08aa1c Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 16:12:48 +0100 Subject: call router added --- misc/freeswitch/scripts/dialplan/router.lua | 181 ++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 misc/freeswitch/scripts/dialplan/router.lua diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua new file mode 100644 index 0000000..2071288 --- /dev/null +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -0,0 +1,181 @@ +-- Gemeinschaft 5 module: call router class +-- (c) AMOOMA GmbH 2013 +-- + +module(...,package.seeall) + +Router = {} + +-- create route object +function Router.new(self, arg) + arg = arg or {} + object = arg.object or {} + setmetatable(object, self); + self.__index = self; + self.class = 'router'; + self.log = arg.log; + self.database = arg.database; + self.routes = arg.routes or {}; + self.caller = arg.caller; + self.variables = arg.variables or {}; + return object; +end + + +function Router.read_table(self, table_name) + local routing_table = {}; + + local sql_query = 'SELECT * \ + FROM `call_routes` `a` \ + JOIN `route_elements` `b` ON `a`.`id` = `b`.`call_route_id`\ + WHERE `a`.`table` = "' .. table_name .. '" \ + ORDER BY `a`.`position`, `b`.`position`'; + + local last_id = 0; + self.database:query(sql_query, function(route) + if last_id ~= tonumber(route.call_route_id) then + last_id = tonumber(route.call_route_id); + table.insert(routing_table, {id = route.call_route_id, name = route.name, endpoint_type = route.endpoint_type , endpoint_id = route.endpoint_id, elements = {} }); + end + + table.insert(routing_table[#routing_table].elements, { + var_in = route.var_in, + var_out = route.var_out, + pattern = route.pattern, + replacement = route.replacement, + action = route.action, + mandatory = common.str.to_b(route.mandatory), + }); + end); + + return routing_table; +end + + +function Router.expand_variables(self, line) + return (line:gsub('{([%a%d_]+)}', function(captured) + return variables[captured] or ''; + end)) +end + + +function Router.set_parameter(self, action, name, value) + if action == 'set_session_var' then + self.log:debug('ROUTER_SET_SESSION_VARIABLE - ', name, ' = ', value); + self.caller[name] = value; + elseif action == 'set_channel_var' then + self.log:debug('ROUTER_SET_VARIABLE - ', name, ' = ', value); + self.caller:set_variable(name, value); + elseif action == 'export_channel_var' then + self.log:debug('ROUTER_EXPORT_VARIABLE - ', name, ' = ', value); + self.caller:export_variable(name, value); + elseif action == 'set_header' then + self.log:debug('ROUTER_SIP_HEADER - ', name, ': ', value); + self.caller:export_variable('sip_h_' .. name, value); + else + self.log:error('ROUTER_SET_PARAMERER - unknown action: ', action, ', ', name, ' = ', value); + end +end + + +function Router.element_match(self, pattern, search_string, replacement) + local variables_list = {}; + local success, result = pcall(string.find, search_string, pattern); + + if not success then + self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string); + elseif result then + return true, search_string:gsub(pattern, self:expand_variables(replacement, variables_list)); + end + + return false; +end + + +function Router.route_match(self, route) + local destination = { + gateway = 'gateway' .. route.endpoint_id, + ['type'] = route.endpoint_type, + id = route.endpoint_id, + actions = {} + }; + + local route_matches = false; + + for index=1, #route.elements do + local result = false; + local replacement = nil; + + local element = route.elements[index]; + if element.var_in == 'group' then + local groups = common.str.try(self.caller, 'auth_account.owner.groups'); + if not groups or type(groups) ~= 'table' then + if element.mandatory then + return false; + end + end + + for group_name, value in pairs(groups) do + result, replacement = self:element_match(tostring(element.pattern), tostring(group_name), tostring(element.replacement)); + if result then + break; + end + end + + else + local search_string = tostring(common.str.try(self.caller, element.var_in)) + result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); + end + + if element.action == 'not_match' then + result = not result; + end + + if not result then + if element.mandatory then + return false; + end + elseif element.action ~= 'match' and element.action ~= 'not_match' then + if element.action == 'set_route_var' then + destination[element.var_out] = replacement; + else + table.insert(destination.actions, {action = element.action, name = element.var_out, value = replacement}); + end + end + + if result then + route_matches = true; + end + end + + if route_matches then + return destination; + end; + + return nil; +end + + +function Router.route_run(self, table_name, phone_number, find_first) + local routing_table = self:read_table(table_name); + local routes = {}; + + if type(routing_table) == 'table' then + for index=1, #routing_table do + local route = self:route_match(routing_table[index], phone_number); + if route then + table.insert(routes, route); + self.log:info('ROUTE ', #routes,' - ', table_name,'=', routing_table[index].id, '/', routing_table[index].name, ', destination: ', route.type, '=', route.id); + if find_first then + return route; + end + else + self.log:debug('ROUTE_NO_MATCH - ', table_name, '=', routing_table[index].id, '/', routing_table[index].name); + end + end + end + + if not find_first then + return routes; + end +end -- cgit v1.2.3 From 0ee17f52f8ad337c1240b4c55dbd8f6c6c74dc90 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 16:32:59 +0100 Subject: Fixed routes and breadcrumbs. #106 --- app/controllers/call_routes_controller.rb | 19 +++++++++----- app/controllers/route_elements_controller.rb | 36 +++++++++++++++++++------- app/models/call_route.rb | 7 +++++ app/models/route_element.rb | 5 ++++ app/views/route_elements/_form.html.haml | 2 +- app/views/route_elements/_form_core.html.haml | 1 - app/views/route_elements/_index_core.html.haml | 4 +-- app/views/route_elements/index.html.haml | 2 +- app/views/route_elements/show.html.haml | 5 +--- config/routes.rb | 6 ++--- db/schema.rb | 25 +++++++++++++++++- 11 files changed, 82 insertions(+), 30 deletions(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 631339b..41abe6d 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -1,14 +1,15 @@ class CallRoutesController < ApplicationController + load_and_authorize_resource :call_route + + before_filter :spread_breadcrumbs + def index - @call_routes = CallRoute.all end def show - @call_route = CallRoute.find(params[:id]) end def new - @call_route = CallRoute.new end def create @@ -21,11 +22,9 @@ class CallRoutesController < ApplicationController end def edit - @call_route = CallRoute.find(params[:id]) end def update - @call_route = CallRoute.find(params[:id]) if @call_route.update_attributes(params[:call_route]) redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated') else @@ -34,8 +33,16 @@ class CallRoutesController < ApplicationController end def destroy - @call_route = CallRoute.find(params[:id]) @call_route.destroy redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed') end + + private + def spread_breadcrumbs + add_breadcrumb t("call_routes.index.page_title"), call_routes_path + if @call_route && !@call_route.new_record? + add_breadcrumb @call_route, call_route_path(@call_route) + end + end + end diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb index 595a20d..699fcc6 100644 --- a/app/controllers/route_elements_controller.rb +++ b/app/controllers/route_elements_controller.rb @@ -1,41 +1,57 @@ class RouteElementsController < ApplicationController + load_and_authorize_resource :call_route + load_and_authorize_resource :route_element, :through => [:call_route] + + before_filter :spread_breadcrumbs + def index - @route_elements = RouteElement.all + @route_elements = @call_route.route_elements end def show - @route_element = RouteElement.find(params[:id]) + @route_element = @call_route.route_elements.find(params[:id]) end def new - @route_element = RouteElement.new + @route_element = @call_route.route_elements.build end def create - @route_element = RouteElement.new(params[:route_element]) + @route_element = @call_route.route_elements.build(params[:route_element]) if @route_element.save - redirect_to @route_element, :notice => t('route_elements.controller.successfuly_created') + redirect_to [@call_route, @route_element], :notice => t('route_elements.controller.successfuly_created') else render :new end end def edit - @route_element = RouteElement.find(params[:id]) + @route_element = @call_route.route_elements.find(params[:id]) end def update - @route_element = RouteElement.find(params[:id]) + @route_element = @call_route.route_elements.find(params[:id]) if @route_element.update_attributes(params[:route_element]) - redirect_to @route_element, :notice => t('route_elements.controller.successfuly_updated') + redirect_to [@call_route, @route_element], :notice => t('route_elements.controller.successfuly_updated') else render :edit end end def destroy - @route_element = RouteElement.find(params[:id]) + @route_element = @call_route.route_elements.find(params[:id]) @route_element.destroy - redirect_to route_elements_url, :notice => t('route_elements.controller.successfuly_destroyed') + redirect_to call_route_route_elements_path(@call_route), :notice => t('route_elements.controller.successfuly_destroyed') end + + private + def spread_breadcrumbs + add_breadcrumb t("call_routes.index.page_title"), call_routes_path + add_breadcrumb @call_route, call_route_path(@call_route) + add_breadcrumb t("route_elements.index.page_title"), call_route_route_elements_path(@call_route) + if @route_element && !@route_element.new_record? + add_breadcrumb @route_element, call_route_route_element_path(@call_route, @route_element) + end + end + end diff --git a/app/models/call_route.rb b/app/models/call_route.rb index eba247c..de0f68a 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -2,4 +2,11 @@ class CallRoute < ActiveRecord::Base attr_accessible :table, :name, :endpoint_type, :endpoint_id, :position has_many :route_elements, :dependent => :destroy + + validates :name, + :presence => true + + def to_s + name.to_s + end end diff --git a/app/models/route_element.rb b/app/models/route_element.rb index e845f24..11bb54a 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -2,4 +2,9 @@ class RouteElement < ActiveRecord::Base attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position belongs_to :call_route + + def to_s + "#{var_in} #{var_out}" + end + end diff --git a/app/views/route_elements/_form.html.haml b/app/views/route_elements/_form.html.haml index cfa4c6b..8feacaa 100644 --- a/app/views/route_elements/_form.html.haml +++ b/app/views/route_elements/_form.html.haml @@ -1,4 +1,4 @@ -= simple_form_for(@route_element) do |f| += simple_form_for([@call_route, @route_element]) do |f| = f.error_notification = render "form_core", :f => f diff --git a/app/views/route_elements/_form_core.html.haml b/app/views/route_elements/_form_core.html.haml index 7697cb0..133d1df 100644 --- a/app/views/route_elements/_form_core.html.haml +++ b/app/views/route_elements/_form_core.html.haml @@ -1,5 +1,4 @@ .inputs - = f.input :call_route_id, :label => t('route_elements.form.call_route_id.label'), :hint => conditional_hint('route_elements.form.call_route_id.hint') = f.input :var_in, :label => t('route_elements.form.var_in.label'), :hint => conditional_hint('route_elements.form.var_in.hint') = f.input :var_out, :label => t('route_elements.form.var_out.label'), :hint => conditional_hint('route_elements.form.var_out.hint') = f.input :pattern, :label => t('route_elements.form.pattern.label'), :hint => conditional_hint('route_elements.form.pattern.hint') diff --git a/app/views/route_elements/_index_core.html.haml b/app/views/route_elements/_index_core.html.haml index 63665fd..c1df665 100644 --- a/app/views/route_elements/_index_core.html.haml +++ b/app/views/route_elements/_index_core.html.haml @@ -1,6 +1,5 @@ %table %tr - %th= t('route_elements.index.call_route_id') %th= t('route_elements.index.var_in') %th= t('route_elements.index.var_out') %th= t('route_elements.index.pattern') @@ -12,7 +11,6 @@ - reset_cycle - for route_element in route_elements %tr{:class => cycle('odd', 'even')} - %td= route_element.call_route_id %td= route_element.var_in %td= route_element.var_out %td= route_element.pattern @@ -20,4 +18,4 @@ %td= route_element.action %td= route_element.mandatory %td= route_element.position - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => route_element} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => @call_route, :child => route_element} \ No newline at end of file diff --git a/app/views/route_elements/index.html.haml b/app/views/route_elements/index.html.haml index b05236b..8a6f7bc 100644 --- a/app/views/route_elements/index.html.haml +++ b/app/views/route_elements/index.html.haml @@ -3,4 +3,4 @@ - if @route_elements && @route_elements.count > 0 = render "index_core", :route_elements => @route_elements -= render :partial => 'shared/create_link', :locals => {:child_class => RouteElement} \ No newline at end of file += render :partial => 'shared/create_link', :locals => {:parent => @call_route, :child_class => RouteElement} \ No newline at end of file diff --git a/app/views/route_elements/show.html.haml b/app/views/route_elements/show.html.haml index a439353..8e41f80 100644 --- a/app/views/route_elements/show.html.haml +++ b/app/views/route_elements/show.html.haml @@ -1,8 +1,5 @@ - title t("route_elements.show.page_title") -%p - %strong= t('route_elements.show.call_route_id') + ":" - = @route_element.call_route_id %p %strong= t('route_elements.show.var_in') + ":" = @route_element.var_in @@ -25,4 +22,4 @@ %strong= t('route_elements.show.position') + ":" = @route_element.position -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @route_element } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @call_route, :child => @route_element } \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3874170..249c947 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,8 @@ Gemeinschaft42c::Application.routes.draw do - resources :route_elements - - resources :call_routes + resources :call_routes do + resources :route_elements + end resources :gateways do resources :gateway_settings diff --git a/db/schema.rb b/db/schema.rb index bc51504..898faac 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 => 20130113090705) do +ActiveRecord::Schema.define(:version => 20130116133433) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -176,6 +176,16 @@ ActiveRecord::Schema.define(:version => 20130113090705) do t.datetime "updated_at", :null => false end + create_table "call_routes", :force => true do |t| + t.string "table" + t.string "name" + t.string "endpoint_type" + t.integer "endpoint_id" + t.integer "position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "calls", :id => false, :force => true do |t| t.string "call_uuid" t.string "call_created", :limit => 128 @@ -806,6 +816,19 @@ ActiveRecord::Schema.define(:version => 20130113090705) do t.datetime "updated_at", :null => false end + create_table "route_elements", :force => true do |t| + t.integer "call_route_id" + t.string "var_in" + t.string "var_out" + t.string "pattern" + t.string "replacement" + t.string "action" + t.boolean "mandatory" + t.integer "position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "sessions", :force => true do |t| t.string "session_id", :null => false t.text "data" -- cgit v1.2.3 From 0d5fd7ba5092b4d00826f3572448bb54ac2ec983 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 17:14:12 +0100 Subject: Limit call_histories to 1000 and add caching. --- app/controllers/call_histories_controller.rb | 2 + app/views/call_histories/_index_core.html.haml | 119 +++++++++++++------------ 2 files changed, 63 insertions(+), 58 deletions(-) diff --git a/app/controllers/call_histories_controller.rb b/app/controllers/call_histories_controller.rb index f711f34..5335ed3 100644 --- a/app/controllers/call_histories_controller.rb +++ b/app/controllers/call_histories_controller.rb @@ -34,6 +34,8 @@ class CallHistoriesController < ApplicationController if ! @type.blank? @call_histories = @call_histories.where(:entry_type => @type) end + + @call_histories = @call_histories.order(:created_at).reverse_order.limit(1000) end diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index 2d7658a..4ed4fc4 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -1,64 +1,67 @@ = form_tag(destroy_multiple_sip_account_call_histories_path(@sip_account), :method => :delete, :id => 'call_history_form') do %header.entries-nav= render :partial => "call_histories/navigation" .content - %table - - reset_cycle - - for call_history in call_histories - - phone_number = call_history.display_number - - voicemail_message = call_history.voicemail_message - - if phone_number - - phone_book_entry = call_history.phone_book_entry_by_number(phone_number) - %tr.call-history-entry{:class => cycle('odd', 'even')} - %td.select_box= check_box_tag("selected_ids[]", call_history.id, false, :id => "select_item_#{call_history.id}", :class => 'select_item') - %td.thumbnail - - image = call_history.display_image(:small, phone_book_entry) - - if image - = image_tag(image, :itemprop => 'image') - %td.time - - if voicemail_message - .voicemail-message - %a{:href => sip_account_voicemail_messages_path(@sip_account, :anchor => "message_#{voicemail_message.id}")} - = image_tag('icons/gs_envelope_16x.png', :class => 'display') - = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - elsif call_history.entry_type == 'forwarded' - .call-forwarded= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - if call_history.callee_account_type.to_s.downcase == 'voicemail' - = t("call_histories.index.voicemail") - - else - = call_history.destination_number - - elsif call_history.entry_type == 'dialed' - .call-placed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - elsif call_history.entry_type == 'received' - .call-received= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - elsif call_history.entry_type == 'missed' - .call-missed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - else - .call-unknown - = t("call_histories.index.#{call_history.entry_type}") - = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - if call_history.forwarding_service && call_history.entry_type != 'forwarded' - = t("call_histories.index.forwarded_by") - = call_history.display_auth_account_name - %td.user - - display_name = call_history.display_name - - if display_name.blank? - - display_name = phone_book_entry.to_s - - if phone_book_entry - %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= display_name - - else - .name= display_name - .phone= phone_number - %td.status - - if call_history.display_duration - .duration= call_history.display_duration - - else - .disposition= t("call_histories.call_results.#{call_history.result}") - %td.actions - - if @sip_account.registration && can?(:call, call_history) - = link_to t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put - %td.actions - - if can? :destroy, call_history - = link_to t('call_histories.index.actions.destroy'), sip_account_call_history_path(@sip_account, call_history), :method => :delete + - cache(['call_history_table', I18n.locale, @sip_account, call_histories.first, call_histories.last, call_histories.count]) do + %table + - reset_cycle + - for call_history in call_histories + - tr_background_colour = cycle('odd', 'even') + - cache(['call_history_table_row', I18n.locale, call_history, tr_background_colour]) do + - phone_number = call_history.display_number + - voicemail_message = call_history.voicemail_message + - if phone_number + - phone_book_entry = call_history.phone_book_entry_by_number(phone_number) + %tr.call-history-entry{:class => tr_background_colour} + %td.select_box= check_box_tag("selected_ids[]", call_history.id, false, :id => "select_item_#{call_history.id}", :class => 'select_item') + %td.thumbnail + - image = call_history.display_image(:small, phone_book_entry) + - if image + = image_tag(image, :itemprop => 'image') + %td.time + - if voicemail_message + .voicemail-message + %a{:href => sip_account_voicemail_messages_path(@sip_account, :anchor => "message_#{voicemail_message.id}")} + = image_tag('icons/gs_envelope_16x.png', :class => 'display') + = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) + - elsif call_history.entry_type == 'forwarded' + .call-forwarded= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) + - if call_history.callee_account_type.to_s.downcase == 'voicemail' + = t("call_histories.index.voicemail") + - else + = call_history.destination_number + - elsif call_history.entry_type == 'dialed' + .call-placed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) + - elsif call_history.entry_type == 'received' + .call-received= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) + - elsif call_history.entry_type == 'missed' + .call-missed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) + - else + .call-unknown + = t("call_histories.index.#{call_history.entry_type}") + = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) + - if call_history.forwarding_service && call_history.entry_type != 'forwarded' + = t("call_histories.index.forwarded_by") + = call_history.display_auth_account_name + %td.user + - display_name = call_history.display_name + - if display_name.blank? + - display_name = phone_book_entry.to_s + - if phone_book_entry + %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= display_name + - else + .name= display_name + .phone= phone_number + %td.status + - if call_history.display_duration + .duration= call_history.display_duration + - else + .disposition= t("call_histories.call_results.#{call_history.result}") + %td.actions + - if @sip_account.registration && can?(:call, call_history) + = link_to t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put + %td.actions + - if can? :destroy, call_history + = link_to t('call_histories.index.actions.destroy'), sip_account_call_history_path(@sip_account, call_history), :method => :delete %footer.entries-nav= render :partial => "call_histories/navigation" = image_submit_tag('icons/cross-16x.png', :confirm => t("call_histories.index.actions.confirm_selected")) -- cgit v1.2.3 From 7cdcbdc4b851b348bb21e0f2ff437138e8b9884b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 21:00:41 +0100 Subject: Added page caching for the gemeinschaft_setup#new page. --- app/controllers/gemeinschaft_setups_controller.rb | 18 +++++------------- app/models/gemeinschaft_setup.rb | 9 +++++++++ app/views/users/_form_core.html.haml | 2 +- db/schema.rb | 2 +- lib/tasks/heater.rake | 11 +++++++++++ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index dbe8ff5..27c0a83 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -1,8 +1,12 @@ class GemeinschaftSetupsController < ApplicationController + # We use the heater rake task to generate this file. + # So it loads super fast even on slow machines. + # + caches_page :new, :gzip => :best_compression + load_and_authorize_resource :gemeinschaft_setup skip_before_filter :go_to_setup_if_new_installation - # before_filter :redirect_if_not_a_fresh_installation def new @user = @gemeinschaft_setup.build_user( @@ -62,16 +66,4 @@ class GemeinschaftSetupsController < ApplicationController end end - private - - def redirect_if_not_a_fresh_installation - if GemeinschaftSetup.all.count > 0 - if current_user - redirect_to root_url , :alert => t('gemeinschaft_setups.initial_setup.access_denied_only_available_on_a_new_system') - else - redirect_to log_in_path , :alert => t('gemeinschaft_setups.initial_setup.access_denied_only_available_on_a_new_system') - end - end - end - end diff --git a/app/models/gemeinschaft_setup.rb b/app/models/gemeinschaft_setup.rb index b445b21..0b3eeae 100644 --- a/app/models/gemeinschaft_setup.rb +++ b/app/models/gemeinschaft_setup.rb @@ -5,4 +5,13 @@ class GemeinschaftSetup < ActiveRecord::Base accepts_nested_attributes_for :sip_domain belongs_to :country belongs_to :language + + # Remove the cache which was created by the heater rake task. + # + after_create :expire_cache + + private + def expire_cache + ActionController::Base.expire_page(Rails.application.routes.url_helpers.new_gemeinschaft_setup_path) + end end diff --git a/app/views/users/_form_core.html.haml b/app/views/users/_form_core.html.haml index 8e18d12..24b15f5 100644 --- a/app/views/users/_form_core.html.haml +++ b/app/views/users/_form_core.html.haml @@ -1,6 +1,6 @@ .inputs - 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 + = 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') = f.input :last_name, :label => t('users.form.last_name.label'), :hint => conditional_hint('users.form.last_name.hint') diff --git a/db/schema.rb b/db/schema.rb index 898faac..bc4f737 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 => 20130116133433) do +ActiveRecord::Schema.define(:version => 20130116145500) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" diff --git a/lib/tasks/heater.rake b/lib/tasks/heater.rake index 7d026d9..11862a5 100644 --- a/lib/tasks/heater.rake +++ b/lib/tasks/heater.rake @@ -1,6 +1,17 @@ namespace :heater do desc "Warm up the cache." task :preheat => :environment do + if GemeinschaftSetup.any? + else + # This is a fresh installation. + # + if Rails.env.production? + require 'open-uri' + open('/dev/null', 'wb') do |file| + file << open("http://localhost/gemeinschaft_setups/new").read + end + end + end end end \ No newline at end of file -- cgit v1.2.3 From ea70e08534319dd3f15c34859c498771fa7d9b32 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Wed, 16 Jan 2013 21:06:15 +0100 Subject: add configuration for unicorn server --- config/unicorn.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 config/unicorn.rb diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 0000000..d379569 --- /dev/null +++ b/config/unicorn.rb @@ -0,0 +1,35 @@ +worker_processes 2 +working_directory "/opt/GS5/" + +# This loads the application in the master process before forking +# worker processes +# Read more about it here: +# http://unicorn.bogomips.org/Unicorn/Configurator.html +preload_app true + +timeout 30 + +# This is where we specify the socket. +# We will point the upstream Nginx module to this socket later on +listen "/opt/GS5/tmp/sockets/unicorn.sock", :backlog => 64 + +pid "/opt/GS5/tmp/pids/unicorn.pid" + +# Set the path of the log files inside the log folder of the testapp +stderr_path "/opt/GS5/log/unicorn.stderr.log" +stdout_path "/opt/GS5/log/unicorn.stdout.log" + +before_fork do |server, worker| +# This option works in together with preload_app true setting +# What is does is prevent the master process from holding +# the database connection + defined?(ActiveRecord::Base) and + ActiveRecord::Base.connection.disconnect! +end + +after_fork do |server, worker| +# Here we are establishing the connection after forking worker +# processes + defined?(ActiveRecord::Base) and + ActiveRecord::Base.establish_connection +end -- cgit v1.2.3 From 046ce09895a08778c971052f6d22ecd6422aee6d Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 21:24:24 +0100 Subject: list route elements in route view --- app/views/call_routes/show.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml index 31c3cb0..c5c7397 100644 --- a/app/views/call_routes/show.html.haml +++ b/app/views/call_routes/show.html.haml @@ -16,4 +16,10 @@ %strong= t('call_routes.show.position') + ":" = @call_route.position -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route } + +%h3= t('route_elements.index.page_title') +- if @call_route.route_elements && @call_route.route_elements.count > 0 + = render "route_elements/index_core", :route_elements => @call_route.route_elements + += render :partial => 'shared/create_link', :locals => { :parent => @call_route, :child_class => RouteElement } -- cgit v1.2.3 From 9ffaaeeb42b364f2c7d9b7d17a272c530f546c83 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 21:46:37 +0100 Subject: Refactoring and adding user_groups to tenant#show #105 --- app/views/tenants/_admin_area.de.html.haml | 4 +++ app/views/tenants/_admin_area.html.haml | 4 +++ app/views/user_groups/_index_core.html.haml | 46 ++++++++++++++++------------- app/views/users/_listing.html.haml | 6 ++-- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index beab94e..89e14cb 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -30,6 +30,10 @@ %h2 Admin Bereich = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +- if @tenant.user_groups.any? + %h2 Gruppen + = render "user_groups/index_core", :user_groups => @tenant.user_groups + %h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index 65810e7..7136f1e 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -29,6 +29,10 @@ %h2 Admin Area = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +- if @tenant.user_groups.any? + %h2 Groups + = render "user_groups/index_core", :user_groups => @tenant.user_groups + %h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} diff --git a/app/views/user_groups/_index_core.html.haml b/app/views/user_groups/_index_core.html.haml index d2b6e88..481a507 100644 --- a/app/views/user_groups/_index_core.html.haml +++ b/app/views/user_groups/_index_core.html.haml @@ -1,24 +1,28 @@ -%table - %tr - %th= t('user_groups.index.name') - %th= t('user_groups.index.description') - - if @user - %th= t('user_groups.index.tenant_id') - - else - %th= t('user_groups.index.members') - - - reset_cycle - - for user_group in user_groups - %tr{:class => cycle('odd', 'even')} - %td= user_group.name - %td= user_group.description +- cache(['user_groups_table', I18n.locale, current_user, @user, user_groups, User.order(:updated_at).last, User.count, UserGroupMembership.count, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do + %table + %tr + %th= t('user_groups.index.name') + - if user_groups.pluck(:description).uniq != [nil] + %th= t('user_groups.index.description') - if @user - %td= user_group.tenant + %th= t('user_groups.index.tenant_id') - else - %td - =render 'users/listing', :users => user_group.users - - if user_group.users.count > 1 - %br - = render :partial => 'shared/create_link', :locals => {:parent => user_group, :child_class => UserGroupMembership} + %th= t('user_groups.index.members') + + - reset_cycle + - for user_group in user_groups + %tr{:class => cycle('odd', 'even')} + %td= user_group.name + - if user_groups.pluck(:description).uniq != [nil] + %td= user_group.description + - if @user + %td= user_group.tenant + - 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} + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => user_group.tenant, :child => user_group} diff --git a/app/views/users/_listing.html.haml b/app/views/users/_listing.html.haml index 0a97ad1..9b7b653 100644 --- a/app/views/users/_listing.html.haml +++ b/app/views/users/_listing.html.haml @@ -1,8 +1,8 @@ - amount_of_users = users.count - if amount_of_users > 0 - - if amount_of_users < 30 + - if amount_of_users < GsParameter.get('NUMBER_OF_SHOWN_ITEMS') = users.map{|user| user}.join(', ') - else - = users.limit(15).map{|user| user}.join(', ') + ', ' + = users.limit((GsParameter.get('NUMBER_OF_SHOWN_ITEMS') / 2).floor).map{|user| user}.join(', ') + ', ' = '[...]' - = users.offset(amount_of_users - 15).map{|user| user}.join(', ') \ No newline at end of file + = users.offset(amount_of_users - (GsParameter.get('NUMBER_OF_SHOWN_ITEMS') / 2).floor).map{|user| user}.join(', ') \ No newline at end of file -- cgit v1.2.3 From 1bd91b138c773aedbd5f18b9df79e28fac240dbc Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 22:04:44 +0100 Subject: Added a users table to tenant#view. Related to #105. Still a lot of room for improvement. --- app/views/tenants/_admin_area.de.html.haml | 17 +++++++++++++---- app/views/tenants/_admin_area.html.haml | 19 ++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 89e14cb..0ef9da3 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -30,15 +30,24 @@ %h2 Admin Bereich = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +%h2= t("users.index.page_title") +- if @tenant.users.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "users/index_core", :users => @tenant.users + = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => User} +- else + %p + = link_to "Liste aller User.", tenant_users_path(@tenant) + - if @tenant.user_groups.any? - %h2 Gruppen + %h2= t("user_groups.index.page_title") = render "user_groups/index_core", :user_groups => @tenant.user_groups + = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => UserGroup} %h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} -%h2 Gemeinschaft Konfiguration -= render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} - %h2=t("phone_books.index.page_title") = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} + +%h2 Gemeinschaft Konfiguration += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} \ No newline at end of file diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index 7136f1e..7b47587 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -29,15 +29,24 @@ %h2 Admin Area = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +%h2= t("users.index.page_title") +- if @tenant.users.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "users/index_core", :users => @tenant.users + = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => User} +- else + %p + = link_to "Liste aller User.", tenant_users_path(@tenant) + - if @tenant.user_groups.any? - %h2 Groups + %h2= t("user_groups.index.page_title") = render "user_groups/index_core", :user_groups => @tenant.user_groups + = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => UserGroup} %h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} -%h2 Gemeinschaft Configuration -= render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} - %h2=t("phone_books.index.page_title") -= render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} \ No newline at end of file += render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} + +%h2 Gemeinschaft Configuration += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} \ No newline at end of file -- cgit v1.2.3 From 0601ff60400e27451259531bb26cb69c7e6e352c Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Wed, 16 Jan 2013 22:05:46 +0100 Subject: add unicorn application server to Gemfile --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 9f0fe8e..375743f 100644 --- a/Gemfile +++ b/Gemfile @@ -68,6 +68,9 @@ gem 'breadcrumbs_on_rails' # UUID Generator https://github.com/assaf/uuid gem 'uuid' +# Application server +gem 'unicorn' + # Local Variables: # mode: ruby # End: -- cgit v1.2.3 From 35b857cd917b2005aef993c40021253abe96e2d2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 22:08:19 +0100 Subject: It doesn't make sense to create a tenant.user_group here. #105 --- app/views/users/_user_groups.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/users/_user_groups.html.haml b/app/views/users/_user_groups.html.haml index 7e206b6..81191ae 100644 --- a/app/views/users/_user_groups.html.haml +++ b/app/views/users/_user_groups.html.haml @@ -5,4 +5,3 @@ %h2=t("user_groups.index.page_title") - if user.user_groups.count > 0 = render "user_groups/index_core", :user_groups => user.user_groups.where(:tenant_id => tenant.id).order(:name) - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => UserGroup} \ No newline at end of file -- cgit v1.2.3 From f115c3541a42e408e32ebd30603125d796113a79 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Wed, 16 Jan 2013 22:15:58 +0100 Subject: add Unicorn to Gemfile.lock --- Gemfile.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index e4deaeb..218f072 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,6 +170,10 @@ GEM uglifier (1.3.0) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) + unicorn (4.5.0) + kgio (~> 2.6) + rack + raindrops (~> 0.7) uuid (2.3.6) macaddr (~> 1.0) will_paginate (3.0.4) @@ -209,5 +213,6 @@ DEPENDENCIES state_machine strong_parameters uglifier (>= 1.3.0) + unicorn uuid will_paginate -- cgit v1.2.3 From 16c2367e7e291fdc063f77cbdcbc41874060554a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 22:36:21 +0100 Subject: bundle update --- Gemfile.lock | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index e4deaeb..0beeb3b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -100,6 +100,7 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.7.6) + kgio (2.7.4) macaddr (1.6.1) systemu (~> 2.5.0) mail (2.4.4) @@ -137,6 +138,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) + raindrops (0.10.0) rake (10.0.3) rdoc (3.12) json (~> 1.4) @@ -170,6 +172,10 @@ GEM uglifier (1.3.0) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) + unicorn (4.5.0) + kgio (~> 2.6) + rack + raindrops (~> 0.7) uuid (2.3.6) macaddr (~> 1.0) will_paginate (3.0.4) @@ -209,5 +215,6 @@ DEPENDENCIES state_machine strong_parameters uglifier (>= 1.3.0) + unicorn uuid will_paginate -- cgit v1.2.3 From ee9efa4e414e89a5dbc8df5b94b758055d8ee633 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 22:37:20 +0100 Subject: Set a new default for USER_NAME_PREFIX. --- db/migrate/20130116213312_change_user_name_prefix.rb | 5 +++++ db/schema.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20130116213312_change_user_name_prefix.rb diff --git a/db/migrate/20130116213312_change_user_name_prefix.rb b/db/migrate/20130116213312_change_user_name_prefix.rb new file mode 100644 index 0000000..1e6aa59 --- /dev/null +++ b/db/migrate/20130116213312_change_user_name_prefix.rb @@ -0,0 +1,5 @@ +class ChangeUserNamePrefix < ActiveRecord::Migration + def up + GsParameter.where(:name => 'USER_NAME_PREFIX').first.update_attributes(:value => "xyz") + end +end diff --git a/db/schema.rb b/db/schema.rb index bc4f737..8416305 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 => 20130116145500) do +ActiveRecord::Schema.define(:version => 20130116213312) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" -- cgit v1.2.3 From a8a0c40dfae8844162bd472faa9badc38d30d2d5 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 23:08:08 +0100 Subject: acts_as_list --- app/models/route_element.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 11bb54a..6f6fd3f 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -3,6 +3,8 @@ class RouteElement < ActiveRecord::Base belongs_to :call_route + acts_as_list :scope => :call_route + def to_s "#{var_in} #{var_out}" end -- cgit v1.2.3 From f7f1785023f6fa52775c7ab2796fc247bf1ab15f Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 23:08:13 +0100 Subject: acts_as_list --- app/models/call_route.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index de0f68a..e423030 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -6,6 +6,8 @@ class CallRoute < ActiveRecord::Base validates :name, :presence => true + acts_as_list :scope => '`table` = \'#{table}\'' + def to_s name.to_s end -- cgit v1.2.3 From 4ba228de6ecbfa0eeca20f8f7b70aee78fde9385 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 23:08:53 +0100 Subject: position removed --- app/views/call_routes/show.html.haml | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml index c5c7397..8be64e6 100644 --- a/app/views/call_routes/show.html.haml +++ b/app/views/call_routes/show.html.haml @@ -12,9 +12,6 @@ %p %strong= t('call_routes.show.endpoint_id') + ":" = @call_route.endpoint_id -%p - %strong= t('call_routes.show.position') + ":" - = @call_route.position = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route } -- cgit v1.2.3 From 8fd56dfe3d2bca6ccd9353031947ae4a8dca4528 Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 16 Jan 2013 23:09:20 +0100 Subject: set prerouting table --- db/migrate/20130116203000_set_prerouting_table.rb | 99 +++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 db/migrate/20130116203000_set_prerouting_table.rb diff --git a/db/migrate/20130116203000_set_prerouting_table.rb b/db/migrate/20130116203000_set_prerouting_table.rb new file mode 100644 index 0000000..86137a0 --- /dev/null +++ b/db/migrate/20130116203000_set_prerouting_table.rb @@ -0,0 +1,99 @@ +class SetPreroutingTable < ActiveRecord::Migration + def up + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*$', :replacement => 'f-li', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)#*$', :replacement => 'f-li-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*(%d+)%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)%*(%d+)#*$', :replacement => 'f-li-%1-%2', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#0#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#0#$', :replacement => 'f-lo', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*5%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*5%*(%d+)#$', :replacement => 'f-acdmtg-0-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*30#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*30#$', :replacement => 'f-clipon', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#30#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#30#$', :replacement => 'f-clipoff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*31#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#$', :replacement => 'f-cliroff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#31#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#$', :replacement => 'f-cliron', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#(%d+)$', :replacement => 'f-dcliroff-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#(%d+)$', :replacement => 'f-dcliron-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*43#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*43#$', :replacement => 'f-cwaon', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#43#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#43#$', :replacement => 'f-cwaoff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#002#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#002#$', :replacement => 'f-cfoff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^##002#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##002#$', :replacement => 'f-cfdel', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*21#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21#$', :replacement => 'f-cfu', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#21#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#21#$', :replacement => 'f-cfuoff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^##21#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##21#$', :replacement => 'f-cfudel', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61#$', :replacement => 'f-cfn', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#61#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#61#$', :replacement => 'f-cfnoff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^##61#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##61#$', :replacement => 'f-cfndel', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*62#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62#$', :replacement => 'f-cfo', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#62#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#62#$', :replacement => 'f-cfooff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^##62#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##62#$', :replacement => 'f-cfodel', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*67#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67#$', :replacement => 'f-cfb', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^#67#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#67#$', :replacement => 'f-cfboff', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^##67#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##67#$', :replacement => 'f-cfbdel', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*66#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*66#$', :replacement => 'f-redial', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98#$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98%*(%d+)#$', :replacement => 'f-vmcheck-%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*1337%*1%*1#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*1#$', :replacement => 'f-loaon', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*1337%*1%*0#$', :endpoint_type => 'dialplanfunction').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*0#$', :replacement => 'f-loaoff', :action => 'set_route_var', :mandatory => true) + + CallRoute.create(:table => 'prerouting', :name => 'international prefix', :endpoint_type => 'phonenumber').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^00(%d+)$', :replacement => '+%1', :action => 'set_route_var', :mandatory => true) + CallRoute.create(:table => 'prerouting', :name => 'national prefix', :endpoint_type => 'phonenumber').route_elements. + create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^0(%d+)$', :replacement => '+49%1', :action => 'set_route_var', :mandatory => true) + end + + def down + CallRoute.where(:table => "prerouting").destroy_all + end +end -- cgit v1.2.3 From 86b9ba00a88b455f88ced10cf959660b96113c88 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Wed, 16 Jan 2013 23:24:41 +0100 Subject: better process handling --- config/unicorn.rb | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/config/unicorn.rb b/config/unicorn.rb index d379569..8157562 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -1,35 +1,34 @@ -worker_processes 2 -working_directory "/opt/GS5/" +APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__))) + +worker_processes 1 +working_directory APP_ROOT -# This loads the application in the master process before forking -# worker processes -# Read more about it here: -# http://unicorn.bogomips.org/Unicorn/Configurator.html preload_app true timeout 30 -# This is where we specify the socket. -# We will point the upstream Nginx module to this socket later on -listen "/opt/GS5/tmp/sockets/unicorn.sock", :backlog => 64 +listen APP_ROOT + "/tmp/sockets/unicorn.sock", :backlog => 64 -pid "/opt/GS5/tmp/pids/unicorn.pid" +pid APP_ROOT + "/tmp/pids/unicorn.pid" -# Set the path of the log files inside the log folder of the testapp -stderr_path "/opt/GS5/log/unicorn.stderr.log" -stdout_path "/opt/GS5/log/unicorn.stdout.log" +stderr_path APP_ROOT + "/log/unicorn.stderr.log" +stdout_path APP_ROOT + "/log/unicorn.stdout.log" before_fork do |server, worker| -# This option works in together with preload_app true setting -# What is does is prevent the master process from holding -# the database connection - defined?(ActiveRecord::Base) and - ActiveRecord::Base.connection.disconnect! + defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect! + + old_pid = Rails.root + '/tmp/pids/unicorn.pid.oldbin' + if File.exists?(old_pid) && server.pid != old_pid + begin + Process.kill("QUIT", File.read(old_pid).to_i) + rescue Errno::ENOENT, Errno::ESRCH + puts "Old master alerady dead" + end + end end after_fork do |server, worker| -# Here we are establishing the connection after forking worker -# processes - defined?(ActiveRecord::Base) and - ActiveRecord::Base.establish_connection + defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection + child_pid = server.config[:pid].sub('.pid', ".#{worker.nr}.pid") + system("echo #{Process.pid} > #{child_pid}") end -- cgit v1.2.3 From 1d18e9d7fc16501d7622889df9d6ef05c75adb2f Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 06:59:08 +0100 Subject: validations --- app/models/call_route.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index e423030..f6a3dd3 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -1,4 +1,6 @@ class CallRoute < ActiveRecord::Base + ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] + attr_accessible :table, :name, :endpoint_type, :endpoint_id, :position has_many :route_elements, :dependent => :destroy @@ -6,6 +8,10 @@ class CallRoute < ActiveRecord::Base validates :name, :presence => true + validates :table, + :presence => true, + :inclusion => { :in => ROUTING_TABLES } + acts_as_list :scope => '`table` = \'#{table}\'' def to_s -- cgit v1.2.3 From 85d8dc12c3963f78ea1db4089c6ff2fa6ec205e9 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 07:44:01 +0100 Subject: validations --- app/models/route_element.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 6f6fd3f..d3302ea 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -1,10 +1,23 @@ class RouteElement < ActiveRecord::Base + ELEMENT_ACTIONS = ['match', 'not_match', 'set_route_var', 'set_header'] + attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position belongs_to :call_route acts_as_list :scope => :call_route + validates :var_in, + :presence => true + + validates :pattern, + :presence => true + + validates :action, + :presence => true, + :inclusion => { :in => ELEMENT_ACTIONS } + + def to_s "#{var_in} #{var_out}" end -- cgit v1.2.3 From 416a9c563ed52b2b4f5350b8a069313f5843489c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 17 Jan 2013 09:51:34 +0100 Subject: Cache bug fixed. --- app/views/users/show.html.haml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index f74d0a5..9a0ae02 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -47,16 +47,14 @@ - cache(['user_show_user_groups_overview', I18n.locale, @user, @user.user_groups]) do = render :partial => 'user_groups', :locals => {:user => @user, :tenant => @tenant} - - cache(['user_show_overview_for_sip_account_phones_fax_accounts_and_conferences', I18n.locale, @user, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - cache(['user_show_sip_accounts_overview', I18n.locale, @user, @user.sip_accounts]) do + = render :partial => 'sip_accounts', :locals => {:user => @user} - - cache(['user_show_sip_accounts_overview', I18n.locale, @user, @user.sip_accounts]) do - = render :partial => 'sip_accounts', :locals => {:user => @user} + - cache(['user_show_phones_overview', I18n.locale, @user, @user.phones]) do + = render :partial => 'phones', :locals => {:user => @user} - - cache(['user_show_phones_overview', I18n.locale, @user, @user.phones]) do - = render :partial => 'phones', :locals => {:user => @user} + - cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do + = render :partial => 'fax_accounts', :locals => {:user => @user} - - cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do - = render :partial => 'fax_accounts', :locals => {:user => @user} - - - cache(['user_show_conferences_overview', I18n.locale, @user, @user.conferences]) do - = render :partial => 'conferences', :locals => {:user => @user} + - cache(['user_show_conferences_overview', I18n.locale, @user, @user.conferences]) do + = render :partial => 'conferences', :locals => {:user => @user} -- cgit v1.2.3 From bc530494cca59845b5896ae4b0900ca1b9691827 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 10:05:49 +0100 Subject: set caller id numbers array --- misc/freeswitch/scripts/dialplan/dialplan.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 32f59c2..704728a 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -757,6 +757,21 @@ function Dialplan.switch(self, destination) elseif not common.str.blank(destination.number) then local result = { continue = false, code = 404, phrase = 'No route' } + local clip_no_screening = common.str.try(caller, 'account.record.clip_no_screening'); + self.caller.caller_id_numbers = {} + if not common.str.blank(clip_no_screening) then + for index, number in ipairs(common.str.strip_to_a(clip_no_screening, ',')) do + table.insert(self.caller.caller_id_numbers, number); + end + end + for index, number in ipairs(self.caller.caller_phone_numbers) do + table.insert(self.caller.caller_id_numbers, number); + end + self.log:info('CALLER_ID_NUMBERS - clir: ', self.caller.clir, ', numbers: ', table.concat(self.caller.caller_id_numbers, ',')); + + destination.callee_id_number = destination.number; + destination.callee_id_name = nil; + require 'dialplan.router' local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('outbound', destination.number); @@ -765,9 +780,6 @@ function Dialplan.switch(self, destination) return { continue = false, code = 404, phrase = 'No route' } end - destination.callee_id_number = destination.number; - destination.callee_id_name = nil; - if self.phonebook_number_lookup then require 'common.str' local user_id = common.str.try(self.caller, 'account.owner.id'); -- cgit v1.2.3 From 0a3a4c78badb80e7f0f7b5d372421f1e75fd5f02 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 11:12:02 +0100 Subject: access arrays from within routing elements --- misc/freeswitch/scripts/dialplan/router.lua | 40 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index 2071288..de543f3 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -92,6 +92,23 @@ function Router.element_match(self, pattern, search_string, replacement) end +function Router.element_match_group(self, pattern, groups, replacement, use_key) + if type(groups) ~= 'table' then + return false; + end + + for key, value in pairs(groups) do + if use_key then + value = key; + end + result, replaced_value = self:element_match(pattern, tostring(value), replacement); + if result then + return true, replaced_value; + end + end +end + + function Router.route_match(self, route) local destination = { gateway = 'gateway' .. route.endpoint_id, @@ -107,24 +124,17 @@ function Router.route_match(self, route) local replacement = nil; local element = route.elements[index]; - if element.var_in == 'group' then - local groups = common.str.try(self.caller, 'auth_account.owner.groups'); - if not groups or type(groups) ~= 'table' then - if element.mandatory then - return false; - end - end + local command, variable_name = common.str.partition(element.var_in, ':'); - for group_name, value in pairs(groups) do - result, replacement = self:element_match(tostring(element.pattern), tostring(group_name), tostring(element.replacement)); - if result then - break; - end - end - - else + if not command or not variable_name or command == 'var' then local search_string = tostring(common.str.try(self.caller, element.var_in)) result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); + elseif command == 'key' or command == 'val' then + local groups = common.str.try(self.caller, variable_name); + result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key'); + elseif command == 'chv' then + local search_string = self.caller:to_s(variable_name); + result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); end if element.action == 'not_match' then -- cgit v1.2.3 From 4bf20d36ed26746e0a7b2fc551e57337c8788c86 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 12:03:09 +0100 Subject: array vs. hash --- misc/freeswitch/scripts/dialplan/user.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan/user.lua b/misc/freeswitch/scripts/dialplan/user.lua index 3b483c8..0a2e0dd 100644 --- a/misc/freeswitch/scripts/dialplan/user.lua +++ b/misc/freeswitch/scripts/dialplan/user.lua @@ -62,7 +62,7 @@ function User.list_groups(self, id) local groups = {}; self.database:query(sql_query, function(entry) - groups[common.str.downcase(entry.name)] = true; + table.insert(groups, common.str.downcase(entry.name)); end); return groups; -- cgit v1.2.3 From a4c63280de43e820bfcf9f02d61f90a50fffff92 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 12:03:57 +0100 Subject: debugging output --- misc/freeswitch/scripts/dialplan/router.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index de543f3..e82d224 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -175,7 +175,7 @@ function Router.route_run(self, table_name, phone_number, find_first) local route = self:route_match(routing_table[index], phone_number); if route then table.insert(routes, route); - self.log:info('ROUTE ', #routes,' - ', table_name,'=', routing_table[index].id, '/', routing_table[index].name, ', destination: ', route.type, '=', route.id); + self.log:info('ROUTE ', #routes,' - ', table_name,'=', routing_table[index].id, '/', routing_table[index].name, ', destination: ', route.type, '=', route.id, ', destination_number: ', route.destination_number); if find_first then return route; end -- cgit v1.2.3 From ae8ce84e44d776b3c2318795ceff611f0639b7ec Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 12:31:10 +0100 Subject: call route views --- app/views/call_routes/_form_core.html.haml | 3 +-- app/views/call_routes/_index_core.html.haml | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/call_routes/_form_core.html.haml b/app/views/call_routes/_form_core.html.haml index 4b97434..4712e2f 100644 --- a/app/views/call_routes/_form_core.html.haml +++ b/app/views/call_routes/_form_core.html.haml @@ -1,6 +1,5 @@ .inputs - = f.input :table, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint') + = f.input :table, :collection => CallRoute::ROUTING_TABLES, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint'), :include_blank => false = f.input :name, :label => t('call_routes.form.name.label'), :hint => conditional_hint('call_routes.form.name.hint') = f.input :endpoint_type, :label => t('call_routes.form.endpoint_type.label'), :hint => conditional_hint('call_routes.form.endpoint_type.hint') = f.input :endpoint_id, :label => t('call_routes.form.endpoint_id.label'), :hint => conditional_hint('call_routes.form.endpoint_id.hint') - = f.input :position, :label => t('call_routes.form.position.label'), :hint => conditional_hint('call_routes.form.position.hint') diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml index 6ea3af7..9e7b94e 100644 --- a/app/views/call_routes/_index_core.html.haml +++ b/app/views/call_routes/_index_core.html.haml @@ -4,7 +4,6 @@ %th= t('call_routes.index.name') %th= t('call_routes.index.endpoint_type') %th= t('call_routes.index.endpoint_id') - %th= t('call_routes.index.position') - reset_cycle - for call_route in call_routes @@ -13,5 +12,4 @@ %td= call_route.name %td= call_route.endpoint_type %td= call_route.endpoint_id - %td= call_route.position =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route} \ No newline at end of file -- cgit v1.2.3 From 808a9d19c7376907370e58662856cd028e9b83b1 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 12:31:28 +0100 Subject: route elements views --- app/views/route_elements/_form_core.html.haml | 3 +-- app/views/route_elements/_index_core.html.haml | 2 -- app/views/route_elements/show.html.haml | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/views/route_elements/_form_core.html.haml b/app/views/route_elements/_form_core.html.haml index 133d1df..a9a38a7 100644 --- a/app/views/route_elements/_form_core.html.haml +++ b/app/views/route_elements/_form_core.html.haml @@ -3,6 +3,5 @@ = f.input :var_out, :label => t('route_elements.form.var_out.label'), :hint => conditional_hint('route_elements.form.var_out.hint') = f.input :pattern, :label => t('route_elements.form.pattern.label'), :hint => conditional_hint('route_elements.form.pattern.hint') = f.input :replacement, :label => t('route_elements.form.replacement.label'), :hint => conditional_hint('route_elements.form.replacement.hint') - = f.input :action, :label => t('route_elements.form.action.label'), :hint => conditional_hint('route_elements.form.action.hint') + = f.input :action, :collection => RouteElement::ELEMENT_ACTIONS, :label => t('route_elements.form.action.label'), :hint => conditional_hint('route_elements.form.action.hint'), :include_blank => false = f.input :mandatory, :label => t('route_elements.form.mandatory.label'), :hint => conditional_hint('route_elements.form.mandatory.hint') - = f.input :position, :label => t('route_elements.form.position.label'), :hint => conditional_hint('route_elements.form.position.hint') diff --git a/app/views/route_elements/_index_core.html.haml b/app/views/route_elements/_index_core.html.haml index c1df665..3435686 100644 --- a/app/views/route_elements/_index_core.html.haml +++ b/app/views/route_elements/_index_core.html.haml @@ -6,7 +6,6 @@ %th= t('route_elements.index.replacement') %th= t('route_elements.index.action') %th= t('route_elements.index.mandatory') - %th= t('route_elements.index.position') - reset_cycle - for route_element in route_elements @@ -17,5 +16,4 @@ %td= route_element.replacement %td= route_element.action %td= route_element.mandatory - %td= route_element.position =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => @call_route, :child => route_element} \ No newline at end of file diff --git a/app/views/route_elements/show.html.haml b/app/views/route_elements/show.html.haml index 8e41f80..c637a4d 100644 --- a/app/views/route_elements/show.html.haml +++ b/app/views/route_elements/show.html.haml @@ -18,8 +18,5 @@ %p %strong= t('route_elements.show.mandatory') + ":" = @route_element.mandatory -%p - %strong= t('route_elements.show.position') + ":" - = @route_element.position = render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @call_route, :child => @route_element } \ No newline at end of file -- cgit v1.2.3 From d66a90d64f6c99070c8dde1d12d4de90d7032b49 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 15:10:34 +0100 Subject: display caller id in fork --- misc/freeswitch/scripts/dialplan/sip_call.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 95ab0f3..1513459 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -89,7 +89,7 @@ function SipCall.fork(self, destinations, arg ) for index, destination in ipairs(destinations) do local origination_variables = { 'gs_fork_index=' .. index } - self.log:info('FORK ', index, '/', #destinations, ' - ', destination.type, '=', destination.id, '/', destination.gateway or destination.uuid, '@', destination.node_id, ', number: ', destination.number); + self.log:info('FORK ', index, '/', #destinations, ' - ', destination.type, '=', destination.id, '/', destination.gateway or destination.uuid, '@', destination.node_id, ', number: ', destination.number, ', caller_id: "', destination.caller_id_name, '" <', destination.caller_id_number, '>'); if not common.str.to_b(arg.update_callee_display) then table.insert(origination_variables, 'ignore_display_updates=true'); -- cgit v1.2.3 From 25a311e5dd538a190a1b3cf94477d2aad2cc89c9 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 15:11:27 +0100 Subject: action handling improvements --- misc/freeswitch/scripts/dialplan/router.lua | 63 ++++++++++++++++------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index e82d224..4a756ea 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -114,7 +114,7 @@ function Router.route_match(self, route) gateway = 'gateway' .. route.endpoint_id, ['type'] = route.endpoint_type, id = route.endpoint_id, - actions = {} + channel_variables = {} }; local route_matches = false; @@ -124,37 +124,46 @@ function Router.route_match(self, route) local replacement = nil; local element = route.elements[index]; - local command, variable_name = common.str.partition(element.var_in, ':'); - - if not command or not variable_name or command == 'var' then - local search_string = tostring(common.str.try(self.caller, element.var_in)) - result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); - elseif command == 'key' or command == 'val' then - local groups = common.str.try(self.caller, variable_name); - result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key'); - elseif command == 'chv' then - local search_string = self.caller:to_s(variable_name); - result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); - end - if element.action == 'not_match' then - result = not result; - end + if element.action ~= 'none' then + local command, variable_name = common.str.partition(element.var_in, ':'); + + if not command or not variable_name or command == 'var' then + local search_string = tostring(common.str.try(self.caller, element.var_in)) + result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); + elseif command == 'key' or command == 'val' then + local groups = common.str.try(self.caller, variable_name); + result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key'); + elseif command == 'chv' then + local search_string = self.caller:to_s(variable_name); + result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); + elseif command == 'hdr' then + local search_string = self.caller:to_s('sip_h_' .. variable_name); + result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); + end - if not result then - if element.mandatory then - return false; + if element.action == 'not_match' then + result = not result; end - elseif element.action ~= 'match' and element.action ~= 'not_match' then - if element.action == 'set_route_var' then - destination[element.var_out] = replacement; + + if not result then + if element.mandatory then + return false; + end else - table.insert(destination.actions, {action = element.action, name = element.var_out, value = replacement}); - end - end + local command, variable_name = common.str.partition(element.var_out, ':'); + if not command or not variable_name or command == 'var' then + destination[element.var_out] = replacement; + elseif command == 'chv' then + table.insert(destination.channel_variables, { name = element.var_out, value = replacement }); + elseif command == 'hdr' then + table.insert(destination.channel_variables, { name = 'sip_h_' .. tostring(element.var_out), value = replacement }); + end - if result then - route_matches = true; + if element.action == 'match' or element.action == 'not_match' then + route_matches = true; + end + end end end -- cgit v1.2.3 From b086515a8a82f572e204bac9cb8c139ca8a0960d Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 15:11:48 +0100 Subject: element actions --- app/models/route_element.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/route_element.rb b/app/models/route_element.rb index d3302ea..32f730d 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -1,5 +1,5 @@ class RouteElement < ActiveRecord::Base - ELEMENT_ACTIONS = ['match', 'not_match', 'set_route_var', 'set_header'] + ELEMENT_ACTIONS = ['none', 'match', 'not_match', 'set'] attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position -- cgit v1.2.3 From 48d569baeda24663b3adcb6532c9678f5b6ddbcb Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 15:18:52 +0100 Subject: do not set variable when name blank --- misc/freeswitch/scripts/dialplan/router.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index 4a756ea..f207276 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -151,13 +151,15 @@ function Router.route_match(self, route) return false; end else - local command, variable_name = common.str.partition(element.var_out, ':'); - if not command or not variable_name or command == 'var' then - destination[element.var_out] = replacement; - elseif command == 'chv' then - table.insert(destination.channel_variables, { name = element.var_out, value = replacement }); - elseif command == 'hdr' then - table.insert(destination.channel_variables, { name = 'sip_h_' .. tostring(element.var_out), value = replacement }); + if not common.str.blank(element.var_out) then + local command, variable_name = common.str.partition(element.var_out, ':'); + if not command or not variable_name or command == 'var' then + destination[element.var_out] = replacement; + elseif command == 'chv' then + table.insert(destination.channel_variables, { name = element.var_out, value = replacement }); + elseif command == 'hdr' then + table.insert(destination.channel_variables, { name = 'sip_h_' .. tostring(element.var_out), value = replacement }); + end end if element.action == 'match' or element.action == 'not_match' then -- cgit v1.2.3 From a36e8ea2bf092a23530b0ad54504667caa94e788 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 15:43:15 +0100 Subject: set match action in prerouting table --- db/migrate/20130117142600_change_action_prerouting_table.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20130117142600_change_action_prerouting_table.rb diff --git a/db/migrate/20130117142600_change_action_prerouting_table.rb b/db/migrate/20130117142600_change_action_prerouting_table.rb new file mode 100644 index 0000000..8b57ca6 --- /dev/null +++ b/db/migrate/20130117142600_change_action_prerouting_table.rb @@ -0,0 +1,13 @@ +class ChangeActionPreroutingTable < ActiveRecord::Migration + def up + RouteElement.where(:action => 'set_route_var', :mandatory => true).each do |route| + route.update_attributes(:action => 'match') + end + end + + def down + RouteElement.where(:action => 'match', :mandatory => true).each do |route| + route.update_attributes(:action => 'set_route_var') + end + end +end -- cgit v1.2.3 From 24e47521f1a57c73dc349de35909af7e1f8a4a1f Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 17:50:47 +0100 Subject: group by table --- app/controllers/call_routes_controller.rb | 2 ++ app/views/call_routes/_index_core.html.haml | 2 -- app/views/call_routes/index.html.haml | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 41abe6d..b0c173d 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -4,6 +4,8 @@ class CallRoutesController < ApplicationController before_filter :spread_breadcrumbs def index + @call_routes = CallRoute.order(['`table`', :position]) + @tables = @call_routes.pluck('`table`').uniq.sort end def show diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml index 9e7b94e..aa22437 100644 --- a/app/views/call_routes/_index_core.html.haml +++ b/app/views/call_routes/_index_core.html.haml @@ -1,6 +1,5 @@ %table %tr - %th= t('call_routes.index.table') %th= t('call_routes.index.name') %th= t('call_routes.index.endpoint_type') %th= t('call_routes.index.endpoint_id') @@ -8,7 +7,6 @@ - reset_cycle - for call_route in call_routes %tr{:class => cycle('odd', 'even')} - %td= call_route.table %td= call_route.name %td= call_route.endpoint_type %td= call_route.endpoint_id diff --git a/app/views/call_routes/index.html.haml b/app/views/call_routes/index.html.haml index 687a9dc..c83606b 100644 --- a/app/views/call_routes/index.html.haml +++ b/app/views/call_routes/index.html.haml @@ -1,6 +1,11 @@ - title t("call_routes.index.page_title") - if @call_routes && @call_routes.count > 0 - = render "index_core", :call_routes => @call_routes - -= render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} \ No newline at end of file + %table + - @tables.each do |table| + %tr + %td{:colspan => 3} + %h3= table + = render "index_core", :call_routes => @call_routes.where(:table => table) + += render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} -- cgit v1.2.3 From b800f7c7ec5aa65f773d1c91c1418ca5edac0f2c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 17 Jan 2013 20:21:13 +0100 Subject: rename_column :call_routes, :table, :routing_table --- db/migrate/20130117191840_change_column_name_in_call_route.rb | 9 +++++++++ db/schema.rb | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20130117191840_change_column_name_in_call_route.rb diff --git a/db/migrate/20130117191840_change_column_name_in_call_route.rb b/db/migrate/20130117191840_change_column_name_in_call_route.rb new file mode 100644 index 0000000..cad0f59 --- /dev/null +++ b/db/migrate/20130117191840_change_column_name_in_call_route.rb @@ -0,0 +1,9 @@ +class ChangeColumnNameInCallRoute < ActiveRecord::Migration + def up + rename_column :call_routes, :table, :routing_table + end + + def down + rename_column :call_routes, :routing_table, :table + end +end diff --git a/db/schema.rb b/db/schema.rb index 8416305..31fdaf7 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 => 20130116213312) do +ActiveRecord::Schema.define(:version => 20130117191840) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -177,7 +177,7 @@ ActiveRecord::Schema.define(:version => 20130116213312) do end create_table "call_routes", :force => true do |t| - t.string "table" + t.string "routing_table" t.string "name" t.string "endpoint_type" t.integer "endpoint_id" -- cgit v1.2.3 From 17206a20e5bcb44fa4d90f0e176f7aa0fe43bca3 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 21:51:58 +0100 Subject: rename_column table to routing_table --- app/controllers/call_routes_controller.rb | 4 ++-- app/models/call_route.rb | 4 ++-- app/views/call_routes/_form_core.html.haml | 2 +- app/views/call_routes/index.html.haml | 6 +++--- app/views/call_routes/show.html.haml | 2 +- misc/freeswitch/scripts/dialplan/router.lua | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index b0c173d..130a160 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -4,8 +4,8 @@ class CallRoutesController < ApplicationController before_filter :spread_breadcrumbs def index - @call_routes = CallRoute.order(['`table`', :position]) - @tables = @call_routes.pluck('`table`').uniq.sort + @call_routes = CallRoute.order([:routing_table, :position]) + @routing_tables = @call_routes.pluck(:routing_table).uniq.sort end def show diff --git a/app/models/call_route.rb b/app/models/call_route.rb index f6a3dd3..0df961d 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -1,7 +1,7 @@ class CallRoute < ActiveRecord::Base ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] - attr_accessible :table, :name, :endpoint_type, :endpoint_id, :position + attr_accessible :routing_table, :name, :endpoint_type, :endpoint_id, :position has_many :route_elements, :dependent => :destroy @@ -12,7 +12,7 @@ class CallRoute < ActiveRecord::Base :presence => true, :inclusion => { :in => ROUTING_TABLES } - acts_as_list :scope => '`table` = \'#{table}\'' + acts_as_list :scope => '`routing_table` = \'#{routing_table}\'' def to_s name.to_s diff --git a/app/views/call_routes/_form_core.html.haml b/app/views/call_routes/_form_core.html.haml index 4712e2f..2eee795 100644 --- a/app/views/call_routes/_form_core.html.haml +++ b/app/views/call_routes/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs - = f.input :table, :collection => CallRoute::ROUTING_TABLES, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint'), :include_blank => false + = f.input :routing_table, :collection => CallRoute::ROUTING_TABLES, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint'), :include_blank => false = f.input :name, :label => t('call_routes.form.name.label'), :hint => conditional_hint('call_routes.form.name.hint') = f.input :endpoint_type, :label => t('call_routes.form.endpoint_type.label'), :hint => conditional_hint('call_routes.form.endpoint_type.hint') = f.input :endpoint_id, :label => t('call_routes.form.endpoint_id.label'), :hint => conditional_hint('call_routes.form.endpoint_id.hint') diff --git a/app/views/call_routes/index.html.haml b/app/views/call_routes/index.html.haml index c83606b..151fc0e 100644 --- a/app/views/call_routes/index.html.haml +++ b/app/views/call_routes/index.html.haml @@ -2,10 +2,10 @@ - if @call_routes && @call_routes.count > 0 %table - - @tables.each do |table| + - @routing_tables.each do |routing_table| %tr %td{:colspan => 3} - %h3= table - = render "index_core", :call_routes => @call_routes.where(:table => table) + %h3= routing_table + = render "index_core", :call_routes => @call_routes.where(:routing_table => routing_table) = render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml index 8be64e6..bada227 100644 --- a/app/views/call_routes/show.html.haml +++ b/app/views/call_routes/show.html.haml @@ -2,7 +2,7 @@ %p %strong= t('call_routes.show.table') + ":" - = @call_route.table + = @call_route.routing_table %p %strong= t('call_routes.show.name') + ":" = @call_route.name diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index f207276..33434ee 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -28,7 +28,7 @@ function Router.read_table(self, table_name) local sql_query = 'SELECT * \ FROM `call_routes` `a` \ JOIN `route_elements` `b` ON `a`.`id` = `b`.`call_route_id`\ - WHERE `a`.`table` = "' .. table_name .. '" \ + WHERE `a`.`routing_table` = "' .. table_name .. '" \ ORDER BY `a`.`position`, `b`.`position`'; local last_id = 0; -- cgit v1.2.3 From 73c9984510d572030329d967e44c6adb00d98613 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 08:11:56 +0100 Subject: Clean up mess which was created by renaming :table to :routing_table. --- app/controllers/call_routes_controller.rb | 9 ++- app/controllers/gs_parameters_controller.rb | 8 +- app/models/call_route.rb | 7 +- db/migrate/20130116133243_create_call_routes.rb | 2 +- db/migrate/20130116203000_set_prerouting_table.rb | 92 +++++++++++----------- ...30117191840_change_column_name_in_call_route.rb | 8 +- 6 files changed, 65 insertions(+), 61 deletions(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 130a160..89f66ba 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -15,7 +15,7 @@ class CallRoutesController < ApplicationController end def create - @call_route = CallRoute.new(params[:call_route]) + @call_route = CallRoute.new(call_route_parameter_params[:call_route]) if @call_route.save redirect_to @call_route, :notice => t('call_routes.controller.successfuly_created') else @@ -27,7 +27,7 @@ class CallRoutesController < ApplicationController end def update - if @call_route.update_attributes(params[:call_route]) + if @call_route.update_attributes(call_route_parameter_params[:call_route]) redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated') else render :edit @@ -40,6 +40,10 @@ class CallRoutesController < ApplicationController end private + def call_route_parameter_params + params.require(:call_route).permit(:id, :routing_table, :name, :endpoint_type, :endpoint_id, :position) + end + def spread_breadcrumbs add_breadcrumb t("call_routes.index.page_title"), call_routes_path if @call_route && !@call_route.new_record? @@ -47,4 +51,5 @@ class CallRoutesController < ApplicationController end end + end diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index 7ca4e8e..3c212c1 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -10,7 +10,7 @@ class GsParametersController < ApplicationController end def show - @gs_parameter = GsParameter.find(params[:id]) + @gs_parameter = GsParameter.find(gs_parameter_params[:id]) end def new @@ -18,11 +18,11 @@ class GsParametersController < ApplicationController end def edit - @gs_parameter = GsParameter.find(params[:id]) + @gs_parameter = GsParameter.find(gs_parameter_params[:id]) end def update - @gs_parameter = GsParameter.find(params[:id]) + @gs_parameter = GsParameter.find(gs_parameter_params[:id]) if @gs_parameter.update_attributes(gs_parameter_params) redirect_to @gs_parameter, :notice => t('gs_parameters.controller.successfuly_updated') else @@ -32,7 +32,7 @@ class GsParametersController < ApplicationController private def gs_parameter_params - params.require(:gs_parameter).permit(:value, :class_type, :description) + params.require(:gs_parameter).permit(:id, :value, :class_type, :description) end def spread_breadcrumbs diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 0df961d..5d90901 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -1,14 +1,15 @@ class CallRoute < ActiveRecord::Base - ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] + # https://github.com/rails/strong_parameters + include ActiveModel::ForbiddenAttributesProtection - attr_accessible :routing_table, :name, :endpoint_type, :endpoint_id, :position + ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] has_many :route_elements, :dependent => :destroy validates :name, :presence => true - validates :table, + validates :routing_table, :presence => true, :inclusion => { :in => ROUTING_TABLES } diff --git a/db/migrate/20130116133243_create_call_routes.rb b/db/migrate/20130116133243_create_call_routes.rb index c2d3f45..c2feda8 100644 --- a/db/migrate/20130116133243_create_call_routes.rb +++ b/db/migrate/20130116133243_create_call_routes.rb @@ -1,7 +1,7 @@ class CreateCallRoutes < ActiveRecord::Migration def self.up create_table :call_routes do |t| - t.string :table + t.string :routing_table t.string :name t.string :endpoint_type t.integer :endpoint_id diff --git a/db/migrate/20130116203000_set_prerouting_table.rb b/db/migrate/20130116203000_set_prerouting_table.rb index 86137a0..8b0365f 100644 --- a/db/migrate/20130116203000_set_prerouting_table.rb +++ b/db/migrate/20130116203000_set_prerouting_table.rb @@ -1,99 +1,99 @@ class SetPreroutingTable < ActiveRecord::Migration def up - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*$', :replacement => 'f-li', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)#*$', :replacement => 'f-li-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*(%d+)%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*(%d+)%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)%*(%d+)#*$', :replacement => 'f-li-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#0#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#0#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#0#$', :replacement => 'f-lo', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*5%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*5%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*5%*(%d+)#$', :replacement => 'f-acdmtg-0-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*30#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*30#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*30#$', :replacement => 'f-clipon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#30#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#30#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#30#$', :replacement => 'f-clipoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*31#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*31#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#$', :replacement => 'f-cliroff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#31#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#31#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#$', :replacement => 'f-cliron', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#(%d+)$', :replacement => 'f-dcliroff-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#(%d+)$', :replacement => 'f-dcliron-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*43#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*43#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*43#$', :replacement => 'f-cwaon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#43#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#43#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#43#$', :replacement => 'f-cwaoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#002#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#002#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#002#$', :replacement => 'f-cfoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##002#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##002#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##002#$', :replacement => 'f-cfdel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*21#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*21#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21#$', :replacement => 'f-cfu', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#21#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#21#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#21#$', :replacement => 'f-cfuoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##21#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##21#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##21#$', :replacement => 'f-cfudel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61#$', :replacement => 'f-cfn', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#61#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#61#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#61#$', :replacement => 'f-cfnoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##61#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##61#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##61#$', :replacement => 'f-cfndel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*62#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*62#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62#$', :replacement => 'f-cfo', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#62#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#62#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#62#$', :replacement => 'f-cfooff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##62#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##62#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##62#$', :replacement => 'f-cfodel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*67#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*67#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67#$', :replacement => 'f-cfb', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#67#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#67#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#67#$', :replacement => 'f-cfboff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##67#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##67#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##67#$', :replacement => 'f-cfbdel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*66#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*66#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*66#$', :replacement => 'f-redial', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98#$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98%*(%d+)#$', :replacement => 'f-vmcheck-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*1337%*1%*1#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*1337%*1%*1#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*1#$', :replacement => 'f-loaon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*1337%*1%*0#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*1337%*1%*0#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*0#$', :replacement => 'f-loaoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'international prefix', :endpoint_type => 'phonenumber').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'international prefix', :endpoint_type => 'phonenumber').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^00(%d+)$', :replacement => '+%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'national prefix', :endpoint_type => 'phonenumber').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'national prefix', :endpoint_type => 'phonenumber').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^0(%d+)$', :replacement => '+49%1', :action => 'set_route_var', :mandatory => true) end def down - CallRoute.where(:table => "prerouting").destroy_all + CallRoute.where(:routing_table => "prerouting").destroy_all end end diff --git a/db/migrate/20130117191840_change_column_name_in_call_route.rb b/db/migrate/20130117191840_change_column_name_in_call_route.rb index cad0f59..bbc4f28 100644 --- a/db/migrate/20130117191840_change_column_name_in_call_route.rb +++ b/db/migrate/20130117191840_change_column_name_in_call_route.rb @@ -1,9 +1,7 @@ class ChangeColumnNameInCallRoute < ActiveRecord::Migration def up - rename_column :call_routes, :table, :routing_table - end - - def down - rename_column :call_routes, :routing_table, :table + if column_exists?(:call_routes, :table) + rename_column :call_routes, :table, :routing_table + end end end -- cgit v1.2.3 From 808c04b5b1776927dc7b854bb2a69d34b287c24c Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 09:45:54 +0100 Subject: validations removed --- app/models/route_element.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 32f730d..87b26ef 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -7,12 +7,6 @@ class RouteElement < ActiveRecord::Base acts_as_list :scope => :call_route - validates :var_in, - :presence => true - - validates :pattern, - :presence => true - validates :action, :presence => true, :inclusion => { :in => ELEMENT_ACTIONS } -- cgit v1.2.3 From 59b51b24e78a58ecd76baee530531df64ff3f668 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 09:47:04 +0100 Subject: set channel variables/headers --- misc/freeswitch/scripts/dialplan/sip_call.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 1513459..06132ab 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -135,6 +135,12 @@ function SipCall.fork(self, destinations, arg ) if destination.caller_id_name then table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'"); end + if destination.channel_variables then + for key, value in pairs(destination.channel_variables) do + self.log:notice('FORK_CHANNEL_VARIABLES: ', tostring(key) .. "='" .. tostring(value) .. "'"); + table.insert(origination_variables, tostring(key) .. "='" .. tostring(value) .. "'"); + end + end table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/gateway/' .. tostring(destination.gateway) .. '/' .. tostring(destination.number)); elseif destination.type == 'dial' then if destination.caller_id_number then -- cgit v1.2.3 From 983a3e274ab46609d0563d8e941ac4a8d90400c9 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 09:47:58 +0100 Subject: set channel variables/headers --- misc/freeswitch/scripts/dialplan/router.lua | 56 +++++++++++------------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index 33434ee..6c5b9f1 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -59,25 +59,6 @@ function Router.expand_variables(self, line) end -function Router.set_parameter(self, action, name, value) - if action == 'set_session_var' then - self.log:debug('ROUTER_SET_SESSION_VARIABLE - ', name, ' = ', value); - self.caller[name] = value; - elseif action == 'set_channel_var' then - self.log:debug('ROUTER_SET_VARIABLE - ', name, ' = ', value); - self.caller:set_variable(name, value); - elseif action == 'export_channel_var' then - self.log:debug('ROUTER_EXPORT_VARIABLE - ', name, ' = ', value); - self.caller:export_variable(name, value); - elseif action == 'set_header' then - self.log:debug('ROUTER_SIP_HEADER - ', name, ': ', value); - self.caller:export_variable('sip_h_' .. name, value); - else - self.log:error('ROUTER_SET_PARAMERER - unknown action: ', action, ', ', name, ' = ', value); - end -end - - function Router.element_match(self, pattern, search_string, replacement) local variables_list = {}; local success, result = pcall(string.find, search_string, pattern); @@ -126,20 +107,25 @@ function Router.route_match(self, route) local element = route.elements[index]; if element.action ~= 'none' then - local command, variable_name = common.str.partition(element.var_in, ':'); - - if not command or not variable_name or command == 'var' then - local search_string = tostring(common.str.try(self.caller, element.var_in)) - result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); - elseif command == 'key' or command == 'val' then - local groups = common.str.try(self.caller, variable_name); - result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key'); - elseif command == 'chv' then - local search_string = self.caller:to_s(variable_name); - result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); - elseif command == 'hdr' then - local search_string = self.caller:to_s('sip_h_' .. variable_name); - result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); + if common.str.blank(element.var_in) or common.str.blank(element.pattern) and element.action == 'set' then + result = true; + replacement = element.replacement; + else + local command, variable_name = common.str.partition(element.var_in, ':'); + + if not command or not variable_name or command == 'var' then + local search_string = tostring(common.str.try(self.caller, element.var_in)) + result, replacement = self:element_match(tostring(element.pattern), tostring(search_string), tostring(element.replacement)); + elseif command == 'key' or command == 'val' then + local groups = common.str.try(self.caller, variable_name); + result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key'); + elseif command == 'chv' then + local search_string = self.caller:to_s(variable_name); + result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); + elseif command == 'hdr' then + local search_string = self.caller:to_s('sip_h_' .. variable_name); + result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement)); + end end if element.action == 'not_match' then @@ -156,9 +142,9 @@ function Router.route_match(self, route) if not command or not variable_name or command == 'var' then destination[element.var_out] = replacement; elseif command == 'chv' then - table.insert(destination.channel_variables, { name = element.var_out, value = replacement }); + destination.channel_variables[variable_name] = replacement; elseif command == 'hdr' then - table.insert(destination.channel_variables, { name = 'sip_h_' .. tostring(element.var_out), value = replacement }); + destination.channel_variables['sip_h_' .. variable_name] = replacement; end end -- cgit v1.2.3 From 01078d50412183ff4fbeb213643093e6d2cf8714 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 10:08:47 +0100 Subject: log line removed --- misc/freeswitch/scripts/dialplan/sip_call.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 06132ab..0b799e5 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -137,7 +137,6 @@ function SipCall.fork(self, destinations, arg ) end if destination.channel_variables then for key, value in pairs(destination.channel_variables) do - self.log:notice('FORK_CHANNEL_VARIABLES: ', tostring(key) .. "='" .. tostring(value) .. "'"); table.insert(origination_variables, tostring(key) .. "='" .. tostring(value) .. "'"); end end -- cgit v1.2.3 From 5efd9bdd2f78a15569fb7d1569dceff3bb4f8800 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 10:19:09 +0100 Subject: Fixed a strange strong_parameter cancan bug. --- app/controllers/call_routes_controller.rb | 13 +++++++------ app/views/call_routes/_form_core.html.haml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 89f66ba..8b8698f 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -1,6 +1,4 @@ class CallRoutesController < ApplicationController - load_and_authorize_resource :call_route - before_filter :spread_breadcrumbs def index @@ -9,13 +7,15 @@ class CallRoutesController < ApplicationController end def show + @call_route = CallRoute.find(params[:id]) end def new + @call_route = CallRoute.new end def create - @call_route = CallRoute.new(call_route_parameter_params[:call_route]) + @call_route = CallRoute.new(call_route_parameter_params) if @call_route.save redirect_to @call_route, :notice => t('call_routes.controller.successfuly_created') else @@ -27,7 +27,8 @@ class CallRoutesController < ApplicationController end def update - if @call_route.update_attributes(call_route_parameter_params[:call_route]) + @call_route = CallRoute.find(params[:id]) + if @call_route.update_attributes(call_route_parameter_params) redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated') else render :edit @@ -35,13 +36,14 @@ class CallRoutesController < ApplicationController end def destroy + @call_route = CallRoute.find(params[:id]) @call_route.destroy redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed') end private def call_route_parameter_params - params.require(:call_route).permit(:id, :routing_table, :name, :endpoint_type, :endpoint_id, :position) + params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id) end def spread_breadcrumbs @@ -51,5 +53,4 @@ class CallRoutesController < ApplicationController end end - end diff --git a/app/views/call_routes/_form_core.html.haml b/app/views/call_routes/_form_core.html.haml index 2eee795..b64d660 100644 --- a/app/views/call_routes/_form_core.html.haml +++ b/app/views/call_routes/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs - = f.input :routing_table, :collection => CallRoute::ROUTING_TABLES, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint'), :include_blank => false + = f.input :routing_table, :collection => CallRoute::ROUTING_TABLES, :label => t('call_routes.form.table.label'), :hint => conditional_hint('call_routes.form.table.hint'), :include_blank => false, :autofocus => true = f.input :name, :label => t('call_routes.form.name.label'), :hint => conditional_hint('call_routes.form.name.hint') = f.input :endpoint_type, :label => t('call_routes.form.endpoint_type.label'), :hint => conditional_hint('call_routes.form.endpoint_type.hint') = f.input :endpoint_id, :label => t('call_routes.form.endpoint_id.label'), :hint => conditional_hint('call_routes.form.endpoint_id.hint') -- cgit v1.2.3 From b79543b0881a75c97a3710f4dadba6bf19ce6895 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 10:32:05 +0100 Subject: set inbound variables --- misc/freeswitch/scripts/dialplan/dialplan.lua | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 704728a..e90354c 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -880,11 +880,11 @@ function Dialplan.run(self, destination) route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('inbound', self.caller.destination_number, true); if route then - local ignore_keys = { + id = true, gateway = true, ['type'] = true, - actions = true, + channel_variables = true, }; for key, value in pairs(route) do @@ -897,23 +897,31 @@ function Dialplan.run(self, destination) else self.log:notice('INBOUND - no route'); end - - if false then - local route_object = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = self.routes }; - route = route_object:inbound(self.caller, self.caller.destination_number); - local inbound_caller_id_number = route_object:inbound_cid_number(self.caller, self.caller.gateway_name, 'gateway'); - route_object.expandable.caller_id_number = inbound_caller_id_number; - local inbound_caller_id_name = route_object:inbound_cid_name(self.caller, self.caller.gateway_name, 'gateway'); - self.log:info('INBOUND_CALLER_ID_REWRITE - number: ', inbound_caller_id_number, ', name: ', inbound_caller_id_name); - self.caller.caller_id_number = inbound_caller_id_number or self.caller.caller_id_number; - self.caller.caller_id_name = inbound_caller_id_name or self.caller.caller_id_name; - self.caller.caller_phone_numbers[1] = self.caller.caller_id_number; - end else route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('prerouting', self.caller.destination_number, true); + if route then + local ignore_keys = { + id = true, + gateway = true, + ['type'] = true, + channel_variables = true, + }; + + for key, value in pairs(route) do + if not ignore_keys[key] then + self.caller[key] = value; + end + end + end end if route then + if type(route.channel_variables) == 'table' then + for key, value in pairs(route.channel_variables) do + self.caller:set_variable(key, value); + end + end + destination = self:destination_new{ ['type'] = route.type, id = route.id, number = route.destination_number } self.caller.destination_number = destination.number; self.caller.destination = destination; -- cgit v1.2.3 From 8feb9102570d23f53c3443ccd3a409d87c97828d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 10:57:12 +0100 Subject: Refactoring and fixing #112 --- app/models/ability.rb | 4 ++ app/views/tenants/_admin_area.de.html.haml | 46 ++++++++-------------- app/views/tenants/_admin_area.html.haml | 45 ++++++++------------- .../tenants/_sip_accounts_and_phones.html.haml | 2 +- app/views/tenants/show.html.haml | 14 +++---- 5 files changed, 42 insertions(+), 69 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index cd91a8a..b846af0 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -27,6 +27,10 @@ class Ability # cannot [:create, :destroy, :edit, :update], Tenant, :id => 1 + # Can't destroy any tenant + # + cannot :destroy, Tenant + cannot :manage, PhoneBook # Phonebooks and PhoneBookEntries diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 0ef9da3..268c8e7 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -1,32 +1,3 @@ -- cache(['tenant_show_admin_area', 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')) - und haben deshalb besondere Rechte. Aber wie Peter Parker schon sagte: "With great power comes great responsibility." - - %p - = @tenant - hat - = link_to pluralize(@tenant.user_groups.count, 'user group'), tenant_user_groups_path(@tenant) - - if @tenant.user_groups.count < 5 - = "(#{@tenant.user_groups.order(:name).map{|group| group.to_s }.join(', ')})" - die in Summe - = link_to pluralize(@tenant.users.count, 'user'), tenant_users_path(@tenant) - verwalten. - Das System kann - = PhoneModel.count - verschiedene Telefonmodelle von den folgenden Herstellern verwalten: - - Manufacturer.all.each do |manufacturer| - - if manufacturer != Manufacturer.last && manufacturer != Manufacturer.limit(Manufacturer.count - 1).last - = succeed ', ' do - =link_to manufacturer, manufacturer_path(manufacturer) - - elsif manufacturer == Manufacturer.limit(Manufacturer.count - 1).last - = succeed ' und ' do - =link_to manufacturer, manufacturer_path(manufacturer) - - else - = succeed '.' do - =link_to manufacturer, manufacturer_path(manufacturer) - %h2 Admin Bereich = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} @@ -50,4 +21,19 @@ = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} %h2 Gemeinschaft Konfiguration -= render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} \ No newline at end of file += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} + +%p + Das System kann + = PhoneModel.count + verschiedene Telefonmodelle von den folgenden Herstellern verwalten: + - Manufacturer.all.each do |manufacturer| + - if manufacturer != Manufacturer.last && manufacturer != Manufacturer.limit(Manufacturer.count - 1).last + = succeed ', ' do + =link_to manufacturer, manufacturer_path(manufacturer) + - elsif manufacturer == Manufacturer.limit(Manufacturer.count - 1).last + = succeed ' und ' do + =link_to manufacturer, manufacturer_path(manufacturer) + - else + = succeed '.' do + =link_to manufacturer, manufacturer_path(manufacturer) \ No newline at end of file diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index 7b47587..e708215 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -1,31 +1,3 @@ -- cache(['tenant_show_admin_area', 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')) - and therefore have super powers. But always remember Peter Parker's: "With great power comes great responsibility." - - %p - = succeed '.' do - This tenant has - = link_to pluralize(@tenant.user_groups.count, 'user group'), tenant_user_groups_path(@tenant) - - if @tenant.user_groups.count < 5 - = "(#{@tenant.user_groups.order(:name).map{|group| group.to_s }.join(', ')})" - which handle a total of - = link_to pluralize(@tenant.users.count, 'user'), tenant_users_path(@tenant) - This system can setup - = PhoneModel.count - different phone models from the manufacturers - - Manufacturer.all.each do |manufacturer| - - if manufacturer != Manufacturer.last && manufacturer != Manufacturer.limit(Manufacturer.count - 1).last - = succeed ', ' do - =link_to manufacturer, manufacturer_path(manufacturer) - - elsif manufacturer == Manufacturer.limit(Manufacturer.count - 1).last - = succeed ' and ' do - =link_to manufacturer, manufacturer_path(manufacturer) - - else - = succeed '.' do - =link_to manufacturer, manufacturer_path(manufacturer) - %h2 Admin Area = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} @@ -49,4 +21,19 @@ = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} %h2 Gemeinschaft Configuration -= render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} \ No newline at end of file += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} + +%p + This system can setup + = PhoneModel.count + different phone models from the manufacturers + - Manufacturer.all.each do |manufacturer| + - if manufacturer != Manufacturer.last && manufacturer != Manufacturer.limit(Manufacturer.count - 1).last + = succeed ', ' do + =link_to manufacturer, manufacturer_path(manufacturer) + - elsif manufacturer == Manufacturer.limit(Manufacturer.count - 1).last + = succeed ' and ' do + =link_to manufacturer, manufacturer_path(manufacturer) + - else + = succeed '.' do + =link_to manufacturer, manufacturer_path(manufacturer) \ No newline at end of file diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml index e322b67..4b84b1c 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -21,7 +21,7 @@ = '[' + 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} - - cache(['tenant_show_admin_area_sip_accounts_table_cell', I18n.locale, @tenant, @tenant.phones.count, @tenant.phones.reorder(:updated_at).last]) do + - cache(['tenant_show_admin_area_phones_table_cell', I18n.locale, @tenant, @tenant.phones.count, @tenant.phones.reorder(:updated_at).last]) do %td - if tenant.phones.any? - if tenant.phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') diff --git a/app/views/tenants/show.html.haml b/app/views/tenants/show.html.haml index 10845cf..f5cff5f 100644 --- a/app/views/tenants/show.html.haml +++ b/app/views/tenants/show.html.haml @@ -1,15 +1,11 @@ -- title t("tenants.show.page_title") +- title @tenant.name -- cache(['tenant_show_name_and_description', I18n.locale, @tenant, current_user]) do +- if !@tenant.description.blank? %p - %strong= t('tenants.show.name') + ":" - = @tenant.name - - if !@tenant.description.blank? - %p - %strong= t('tenants.show.description') + ":" - = @tenant.description + %strong= t('tenants.show.description') + ":" + = @tenant.description - = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @tenant } += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @tenant } - if @tenant.user_groups.where(:name => 'Admins').count > 0 && @tenant.user_groups.where(:name => 'Admins').first.users.include?(current_user) = render 'admin_area' \ No newline at end of file -- cgit v1.2.3 From dc3f3ef9eb0d0669d48be0795ecd601350ac978f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 11:00:34 +0100 Subject: Closes #113 --- app/controllers/gs_parameters_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index 3c212c1..7ca4e8e 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -10,7 +10,7 @@ class GsParametersController < ApplicationController end def show - @gs_parameter = GsParameter.find(gs_parameter_params[:id]) + @gs_parameter = GsParameter.find(params[:id]) end def new @@ -18,11 +18,11 @@ class GsParametersController < ApplicationController end def edit - @gs_parameter = GsParameter.find(gs_parameter_params[:id]) + @gs_parameter = GsParameter.find(params[:id]) end def update - @gs_parameter = GsParameter.find(gs_parameter_params[:id]) + @gs_parameter = GsParameter.find(params[:id]) if @gs_parameter.update_attributes(gs_parameter_params) redirect_to @gs_parameter, :notice => t('gs_parameters.controller.successfuly_updated') else @@ -32,7 +32,7 @@ class GsParametersController < ApplicationController private def gs_parameter_params - params.require(:gs_parameter).permit(:id, :value, :class_type, :description) + params.require(:gs_parameter).permit(:value, :class_type, :description) end def spread_breadcrumbs -- cgit v1.2.3 From ba4d32db18a7e6dd701dcfb210ec6af062ee2446 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 11:07:08 +0100 Subject: Added caching for users table. --- app/views/users/_index_core.html.haml | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/app/views/users/_index_core.html.haml b/app/views/users/_index_core.html.haml index 51c15de..5d0fd16 100644 --- a/app/views/users/_index_core.html.haml +++ b/app/views/users/_index_core.html.haml @@ -1,18 +1,20 @@ -%table - %tr - %th - %th= t('users.index.user_name') - %th= t('users.index.email') - %th= t('users.index.first_name') - %th= t('users.index.last_name') +- cache(['user_table_row_inner_td', I18n.locale, current_user, users.order(:updated_at).last, users.count]) do + %table + %tr + %th + %th= t('users.index.user_name') + %th= t('users.index.email') + %th= t('users.index.first_name') + %th= t('users.index.last_name') - - reset_cycle - - for user in users - %tr{:class => cycle('odd', 'even')} - %td - = image_tag user.image_url(:mini).to_s if user.image_url(:mini) - %td= user.user_name - %td= user.email - %td= user.first_name - %td= user.last_name - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => @tenant, :child => user} \ No newline at end of file + - reset_cycle + - for user in users + %tr{:class => cycle('odd', 'even')} + - cache(['user_table_row_inner_td', I18n.locale, current_user, user]) do + %td + = image_tag user.image_url(:mini).to_s if user.image_url(:mini) + %td= user.user_name + %td= user.email + %td= user.first_name + %td= user.last_name + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => @tenant, :child => user} \ No newline at end of file -- cgit v1.2.3 From d4e7d4a5d5bdb63fbda279dbc8dd2ec495b90907 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 11:08:34 +0100 Subject: Added GsParameter.get('NUMBER_OF_SHOWN_ITEMS') to the cache key. --- app/views/users/_index_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_index_core.html.haml b/app/views/users/_index_core.html.haml index 5d0fd16..9376826 100644 --- a/app/views/users/_index_core.html.haml +++ b/app/views/users/_index_core.html.haml @@ -1,4 +1,4 @@ -- cache(['user_table_row_inner_td', I18n.locale, current_user, users.order(:updated_at).last, users.count]) do +- cache(['user_table_row_inner_td', I18n.locale, current_user, users.order(:updated_at).last, users.count, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do %table %tr %th -- cgit v1.2.3 From 78cfbba5f201d2468c628abdfd457b1f14495541 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 11:18:30 +0100 Subject: set variables --- misc/freeswitch/scripts/dialplan/dialplan.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index e90354c..0407485 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -624,7 +624,7 @@ function Dialplan.callthrough(self, destination) end require 'dialplan.router' - local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('prerouting', destination_number, true); + local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', destination_number, true); if route and route.destination_number then destination_number = route.destination_number; @@ -773,7 +773,7 @@ function Dialplan.switch(self, destination) destination.callee_id_name = nil; require 'dialplan.router' - local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('outbound', destination.number); + local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('outbound', destination.number); if not routes or #routes == 0 then self.log:notice('SWITCH - no route - number: ', destination.number); @@ -878,7 +878,7 @@ function Dialplan.run(self, destination) self.caller.destination_number = self.caller:to_s(self.caller.gateway.settings.number_source); end - route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('inbound', self.caller.destination_number, true); + route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('inbound', self.caller.destination_number, true); if route then local ignore_keys = { id = true, @@ -898,7 +898,7 @@ function Dialplan.run(self, destination) self.log:notice('INBOUND - no route'); end else - route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('prerouting', self.caller.destination_number, true); + route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', self.caller.destination_number, true); if route then local ignore_keys = { id = true, -- cgit v1.2.3 From 1e465e49670f6c0fccc1cd920992a14942d3cfba Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 11:19:09 +0100 Subject: expand variables --- misc/freeswitch/scripts/dialplan/router.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index 6c5b9f1..5f427ac 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -52,21 +52,20 @@ function Router.read_table(self, table_name) end -function Router.expand_variables(self, line) - return (line:gsub('{([%a%d_]+)}', function(captured) - return variables[captured] or ''; +function Router.expand_variables(self, line, variables) + return (line:gsub('{([%a%d%._]+)}', function(captured) + return common.str.try(variables, captured) or ''; end)) end function Router.element_match(self, pattern, search_string, replacement) - local variables_list = {}; local success, result = pcall(string.find, search_string, pattern); if not success then self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string); elseif result then - return true, search_string:gsub(pattern, self:expand_variables(replacement, variables_list)); + return true, search_string:gsub(pattern, self:expand_variables(replacement, self.variables)); end return false; @@ -109,7 +108,7 @@ function Router.route_match(self, route) if element.action ~= 'none' then if common.str.blank(element.var_in) or common.str.blank(element.pattern) and element.action == 'set' then result = true; - replacement = element.replacement; + replacement = self:expand_variables(element.replacement, self.variables); else local command, variable_name = common.str.partition(element.var_in, ':'); -- cgit v1.2.3 From a76f384bef7deed913af1e2ee54eb1c295b62edd Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 11:55:18 +0100 Subject: gateways ini rexample removed --- misc/freeswitch/scripts/ini/gateways.ini.example | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 misc/freeswitch/scripts/ini/gateways.ini.example diff --git a/misc/freeswitch/scripts/ini/gateways.ini.example b/misc/freeswitch/scripts/ini/gateways.ini.example deleted file mode 100644 index b6ae018..0000000 --- a/misc/freeswitch/scripts/ini/gateways.ini.example +++ /dev/null @@ -1,23 +0,0 @@ -; Gemeinschaft 5 gateways configuration file -; (c) AMOOMA GmbH 2012 -; - -[gateway1] -profile = gemeinschaft -name = gateway1 -username = gateway1 -realm = gemeinschaft -password = freeswitch -extension = default -proxy = 192.168.0.1 -expire-seconds = 600 -register = true - -[gateway2] -profile = gemeinschaft -name = sipgate -username = 1234567e0 -password = ABCdeF -proxy = sipgate.com -register = true -extension = {sip_to_user} -- cgit v1.2.3 From 045a4cfb6374cde4c664e91a9f8d1fede844b610 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 11:57:19 +0100 Subject: unused constant removed --- misc/freeswitch/scripts/dialplan/dialplan.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 0407485..87652d5 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -7,7 +7,6 @@ module(...,package.seeall) Dialplan = {} -- local constants -local CONFIG_FILE_NAME = '/opt/freeswitch/scripts/ini/dialplan.ini'; local DIAL_TIMEOUT = 120; local MAX_LOOPS = 20; local DIALPLAN_FUNCTION_PATTERN = '^f[_%-].*'; -- cgit v1.2.3 From 3a91509c6c668cc634d667a2e1c7144873a39861 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 12:10:48 +0100 Subject: gateway find_by_name method added --- misc/freeswitch/scripts/common/gateway.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 5c76aba..e50c763 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -52,6 +52,27 @@ function Gateway.find_by_id(self, id) end +function Gateway.find_by_name(self, name) + local gateway_name = name:gsub('([^%a%d%._%+])', ''); + + local sql_query = 'SELECT * FROM `gateways` WHERE `name`= "' .. gateway_name .. '" LIMIT 1'; + + local gateway = nil; + self.database:query(sql_query, function(entry) + gateway = Gateway:new(self); + gateway.record = entry; + gateway.id = tonumber(entry.id); + gateway.name = entry.name; + end) + + if gateway then + gateway.settings = self:config_table_get('gateway_settings', gateway.id); + end + + return gateway; +end + + function Gateway.authenticate(self, technology, caller) local sql_query = 'SELECT `c`.`name`, `c`.`id`, `a`.`value` `auth_source`, `b`.`value` `auth_pattern` \ FROM `gateway_settings` `a` \ -- cgit v1.2.3 From c7d5128985e4f4480068f467ad8efafdc7f7b7ed Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 12:13:11 +0100 Subject: configuration.sip removed --- misc/freeswitch/scripts/configuration.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/misc/freeswitch/scripts/configuration.lua b/misc/freeswitch/scripts/configuration.lua index 1162e97..92ae7d8 100644 --- a/misc/freeswitch/scripts/configuration.lua +++ b/misc/freeswitch/scripts/configuration.lua @@ -312,10 +312,9 @@ function directory_sip_account(database) if string.len(auth_name) > 3 and auth_name:sub(1, 3) == 'gw+' then local gateway_name = auth_name:sub(4); domain = domain or freeswitch.API():execute('global_getvar', 'domain'); - require 'configuration.sip' - log:notice('DATABASE: ', database); - local sip_gateway = configuration.sip.Sip:new{ log = log, database = database}:find_gateway_by_name(gateway_name); - if sip_gateway ~= nil and next(sip_gateway) ~= nil then + require 'common.gateway' + local sip_gateway = common.gateway.Gateway:new{ log = self.log, database = self.database }:find_by_name(gateway_name); + if sip_gateway then log:debug('DIRECTORY_GATEWAY - name: ', gateway_name, ', auth_name: ', auth_name); local user_variables = { @@ -332,7 +331,7 @@ function directory_sip_account(database) 'params', xml:element{ 'param', - password = sip_gateway.password, + password = sip_gateway.record.password, } }, xml:element{ -- cgit v1.2.3 From 5e46709cadac227cbe5a2459a48d284ad657db36 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 12:17:03 +0100 Subject: find_gateway_by_name method removed --- misc/freeswitch/scripts/configuration/sip.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/misc/freeswitch/scripts/configuration/sip.lua b/misc/freeswitch/scripts/configuration/sip.lua index 78143bc..4679aae 100644 --- a/misc/freeswitch/scripts/configuration/sip.lua +++ b/misc/freeswitch/scripts/configuration/sip.lua @@ -18,12 +18,6 @@ function Sip.new(self, arg) return object; end --- find gateway by name -function Sip.find_gateway_by_name(self, name) - require 'common.configuration_file' - return common.configuration_file.get('/opt/freeswitch/scripts/ini/gateways.ini', name); -end - -- list sip domains function Sip.domains(self) local sql_query = 'SELECT * FROM `sip_domains`'; -- cgit v1.2.3 From b5b1a19dd00eb8455ea21072bdd8249c82172619 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 12:18:39 +0100 Subject: save code lines --- misc/freeswitch/scripts/event_manager.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/misc/freeswitch/scripts/event_manager.lua b/misc/freeswitch/scripts/event_manager.lua index 0e3c0e0..707b8a2 100644 --- a/misc/freeswitch/scripts/event_manager.lua +++ b/misc/freeswitch/scripts/event_manager.lua @@ -17,10 +17,9 @@ if not database:connected() then end require "configuration.sip" -local sip = configuration.sip.Sip:new{ log = log, database = database } +local domains = configuration.sip.Sip:new{ log = log, database = database }:domains(); local domain = '127.0.0.1'; -local domains = sip:domains(); if domains[1] then domain = domains[1]['host']; else -- cgit v1.2.3 From 8744de13516c3fc2fbf2843e85aff08707f50de1 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Fri, 18 Jan 2013 12:54:45 +0100 Subject: adjust copyright date for 2013 --- misc/freeswitch/scripts/acd_wait.lua | 2 +- misc/freeswitch/scripts/common/call_forwarding.lua | 2 +- misc/freeswitch/scripts/common/call_history.lua | 2 +- misc/freeswitch/scripts/common/conference.lua | 2 +- misc/freeswitch/scripts/common/configuration_file.lua | 2 +- misc/freeswitch/scripts/common/fapi.lua | 2 +- misc/freeswitch/scripts/common/ipcalc.lua | 2 +- misc/freeswitch/scripts/common/log.lua | 2 +- misc/freeswitch/scripts/common/phone_number.lua | 2 +- misc/freeswitch/scripts/common/routing_tables.lua | 2 +- misc/freeswitch/scripts/common/sip_account.lua | 2 +- misc/freeswitch/scripts/common/str.lua | 2 +- misc/freeswitch/scripts/common/sync_log.lua | 2 +- misc/freeswitch/scripts/configuration.lua | 2 +- misc/freeswitch/scripts/configuration/sip.lua | 2 +- misc/freeswitch/scripts/dialplan/acd.lua | 2 +- misc/freeswitch/scripts/dialplan/cdr.lua | 2 +- misc/freeswitch/scripts/dialplan/dialplan.lua | 2 +- misc/freeswitch/scripts/dialplan/fax.lua | 2 +- misc/freeswitch/scripts/dialplan/geo_number.lua | 2 +- misc/freeswitch/scripts/dialplan/hunt_group.lua | 2 +- misc/freeswitch/scripts/dialplan/phone_book.lua | 2 +- misc/freeswitch/scripts/dialplan/presence.lua | 2 +- misc/freeswitch/scripts/dialplan/route.lua | 2 +- misc/freeswitch/scripts/dialplan/session.lua | 2 +- misc/freeswitch/scripts/dialplan/sip_call.lua | 2 +- misc/freeswitch/scripts/dialplan/tenant.lua | 2 +- misc/freeswitch/scripts/dialplan/user.lua | 2 +- misc/freeswitch/scripts/dialplan/voicemail.lua | 2 +- misc/freeswitch/scripts/dialplan_default.lua | 2 +- misc/freeswitch/scripts/event/call_history_save.lua | 2 +- misc/freeswitch/scripts/event/cdr_save.lua | 2 +- misc/freeswitch/scripts/event/event.lua | 2 +- misc/freeswitch/scripts/event/perimeter.lua | 2 +- misc/freeswitch/scripts/event_manager.lua | 2 +- misc/freeswitch/scripts/fax_daemon.lua | 2 +- misc/freeswitch/scripts/ini/routes.ini | 2 +- misc/freeswitch/scripts/phones/phone.lua | 2 +- misc/freeswitch/scripts/phones/siemens.lua | 2 +- misc/freeswitch/scripts/phones/snom.lua | 2 +- misc/freeswitch/scripts/send_fax.lua | 2 +- misc/mon_ami/asterisk.py | 2 +- misc/mon_ami/freeswitch.py | 2 +- misc/mon_ami/helper.py | 2 +- misc/mon_ami/log.py | 2 +- misc/mon_ami/mon_ami | 2 +- misc/mon_ami/mon_ami_handler.py | 2 +- misc/mon_ami/mon_ami_main.py | 2 +- misc/mon_ami/mon_ami_server.py | 2 +- misc/mon_ami/tcp_server.py | 2 +- 50 files changed, 50 insertions(+), 50 deletions(-) diff --git a/misc/freeswitch/scripts/acd_wait.lua b/misc/freeswitch/scripts/acd_wait.lua index fd16bea..c05cc24 100644 --- a/misc/freeswitch/scripts/acd_wait.lua +++ b/misc/freeswitch/scripts/acd_wait.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5: acd call handler --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- local caller_uuid = argv[1]; diff --git a/misc/freeswitch/scripts/common/call_forwarding.lua b/misc/freeswitch/scripts/common/call_forwarding.lua index 3942d05..400fcde 100644 --- a/misc/freeswitch/scripts/common/call_forwarding.lua +++ b/misc/freeswitch/scripts/common/call_forwarding.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: call forwarding class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/call_history.lua b/misc/freeswitch/scripts/common/call_history.lua index 7a9ac07..7e1e22b 100644 --- a/misc/freeswitch/scripts/common/call_history.lua +++ b/misc/freeswitch/scripts/common/call_history.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: call_history class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/conference.lua b/misc/freeswitch/scripts/common/conference.lua index a7b21c3..ca5fa62 100644 --- a/misc/freeswitch/scripts/common/conference.lua +++ b/misc/freeswitch/scripts/common/conference.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: conference class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/configuration_file.lua b/misc/freeswitch/scripts/common/configuration_file.lua index 67e1f3b..3b3efbc 100644 --- a/misc/freeswitch/scripts/common/configuration_file.lua +++ b/misc/freeswitch/scripts/common/configuration_file.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: configuration file --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/fapi.lua b/misc/freeswitch/scripts/common/fapi.lua index 0a05155..5b96633 100644 --- a/misc/freeswitch/scripts/common/fapi.lua +++ b/misc/freeswitch/scripts/common/fapi.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: FS api class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/ipcalc.lua b/misc/freeswitch/scripts/common/ipcalc.lua index 5c19d20..49cb56c 100644 --- a/misc/freeswitch/scripts/common/ipcalc.lua +++ b/misc/freeswitch/scripts/common/ipcalc.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: ip calculation functions --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/log.lua b/misc/freeswitch/scripts/common/log.lua index d0d13dc..5aff2b8 100644 --- a/misc/freeswitch/scripts/common/log.lua +++ b/misc/freeswitch/scripts/common/log.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: log --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/phone_number.lua b/misc/freeswitch/scripts/common/phone_number.lua index 4df0d57..6635296 100644 --- a/misc/freeswitch/scripts/common/phone_number.lua +++ b/misc/freeswitch/scripts/common/phone_number.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: phone number class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/routing_tables.lua b/misc/freeswitch/scripts/common/routing_tables.lua index 34d0143..f28b5c5 100644 --- a/misc/freeswitch/scripts/common/routing_tables.lua +++ b/misc/freeswitch/scripts/common/routing_tables.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: routing table functions --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/sip_account.lua b/misc/freeswitch/scripts/common/sip_account.lua index 28a00df..8dd432b 100644 --- a/misc/freeswitch/scripts/common/sip_account.lua +++ b/misc/freeswitch/scripts/common/sip_account.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: sip account class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/str.lua b/misc/freeswitch/scripts/common/str.lua index c366fda..32f054e 100644 --- a/misc/freeswitch/scripts/common/str.lua +++ b/misc/freeswitch/scripts/common/str.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: string functions --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/common/sync_log.lua b/misc/freeswitch/scripts/common/sync_log.lua index 05b0dcf..3fdb646 100644 --- a/misc/freeswitch/scripts/common/sync_log.lua +++ b/misc/freeswitch/scripts/common/sync_log.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: sync log class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/configuration.lua b/misc/freeswitch/scripts/configuration.lua index 92ae7d8..9e62bb6 100644 --- a/misc/freeswitch/scripts/configuration.lua +++ b/misc/freeswitch/scripts/configuration.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 dynamic freeswitch configuration --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- function nodes(database, local_node_id) diff --git a/misc/freeswitch/scripts/configuration/sip.lua b/misc/freeswitch/scripts/configuration/sip.lua index 4679aae..6f5b204 100644 --- a/misc/freeswitch/scripts/configuration/sip.lua +++ b/misc/freeswitch/scripts/configuration/sip.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: sip configuration class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/acd.lua b/misc/freeswitch/scripts/dialplan/acd.lua index 563d836..f4b298e 100644 --- a/misc/freeswitch/scripts/dialplan/acd.lua +++ b/misc/freeswitch/scripts/dialplan/acd.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: acd class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/cdr.lua b/misc/freeswitch/scripts/dialplan/cdr.lua index 55a7889..d0fdede 100644 --- a/misc/freeswitch/scripts/dialplan/cdr.lua +++ b/misc/freeswitch/scripts/dialplan/cdr.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: cdr class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 87652d5..405a664 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: dialplan class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/fax.lua b/misc/freeswitch/scripts/dialplan/fax.lua index 2a40620..aa29ff6 100644 --- a/misc/freeswitch/scripts/dialplan/fax.lua +++ b/misc/freeswitch/scripts/dialplan/fax.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: fax class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/geo_number.lua b/misc/freeswitch/scripts/dialplan/geo_number.lua index 06bfd62..76cc01b 100644 --- a/misc/freeswitch/scripts/dialplan/geo_number.lua +++ b/misc/freeswitch/scripts/dialplan/geo_number.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: geonumber class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/hunt_group.lua b/misc/freeswitch/scripts/dialplan/hunt_group.lua index 87f86f1..44c2bb8 100644 --- a/misc/freeswitch/scripts/dialplan/hunt_group.lua +++ b/misc/freeswitch/scripts/dialplan/hunt_group.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: hunt group class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/phone_book.lua b/misc/freeswitch/scripts/dialplan/phone_book.lua index 089f115..6653789 100644 --- a/misc/freeswitch/scripts/dialplan/phone_book.lua +++ b/misc/freeswitch/scripts/dialplan/phone_book.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: phone book class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/presence.lua b/misc/freeswitch/scripts/dialplan/presence.lua index 234b908..0f63ce9 100644 --- a/misc/freeswitch/scripts/dialplan/presence.lua +++ b/misc/freeswitch/scripts/dialplan/presence.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: presence class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/route.lua b/misc/freeswitch/scripts/dialplan/route.lua index 2243cbe..a12b5f9 100644 --- a/misc/freeswitch/scripts/dialplan/route.lua +++ b/misc/freeswitch/scripts/dialplan/route.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: routing class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/session.lua b/misc/freeswitch/scripts/dialplan/session.lua index 20fef88..4029f9e 100644 --- a/misc/freeswitch/scripts/dialplan/session.lua +++ b/misc/freeswitch/scripts/dialplan/session.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: caller session class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 0b799e5..3f56753 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: sip call class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall); diff --git a/misc/freeswitch/scripts/dialplan/tenant.lua b/misc/freeswitch/scripts/dialplan/tenant.lua index 8d6436c..904609e 100644 --- a/misc/freeswitch/scripts/dialplan/tenant.lua +++ b/misc/freeswitch/scripts/dialplan/tenant.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: user class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/user.lua b/misc/freeswitch/scripts/dialplan/user.lua index 0a2e0dd..b536600 100644 --- a/misc/freeswitch/scripts/dialplan/user.lua +++ b/misc/freeswitch/scripts/dialplan/user.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: user class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/voicemail.lua b/misc/freeswitch/scripts/dialplan/voicemail.lua index fe20128..5d79ba3 100644 --- a/misc/freeswitch/scripts/dialplan/voicemail.lua +++ b/misc/freeswitch/scripts/dialplan/voicemail.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: voicemail class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index eb80ae4..7caff57 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 default dialplan --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- diff --git a/misc/freeswitch/scripts/event/call_history_save.lua b/misc/freeswitch/scripts/event/call_history_save.lua index 057ca16..ba7a8f6 100644 --- a/misc/freeswitch/scripts/event/call_history_save.lua +++ b/misc/freeswitch/scripts/event/call_history_save.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: call_history event handler class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/event/cdr_save.lua b/misc/freeswitch/scripts/event/cdr_save.lua index ed53aa3..e7ac64a 100644 --- a/misc/freeswitch/scripts/event/cdr_save.lua +++ b/misc/freeswitch/scripts/event/cdr_save.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: cdr event handler class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/event/event.lua b/misc/freeswitch/scripts/event/event.lua index c57b32a..08d8bfe 100644 --- a/misc/freeswitch/scripts/event/event.lua +++ b/misc/freeswitch/scripts/event/event.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: event manager class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/event/perimeter.lua b/misc/freeswitch/scripts/event/perimeter.lua index 86c50d4..5bbb032 100644 --- a/misc/freeswitch/scripts/event/perimeter.lua +++ b/misc/freeswitch/scripts/event/perimeter.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: cdr event handler class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/event_manager.lua b/misc/freeswitch/scripts/event_manager.lua index 707b8a2..4e78ccf 100644 --- a/misc/freeswitch/scripts/event_manager.lua +++ b/misc/freeswitch/scripts/event_manager.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5.0 event handler --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- -- Set logger diff --git a/misc/freeswitch/scripts/fax_daemon.lua b/misc/freeswitch/scripts/fax_daemon.lua index cfe7c4e..6609fe6 100644 --- a/misc/freeswitch/scripts/fax_daemon.lua +++ b/misc/freeswitch/scripts/fax_daemon.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5.0 fax daemon --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- local MAIN_LOOP_SLEEP_TIME = 30; diff --git a/misc/freeswitch/scripts/ini/routes.ini b/misc/freeswitch/scripts/ini/routes.ini index 33d2f38..535ba63 100644 --- a/misc/freeswitch/scripts/ini/routes.ini +++ b/misc/freeswitch/scripts/ini/routes.ini @@ -1,5 +1,5 @@ ; Gemeinschaft 5 routing configuration file -; (c) AMOOMA GmbH 2012 +; (c) AMOOMA GmbH 2012-2013 ; [general] diff --git a/misc/freeswitch/scripts/phones/phone.lua b/misc/freeswitch/scripts/phones/phone.lua index bc2aa3d..856398b 100644 --- a/misc/freeswitch/scripts/phones/phone.lua +++ b/misc/freeswitch/scripts/phones/phone.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: phone class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/phones/siemens.lua b/misc/freeswitch/scripts/phones/siemens.lua index 71bb40a..ad2447a 100644 --- a/misc/freeswitch/scripts/phones/siemens.lua +++ b/misc/freeswitch/scripts/phones/siemens.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: general siemens model class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/phones/snom.lua b/misc/freeswitch/scripts/phones/snom.lua index 80d1fce..096ccb7 100644 --- a/misc/freeswitch/scripts/phones/snom.lua +++ b/misc/freeswitch/scripts/phones/snom.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: general snom model class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/send_fax.lua b/misc/freeswitch/scripts/send_fax.lua index 321a5b1..a3de5f6 100644 --- a/misc/freeswitch/scripts/send_fax.lua +++ b/misc/freeswitch/scripts/send_fax.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5.0 --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- local FAX_FILE_PATH = "/opt/GS5/public/uploads/fax_document/tiff/"; diff --git a/misc/mon_ami/asterisk.py b/misc/mon_ami/asterisk.py index ffcff06..3406c5b 100644 --- a/misc/mon_ami/asterisk.py +++ b/misc/mon_ami/asterisk.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface Server # Asterisk AMI client connector -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 from threading import Thread, Lock from log import ldebug, linfo, lwarn, lerror, lcritic diff --git a/misc/mon_ami/freeswitch.py b/misc/mon_ami/freeswitch.py index eab9bb6..218b7db 100644 --- a/misc/mon_ami/freeswitch.py +++ b/misc/mon_ami/freeswitch.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface server # FreeSWITCH event socket interface -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 from threading import Thread, Lock from log import ldebug, linfo, lwarn, lerror, lcritic diff --git a/misc/mon_ami/helper.py b/misc/mon_ami/helper.py index bf286de..8e665a4 100644 --- a/misc/mon_ami/helper.py +++ b/misc/mon_ami/helper.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface server # helper functions -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 def to_hash(message): diff --git a/misc/mon_ami/log.py b/misc/mon_ami/log.py index 92709ad..e89a53f 100644 --- a/misc/mon_ami/log.py +++ b/misc/mon_ami/log.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Log library -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 import logging diff --git a/misc/mon_ami/mon_ami b/misc/mon_ami/mon_ami index a212cfe..0e8ce50 100755 --- a/misc/mon_ami/mon_ami +++ b/misc/mon_ami/mon_ami @@ -1,7 +1,7 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface Server -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 from mon_ami_main import main from sys import exit diff --git a/misc/mon_ami/mon_ami_handler.py b/misc/mon_ami/mon_ami_handler.py index 59e9225..015f547 100644 --- a/misc/mon_ami/mon_ami_handler.py +++ b/misc/mon_ami/mon_ami_handler.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface Server # Asterisk AMI Emulator Handler Process -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 from threading import Thread from log import ldebug, linfo, lwarn, lerror, lcritic diff --git a/misc/mon_ami/mon_ami_main.py b/misc/mon_ami/mon_ami_main.py index 13dd4bb..72220e5 100644 --- a/misc/mon_ami/mon_ami_main.py +++ b/misc/mon_ami/mon_ami_main.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface Server # Main Programm -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 from log import ldebug, linfo, lwarn, lerror, lcritic, setup_log from time import sleep diff --git a/misc/mon_ami/mon_ami_server.py b/misc/mon_ami/mon_ami_server.py index 68e72c8..d3d7c0f 100644 --- a/misc/mon_ami/mon_ami_server.py +++ b/misc/mon_ami/mon_ami_server.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface Server # Asterisk AMI Emulator server thread -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 from threading import Thread from log import ldebug, linfo, lwarn, lerror, lcritic diff --git a/misc/mon_ami/tcp_server.py b/misc/mon_ami/tcp_server.py index 5536282..5faa9ea 100644 --- a/misc/mon_ami/tcp_server.py +++ b/misc/mon_ami/tcp_server.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # MonAMI Asterisk Manger Interface Server # TCP Server -# (c) AMOOMA GmbH 2012 +# (c) AMOOMA GmbH 2012-2013 import socket from traceback import format_exc -- cgit v1.2.3 From 8b37b125399ba4019091b83efe889dc8af89185f Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Fri, 18 Jan 2013 13:41:02 +0100 Subject: set log_level to warn for production environment (takeover from GBE) --- config/environments/production.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index f715d91..344f8f8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -30,8 +30,8 @@ Gemeinschaft42c::Application.configure do # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # See everything in the log (default is :info) - # config.log_level = :debug + # Show only warnings in log files + config.log_level = :warn # Use a different logger for distributed setups # config.logger = SyslogLogger.new -- cgit v1.2.3 From baafa28ebe7046a987083f853cfe5a1a55b7adb3 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 14:19:01 +0100 Subject: dialed_sip_user and dialed_domain added --- misc/freeswitch/scripts/dialplan/session.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/freeswitch/scripts/dialplan/session.lua b/misc/freeswitch/scripts/dialplan/session.lua index 20fef88..dc53f7a 100644 --- a/misc/freeswitch/scripts/dialplan/session.lua +++ b/misc/freeswitch/scripts/dialplan/session.lua @@ -43,6 +43,9 @@ function Session.init_channel_variables(self) self.from_gateway = true; end + self.dialed_sip_user = self.caller:to_s('dialed_user'); + self.dialed_domain = self.caller:to_s('dialed_domain'); + self.account_uuid = self:to_s('gs_account_uuid'); self.account_type = self:to_s('gs_account_type'); self.sip_contact_host = self:to_s('sip_contact_host'); -- cgit v1.2.3 From 8e58b80f2da3eb341e1be2ad5847606030910963 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 14:20:32 +0100 Subject: retrieve_caller_data method not dependent on session --- misc/freeswitch/scripts/dialplan/dialplan.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 87652d5..1c31968 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -234,19 +234,21 @@ end function Dialplan.retrieve_caller_data(self) - self.caller.caller_phone_numbers_hash = {} - require 'common.str' - local dialed_sip_user = self.caller:to_s('dialed_user'); + self.caller.caller_phone_numbers_hash = {} -- TODO: Set auth_account on transfer initiated by calling party - if not common.str.blank(dialed_sip_user) then - self.caller.auth_account = self:object_find('sipaccount', self.caller:to_s('dialed_domain'), dialed_sip_user); - self.caller:set_auth_account(self.caller.auth_account); + if not common.str.blank(self.caller.dialed_sip_user) then + self.caller.auth_account = self:object_find('sipaccount', self.caller.dialed_domain, dialed_sip_user); + if self.caller.set_auth_account then + self.caller:set_auth_account(self.caller.auth_account); + end elseif not common.str.blank(self.caller.auth_account_type) and not common.str.blank(self.caller.auth_account_uuid) then self.caller.auth_account = self:object_find(self.caller.auth_account_type, self.caller.auth_account_uuid); - self.caller:set_auth_account(self.caller.auth_account); + if self.caller.set_auth_account then + self.caller:set_auth_account(self.caller.auth_account); + end end if self.caller.auth_account then @@ -275,7 +277,7 @@ function Dialplan.retrieve_caller_data(self) self.log:error('CALLER_DATA - caller owner not found'); end - if not self.caller.clir then + if not self.caller.clir and self.caller.set_caller_id then self.caller:set_caller_id(self.caller.caller_phone_numbers[1], self.caller.account.record.caller_name or self.caller.account.record.name); end else -- cgit v1.2.3 From 1de349a41e84981171a197546e01eab2f1d2c09e Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 14:21:03 +0100 Subject: ini dependance removed --- misc/freeswitch/scripts/send_fax.lua | 52 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/misc/freeswitch/scripts/send_fax.lua b/misc/freeswitch/scripts/send_fax.lua index 321a5b1..7099223 100644 --- a/misc/freeswitch/scripts/send_fax.lua +++ b/misc/freeswitch/scripts/send_fax.lua @@ -80,36 +80,38 @@ local session = nil if phone_number then session = freeswitch.Session("[" .. table.concat(origination_variables, ",") .. "]loopback/" .. destination_number .. "/default"); else - local owner_class = common.str.downcase(fax_account.record.fax_accountable_type); - - local caller = {} - caller.caller_phone_numbers = phone_number_class:list_by_owner(fax_account.record.id, 'FaxAccount'); - caller.account = fax_account; - caller.auth_account = fax_account; - caller.caller_id_name = fax_account.record.station_id; - - if owner_class == 'user' then - require 'dialplan.user' - caller.auth_account.owner = dialplan.user.User:new{ log = log, database = database }:find_by_id(fax_account.record.fax_accountable_id); - if caller.auth_account.owner then - caller.auth_account.owner.groups = caller.auth_account.owner:list_groups(); - end - elseif owner_class == 'tenant' then - require 'dialplan.tenant' - caller.auth_account.owner = dialplan.tenant.Tenant:new{ log = log, database = database }:find_by_id(fax_account.record.fax_accountable_id); + -- local owner_class = common.str.downcase(fax_account.record.fax_accountable_type); + + local caller = { + destination_number = destination_number, + caller_id_name = fax_account.record.station_id, + account_type = 'faxaccount', + account_uuid = fax_account.uuid, + auth_account_type = 'faxaccount', + auth_account_uuid = fax_account.uuid, + } + + -- caller.caller_phone_numbers = phone_number_class:list_by_owner(fax_account.record.id, 'FaxAccount'); + + require 'dialplan.dialplan' + local dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = caller, database = database }; + local result = dialplan:retrieve_caller_data(); + + local dialplan_router = require('dialplan.router'); + local routes = dialplan_router.Router:new{ log = log, database = database, caller = caller, variables = caller }:route_run('outbound', destination_number); + + if not routes or #routes == 0 then + log:notice('SWITCH - no route - number: ', destination_number); + return { continue = false, code = 404, phrase = 'No route' } end - require 'common.configuration_file' - local routing_table = common.configuration_file.get('/opt/freeswitch/scripts/ini/routes.ini'); - require 'dialplan.route' - local routes = dialplan.route.Route:new{ log = log, database = database, routing_table = routing_table }:outbound(caller, destination_number); - for index, route in ipairs(routes) do - log:info('FAX_SEND - ', route.class, '=', route.endpoint, ', number: ', route.value); - if route.class == 'gateway' then + log:info('FAX_SEND - ', route.type, '=', route.id, '/', route.gateway,', number: ', route.destination_number); + if route.type == 'gateway' then table.insert(origination_variables, "origination_caller_id_number='" .. (route.caller_id_number or caller.caller_phone_numbers[1]) .. "'"); table.insert(origination_variables, "origination_caller_id_name='" .. (route.caller_id_name or fax_account.record.station_id) .. "'"); - session = freeswitch.Session('[' .. table.concat(origination_variables, ',') .. ']sofia/gateway/' .. route.endpoint .. '/' .. route.value); + session = freeswitch.Session('[' .. table.concat(origination_variables, ',') .. ']sofia/gateway/' .. route.gateway .. '/' .. route.destination_number); + log:notice('SESSION: ', session); break; end end -- cgit v1.2.3 From 13f3c5274a025c6cc02200ea56488770d4a23984 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 14:21:41 +0100 Subject: comments removed --- misc/freeswitch/scripts/send_fax.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/misc/freeswitch/scripts/send_fax.lua b/misc/freeswitch/scripts/send_fax.lua index 7099223..ffb81e2 100644 --- a/misc/freeswitch/scripts/send_fax.lua +++ b/misc/freeswitch/scripts/send_fax.lua @@ -80,8 +80,6 @@ local session = nil if phone_number then session = freeswitch.Session("[" .. table.concat(origination_variables, ",") .. "]loopback/" .. destination_number .. "/default"); else - -- local owner_class = common.str.downcase(fax_account.record.fax_accountable_type); - local caller = { destination_number = destination_number, caller_id_name = fax_account.record.station_id, @@ -90,8 +88,6 @@ else auth_account_type = 'faxaccount', auth_account_uuid = fax_account.uuid, } - - -- caller.caller_phone_numbers = phone_number_class:list_by_owner(fax_account.record.id, 'FaxAccount'); require 'dialplan.dialplan' local dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = caller, database = database }; -- cgit v1.2.3 From 6994ba4b5fecc2d532770f922d76227a175e3d71 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 14:22:24 +0100 Subject: ini removed --- misc/freeswitch/scripts/ini/routes.ini | 80 ---------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 misc/freeswitch/scripts/ini/routes.ini diff --git a/misc/freeswitch/scripts/ini/routes.ini b/misc/freeswitch/scripts/ini/routes.ini deleted file mode 100644 index 33d2f38..0000000 --- a/misc/freeswitch/scripts/ini/routes.ini +++ /dev/null @@ -1,80 +0,0 @@ -; Gemeinschaft 5 routing configuration file -; (c) AMOOMA GmbH 2012 -; - -[general] - - -[prerouting] -^%*0%*$ , f-li -^%*0%*(%d+)#*$ , f-li-%1 -^%*0%*(%d+)%*(%d+)#*$ , f-li-%1-%2 -^#0#$ , f-lo -^%*5%*(%d+)#$ , f-acdmtg-0-%1 -^%*30#$ , f-clipon -^#30#$ , f-clipoff -^%*31#$ , f-cliroff -^#31#$ , f-cliron -^%*31#(%d+)$ , f-dcliroff-%1 -^#31#(%d+)$ , f-dcliron-%1 -^%*43#$ , f-cwaon -^#43#$ , f-cwaoff -^#002#$ , f-cfoff -^##002#$ , f-cfdel -^%*21#$ , f-cfu -^%*21%*(%d+)#$ , f-cfu-%1 -^%*%*21%*(%d+)#$ , f-cfu-%1 -^#21#$ , f-cfuoff -^##21#$ , f-cfudel -^%*61#$ , f-cfn -^%*61%*(%d+)#$ , f-cfn-%1 -^%*%*61%*(%d+)#$ , f-cfn-%1 -^%*61%*(%d+)%*(%d+)#$ , f-cfn-%1-%2 -^%*%*61%*(%d+)%*(%d+)#$ , f-cfn-%1-%2 -^#61#$ , f-cfnoff -^##61#$ , f-cfndel -^%*62#$ , f-cfo -^%*62%*(%d+)#$ , f-cfo-%1 -^%*%*62%*(%d+)#$ , f-cfo-%1 -^#62#$ , f-cfooff -^##62#$ , f-cfodel -^%*67#$ , f-cfb -^%*67%*(%d+)#$ , f-cfb-%1 -^%*%*67%*(%d+)#$ , f-cfb-%1 -^#67#$ , f-cfboff -^##67#$ , f-cfbdel -^%*66#$ , f-redial -^%*98$ , f-vmcheck -^%*98#$ , f-vmcheck -^%*98%*(%d+)#$ , f-vmcheck-%1 -^%*1337%*1%*1#$ , f-loaon -^%*1337%*1%*0#$ , f-loaoff - -^00(%d+)$ , +%1 -^0(%d+)$ , +49%1 - - -[outbound] -^%+(%d+)$ , class=gateway, endpoint=gateway1, group=users, %1 - - -[failover] -UNALLOCATED_NUMBER = true -NORMAL_TEMPORARY_FAILURE = true - - -[outbound_cid_number] - - -[outbound_cid_name] - - -[inbound] -^00(%d+)$ , +%1 -^0(%d+)$ , +49%1 - -[inbound_cid_number] -^00(%d+)$ , +%1 -^0(%d+)$ , +49%1 - -[inbound_cid_name] -- cgit v1.2.3 From c4c3ce49a9f1a229df30c88f0f8a24f06acc4d0f Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 14:27:43 +0100 Subject: dialed_sip_user and dialed_domain fixed --- misc/freeswitch/scripts/dialplan/session.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/session.lua b/misc/freeswitch/scripts/dialplan/session.lua index 6cb670c..7de85ca 100644 --- a/misc/freeswitch/scripts/dialplan/session.lua +++ b/misc/freeswitch/scripts/dialplan/session.lua @@ -43,8 +43,8 @@ function Session.init_channel_variables(self) self.from_gateway = true; end - self.dialed_sip_user = self.caller:to_s('dialed_user'); - self.dialed_domain = self.caller:to_s('dialed_domain'); + self.dialed_sip_user = self:to_s('dialed_user'); + self.dialed_domain = self:to_s('dialed_domain'); self.account_uuid = self:to_s('gs_account_uuid'); self.account_type = self:to_s('gs_account_type'); -- cgit v1.2.3 From e7f51187fe563c559c5580e5091f01356a36b6c3 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 15:09:32 +0100 Subject: load_and_authorize_resource :gs_parameter #114 --- app/controllers/gs_parameters_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index 7ca4e8e..bd8b44b 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -1,5 +1,5 @@ class GsParametersController < ApplicationController - load_resource :gs_parameter + load_and_authorize_resource :gs_parameter before_filter :spread_breadcrumbs -- cgit v1.2.3 From 4f0e8420bd829abef8b04b51d9df800dfd1ce977 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 15:13:16 +0100 Subject: fixed music on hold configuration --- misc/freeswitch/conf/freeswitch.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/freeswitch/conf/freeswitch.xml b/misc/freeswitch/conf/freeswitch.xml index c5dd3f1..3c098fc 100644 --- a/misc/freeswitch/conf/freeswitch.xml +++ b/misc/freeswitch/conf/freeswitch.xml @@ -492,21 +492,21 @@ - - + + - + - + -- cgit v1.2.3 From 8c2ffa8f9308235e151ae8f16393ee10b08b07c1 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 18 Jan 2013 15:14:17 +0100 Subject: moh defaults to moh --- app/models/automatic_call_distributor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/automatic_call_distributor.rb b/app/models/automatic_call_distributor.rb index a34392e..5807757 100644 --- a/app/models/automatic_call_distributor.rb +++ b/app/models/automatic_call_distributor.rb @@ -26,6 +26,6 @@ class AutomaticCallDistributor < ActiveRecord::Base self.announce_call_agents ||= 'ivr/ivr-stay_on_line_call_answered_momentarily.wav' self.greeting ||= 'ivr/ivr-thank_you_for_calling.wav' self.goodbye ||= 'ivr/ivr-thank_you_for_calling.wav' - self.music ||= 'local_stream://mohl' + self.music ||= 'local_stream://moh' end end -- cgit v1.2.3 From 277744c7412c44b54ff46c1d6548c2c4242327e3 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 15:20:20 +0100 Subject: added load_and_authorize_resource :call_route --- app/controllers/call_routes_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 8b8698f..cdb425b 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -1,4 +1,5 @@ class CallRoutesController < ApplicationController + load_and_authorize_resource :call_route before_filter :spread_breadcrumbs def index -- cgit v1.2.3 From 12e91c4932e32808e5a9bf3f454920e7fb1b7d61 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 17:27:15 +0100 Subject: Imports the GS version number from ENV['GS_VERSION']. #98 --- config/initializers/update_gs_version_number.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 config/initializers/update_gs_version_number.rb diff --git a/config/initializers/update_gs_version_number.rb b/config/initializers/update_gs_version_number.rb new file mode 100644 index 0000000..303b1e0 --- /dev/null +++ b/config/initializers/update_gs_version_number.rb @@ -0,0 +1,6 @@ +# The Gemeinschaft version is stored in an environment variable. +# It equals the branch in git. +# +if !ENV['GS_VERSION'].nil? && GsParameter.get('GEMEINSCHAFT_VERSION') != ENV['GS_VERSION'] + GsParameter.where(:name => 'GEMEINSCHAFT_VERSION').first.update_attributes(:name => ENV['GS_VERSION']) +end \ No newline at end of file -- cgit v1.2.3 From 8d1167c53e9edaf6e5a2b3e89dd4fd2a2c872dbb Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 17:55:10 +0100 Subject: Added GsParameter.table_exists? #98 --- config/initializers/update_gs_version_number.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/update_gs_version_number.rb b/config/initializers/update_gs_version_number.rb index 303b1e0..914f007 100644 --- a/config/initializers/update_gs_version_number.rb +++ b/config/initializers/update_gs_version_number.rb @@ -1,6 +1,6 @@ # The Gemeinschaft version is stored in an environment variable. # It equals the branch in git. # -if !ENV['GS_VERSION'].nil? && GsParameter.get('GEMEINSCHAFT_VERSION') != ENV['GS_VERSION'] +if !ENV['GS_VERSION'].nil? && GsParameter.table_exists? && GsParameter.get('GEMEINSCHAFT_VERSION') != ENV['GS_VERSION'] GsParameter.where(:name => 'GEMEINSCHAFT_VERSION').first.update_attributes(:name => ENV['GS_VERSION']) end \ No newline at end of file -- cgit v1.2.3 From 313a6bfb2c5eddca7872bda007b7eae87306e5c6 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 18 Jan 2013 19:06:01 +0100 Subject: Update config/initializers/update_gs_version_number.rb --- config/initializers/update_gs_version_number.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/initializers/update_gs_version_number.rb b/config/initializers/update_gs_version_number.rb index 914f007..972c480 100644 --- a/config/initializers/update_gs_version_number.rb +++ b/config/initializers/update_gs_version_number.rb @@ -2,5 +2,7 @@ # It equals the branch in git. # if !ENV['GS_VERSION'].nil? && GsParameter.table_exists? && GsParameter.get('GEMEINSCHAFT_VERSION') != ENV['GS_VERSION'] - GsParameter.where(:name => 'GEMEINSCHAFT_VERSION').first.update_attributes(:name => ENV['GS_VERSION']) -end \ No newline at end of file + if GsParameter.where(:name => 'GEMEINSCHAFT_VERSION').any? + GsParameter.where(:name => 'GEMEINSCHAFT_VERSION').first.update_attributes(:name => ENV['GS_VERSION']) + end +end -- cgit v1.2.3 From edb3c4d6eeb603a84403bf81e695330a8ea9c603 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 19 Jan 2013 08:37:14 +0100 Subject: Bugfix --- config/initializers/update_gs_version_number.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/initializers/update_gs_version_number.rb b/config/initializers/update_gs_version_number.rb index 972c480..4770858 100644 --- a/config/initializers/update_gs_version_number.rb +++ b/config/initializers/update_gs_version_number.rb @@ -2,7 +2,8 @@ # It equals the branch in git. # if !ENV['GS_VERSION'].nil? && GsParameter.table_exists? && GsParameter.get('GEMEINSCHAFT_VERSION') != ENV['GS_VERSION'] - if GsParameter.where(:name => 'GEMEINSCHAFT_VERSION').any? - GsParameter.where(:name => 'GEMEINSCHAFT_VERSION').first.update_attributes(:name => ENV['GS_VERSION']) - end + version = GsParameter.find_or_create_by_name('GEMEINSCHAFT_VERSION') + version.section = 'Generic' + version.value = ENV['GS_VERSION'] + version.save end -- cgit v1.2.3 From 68df952403f7ce468c1e7f928171d880cd59ede0 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 19 Jan 2013 08:39:34 +0100 Subject: Added public/gemeinschaft_setups/ to .gitignore. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 65a18ad..4d70e4a 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,6 @@ tmp/**/* # Freeswitch /misc/freeswitch/conf/freeswitch.serial /misc/freeswitch/scripts/ini/gateway_gateway1.ini + +# Cache +/public/gemeinschaft_setups/* -- cgit v1.2.3 From a4c2b5b00c074d8861ef313f672032611d662fff Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 19 Jan 2013 08:53:02 +0100 Subject: Refactoring. --- app/views/tenants/_admin_area.de.html.haml | 15 ++------------- app/views/tenants/_admin_area.html.haml | 15 ++------------- app/views/tenants/_table_of_phone_books.html.haml | 1 + app/views/tenants/_user_groups_table.de.html.haml | 4 ++++ app/views/tenants/_users_table.de.html.haml | 7 +++++++ 5 files changed, 16 insertions(+), 26 deletions(-) create mode 100644 app/views/tenants/_user_groups_table.de.html.haml create mode 100644 app/views/tenants/_users_table.de.html.haml diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 268c8e7..fed7d4f 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -1,23 +1,12 @@ -%h2 Admin Bereich = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} -%h2= t("users.index.page_title") -- if @tenant.users.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') - = render "users/index_core", :users => @tenant.users - = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => User} -- else - %p - = link_to "Liste aller User.", tenant_users_path(@tenant) += render :partial => 'users_table', :locals => {:tenant => @tenant} -- if @tenant.user_groups.any? - %h2= t("user_groups.index.page_title") - = render "user_groups/index_core", :user_groups => @tenant.user_groups - = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => UserGroup} += render :partial => 'user_groups_table', :locals => {:tenant => @tenant} %h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} -%h2=t("phone_books.index.page_title") = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} %h2 Gemeinschaft Konfiguration diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index e708215..50ed372 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -1,23 +1,12 @@ -%h2 Admin Area = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} -%h2= t("users.index.page_title") -- if @tenant.users.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') - = render "users/index_core", :users => @tenant.users - = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => User} -- else - %p - = link_to "Liste aller User.", tenant_users_path(@tenant) += render :partial => 'users_table', :locals => {:tenant => @tenant} -- if @tenant.user_groups.any? - %h2= t("user_groups.index.page_title") - = render "user_groups/index_core", :user_groups => @tenant.user_groups - = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => UserGroup} += render :partial => 'user_groups_table', :locals => {:tenant => @tenant} %h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} -%h2=t("phone_books.index.page_title") = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} %h2 Gemeinschaft Configuration diff --git a/app/views/tenants/_table_of_phone_books.html.haml b/app/views/tenants/_table_of_phone_books.html.haml index 6baca58..9d9b97c 100644 --- a/app/views/tenants/_table_of_phone_books.html.haml +++ b/app/views/tenants/_table_of_phone_books.html.haml @@ -1,4 +1,5 @@ - cache(['user_show_phone_books', I18n.locale, tenant, tenant.phone_books]) do + %h2=t("phone_books.index.page_title") -# Phone books -# - if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) diff --git a/app/views/tenants/_user_groups_table.de.html.haml b/app/views/tenants/_user_groups_table.de.html.haml new file mode 100644 index 0000000..61b3e3d --- /dev/null +++ b/app/views/tenants/_user_groups_table.de.html.haml @@ -0,0 +1,4 @@ +- if @tenant.user_groups.any? + %h2= t("user_groups.index.page_title") + = render "user_groups/index_core", :user_groups => tenant.user_groups + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => UserGroup} diff --git a/app/views/tenants/_users_table.de.html.haml b/app/views/tenants/_users_table.de.html.haml new file mode 100644 index 0000000..850ea5e --- /dev/null +++ b/app/views/tenants/_users_table.de.html.haml @@ -0,0 +1,7 @@ +%h2= t("users.index.page_title") +- if @tenant.users.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "users/index_core", :users => tenant.users + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => User} +- else + %p + = link_to "Liste aller User.", tenant_users_path(tenant) \ No newline at end of file -- cgit v1.2.3 From b4abd87252db53e3d79a9601cf9c581f61827f10 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 19 Jan 2013 09:05:50 +0100 Subject: Added call_routes to tenant#show --- app/models/route_element.rb | 2 +- app/views/tenants/_admin_area.de.html.haml | 4 +++- app/views/tenants/_call_routes.html.haml | 8 ++++++++ config/locales/views/call_routes/de.yml | 28 ++++++++++++++-------------- 4 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 app/views/tenants/_call_routes.html.haml diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 87b26ef..324a26d 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -13,7 +13,7 @@ class RouteElement < ActiveRecord::Base def to_s - "#{var_in} #{var_out}" + "#{pattern} => #{var_in} #{var_out}" end end diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index fed7d4f..ba64e9a 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -25,4 +25,6 @@ =link_to manufacturer, manufacturer_path(manufacturer) - else = succeed '.' do - =link_to manufacturer, manufacturer_path(manufacturer) \ No newline at end of file + =link_to manufacturer, manufacturer_path(manufacturer) + += render :partial => 'call_routes', :locals => {:tenant => @tenant} \ No newline at end of file diff --git a/app/views/tenants/_call_routes.html.haml b/app/views/tenants/_call_routes.html.haml new file mode 100644 index 0000000..ade24c9 --- /dev/null +++ b/app/views/tenants/_call_routes.html.haml @@ -0,0 +1,8 @@ +%h2= t("call_routes.index.page_title") + +- if CallRoute.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "call_routes/index_core", :call_routes => CallRoute.call + = render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} +- else + %p + = link_to t("call_routes.index.page_title"), call_routes_path \ No newline at end of file diff --git a/config/locales/views/call_routes/de.yml b/config/locales/views/call_routes/de.yml index 34af575..71ad51a 100644 --- a/config/locales/views/call_routes/de.yml +++ b/config/locales/views/call_routes/de.yml @@ -1,27 +1,27 @@ de: call_routes: - name: 'Call route' + name: 'Call Route' controller: - successfuly_created: 'Call route wurde angelegt.' - successfuly_updated: 'Call route wurde aktualisiert.' - successfuly_destroyed: 'Call route wurde gelöscht.' + successfuly_created: 'Call Route wurde angelegt.' + successfuly_updated: 'Call Route wurde aktualisiert.' + successfuly_destroyed: 'Call Route wurde gelöscht.' index: - page_title: 'Übersicht von Call route' - table: 'Table' + page_title: 'Liste aller Call Routen' + routing_table: 'Routing Table' name: 'Name' endpoint_type: 'Endpoint type' endpoint_id: 'Endpoint' position: 'Position' actions: - confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Call route' + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Call Route' destroy: 'Löschen' edit: 'Bearbeiten' show: 'Anzeigen' create: 'Neu anlegen' - create_for: 'Call route neu anlegen für %{resource}' + create_for: 'Call Route neu anlegen für %{resource}' show: - page_title: 'Call route bearbeiten' - table: 'Table' + page_title: 'Call Route bearbeiten' + routing_table: 'Routing Table' name: 'Name' endpoint_type: 'Endpoint type' endpoint_id: 'Endpoint' @@ -32,18 +32,18 @@ de: edit: 'Bearbeiten' view_all: 'Alle anzeigen' new: - page_title: 'Call route neu anlegen' + page_title: 'Call Route neu anlegen' actions: back_to_list: 'Zurück zur Übersicht' edit: - page_title: 'Call route bearbeiten' + page_title: 'Call Route bearbeiten' actions: back_to_list: 'Zurück zur Übersicht' edit: 'Bearbeiten' view_all: 'Alle anzeigen' form: - table: - label: 'Table' + routing_table: + label: 'Routing Table' hint: '' name: label: 'Name' -- cgit v1.2.3 From bb7992ac94e763c80fc7f4b5d850a19d88f5bf3b Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:07:43 +0100 Subject: allow arrows if no parent defined --- app/views/shared/_index_view_edit_destroy_part.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_index_view_edit_destroy_part.html.haml b/app/views/shared/_index_view_edit_destroy_part.html.haml index 06ec904..ff5a988 100644 --- a/app/views/shared/_index_view_edit_destroy_part.html.haml +++ b/app/views/shared/_index_view_edit_destroy_part.html.haml @@ -26,4 +26,10 @@ = link_to t("#{child.class.name.underscore.pluralize}.index.actions.edit"), method( :"edit_#{child.class.name.underscore}_path" ).(child) %td{ :style => style } - if can? :destroy, child - = link_to t("#{child.class.name.underscore.pluralize}.index.actions.destroy"), method( :"#{child.class.name.underscore}_path" ).(child), :method => :delete \ No newline at end of file + = link_to t("#{child.class.name.underscore.pluralize}.index.actions.destroy"), method( :"#{child.class.name.underscore}_path" ).(child), :method => :delete + - if child.respond_to?(:move_up?) or child and child.respond_to?(:move_down?) + %td{ :style => style } + - if can? :move_down, child and child.respond_to?(:move_down?) and child.move_down? + = link_to '⇩'.html_safe, method( :"move_lower_#{child.class.name.underscore}_path" ).(child), :method => :put + - if can? :move_up, child and child.respond_to?(:move_up?) and child.move_up? + = link_to '⇧'.html_safe, method( :"move_higher_#{child.class.name.underscore}_path" ).(child), :method => :put -- cgit v1.2.3 From c1cdcc3927a8632157017cf15801d2a508eed2ad Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:08:36 +0100 Subject: move methods added --- app/models/call_route.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 5d90901..1fe61e9 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -18,4 +18,12 @@ class CallRoute < ActiveRecord::Base def to_s name.to_s end + + def move_up? + return self.position.to_i > CallRoute.where(:routing_table => self.routing_table ).order(:position).first.position.to_i + end + + def move_down? + return self.position.to_i < CallRoute.where(:routing_table => self.routing_table ).order(:position).last.position.to_i + end end -- cgit v1.2.3 From 6defcadbb9500efbfcf487c384ad41f958f5e46f Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:09:04 +0100 Subject: move actions added --- app/controllers/call_routes_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index cdb425b..5ef7c4b 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -42,6 +42,16 @@ class CallRoutesController < ApplicationController redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed') end + def move_higher + @call_route.move_higher + redirect_to :back + end + + def move_lower + @call_route.move_lower + redirect_to :back + end + private def call_route_parameter_params params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id) -- cgit v1.2.3 From 4c141a6d1c20745addd135d1cdd6844b90a20c33 Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:09:25 +0100 Subject: move actions added --- app/controllers/route_elements_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb index 699fcc6..c4e4c1a 100644 --- a/app/controllers/route_elements_controller.rb +++ b/app/controllers/route_elements_controller.rb @@ -44,6 +44,16 @@ class RouteElementsController < ApplicationController redirect_to call_route_route_elements_path(@call_route), :notice => t('route_elements.controller.successfuly_destroyed') end + def move_higher + @route_element.move_higher + redirect_to :back + end + + def move_lower + @route_element.move_lower + redirect_to :back + end + private def spread_breadcrumbs add_breadcrumb t("call_routes.index.page_title"), call_routes_path -- cgit v1.2.3 From 1e290840497225c50373d0b860036505fa91e13a Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:09:53 +0100 Subject: move routes added --- config/routes.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 249c947..b25081a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,16 @@ Gemeinschaft42c::Application.routes.draw do resources :call_routes do - resources :route_elements + resources :route_elements do + member do + put 'move_higher' + put 'move_lower' + end + end + member do + put 'move_higher' + put 'move_lower' + end end resources :gateways do -- cgit v1.2.3 From bcbfb154a321953fd32696065e6af1bec85f9345 Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 19 Jan 2013 09:17:41 +0100 Subject: move methods added --- app/models/route_element.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 324a26d..94f0f84 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -16,4 +16,11 @@ class RouteElement < ActiveRecord::Base "#{pattern} => #{var_in} #{var_out}" end + def move_up? + #return self.position.to_i > RouteElement.where(:call_route_id => self.call_route_id ).order(:position).first.position.to_i + end + + def move_down? + #return self.position.to_i < RouteElement.where(:call_route_id => self.call_route_id ).order(:position).last.position.to_i + end end -- cgit v1.2.3 From 3a0213af9ae9fab41dd854e94aa668ee2abc6414 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 19 Jan 2013 13:27:41 +0100 Subject: Added sextant to render all routes => http://0.0.0.0:3000/rails/routes --- Gemfile | 1 + Gemfile.lock | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index 375743f..bec37ee 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,7 @@ gem 'jquery-rails' group :development do gem 'factory_girl_rails' gem 'factory_girl' + gem 'sextant' # Rails 4 stuff end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 0beeb3b..3ee9d06 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,6 +147,9 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) + sextant (0.2.3) + activesupport (>= 3.2) + rails (>= 3.2) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) @@ -210,6 +213,7 @@ DEPENDENCIES private_pub rails (= 3.2.11) sass-rails + sextant simple_form (= 2.0.1) sqlite3 state_machine -- cgit v1.2.3 From 79e4b0b95336d568b5f65bcd793995a7d0d4ee50 Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 20 Jan 2013 16:16:36 +0100 Subject: unused variable removed --- misc/freeswitch/scripts/dialplan/dialplan.lua | 8 ++++---- misc/freeswitch/scripts/dialplan/router.lua | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 3fcb2bd..cc222fc 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -625,7 +625,7 @@ function Dialplan.callthrough(self, destination) end require 'dialplan.router' - local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', destination_number, true); + local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', true); if route and route.destination_number then destination_number = route.destination_number; @@ -774,7 +774,7 @@ function Dialplan.switch(self, destination) destination.callee_id_name = nil; require 'dialplan.router' - local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('outbound', destination.number); + local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('outbound'); if not routes or #routes == 0 then self.log:notice('SWITCH - no route - number: ', destination.number); @@ -879,7 +879,7 @@ function Dialplan.run(self, destination) self.caller.destination_number = self.caller:to_s(self.caller.gateway.settings.number_source); end - route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('inbound', self.caller.destination_number, true); + route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('inbound', true); if route then local ignore_keys = { id = true, @@ -899,7 +899,7 @@ function Dialplan.run(self, destination) self.log:notice('INBOUND - no route'); end else - route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', self.caller.destination_number, true); + route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', true); if route then local ignore_keys = { id = true, diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index 5f427ac..7e64d7b 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -162,13 +162,13 @@ function Router.route_match(self, route) end -function Router.route_run(self, table_name, phone_number, find_first) +function Router.route_run(self, table_name, find_first) local routing_table = self:read_table(table_name); local routes = {}; if type(routing_table) == 'table' then for index=1, #routing_table do - local route = self:route_match(routing_table[index], phone_number); + local route = self:route_match(routing_table[index]); if route then table.insert(routes, route); self.log:info('ROUTE ', #routes,' - ', table_name,'=', routing_table[index].id, '/', routing_table[index].name, ', destination: ', route.type, '=', route.id, ', destination_number: ', route.destination_number); -- cgit v1.2.3 From e840f0b4d7bab10b53174b607ed60e1bce450321 Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 20 Jan 2013 16:17:09 +0100 Subject: routing in hunt group class --- misc/freeswitch/scripts/dialplan/hunt_group.lua | 39 ++++++++++++++++++------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/hunt_group.lua b/misc/freeswitch/scripts/dialplan/hunt_group.lua index 44c2bb8..07f403e 100644 --- a/misc/freeswitch/scripts/dialplan/hunt_group.lua +++ b/misc/freeswitch/scripts/dialplan/hunt_group.lua @@ -98,21 +98,35 @@ function HuntGroup.run(self, dialplan_object, caller, destination) self.log:info('HUNTGROUP ', self.record.id, ' - name: ', self.record.name, ', strategy: ', self.record.strategy,', members: ', #hunt_group_members); + local save_destination = caller.destination; + local destinations = {} for index, hunt_group_member in ipairs(hunt_group_members) do local destination = dialplan_object:destination_new{ number = hunt_group_member.number }; if destination.type == 'unknown' then - require 'dialplan.route' - local routes = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = dialplan_object.routes }:outbound(caller, destination.number); - if routes and #routes > 0 then - destination.callee_id_number = destination.number; - destination.callee_id_name = nil; - local route = routes[1]; - destination.gateway = route.endpoint; - destination.type = route.class; - destination.number = route.value; - destination.caller_id_number = route.caller_id_number; - destination.caller_id_name = route.caller_id_name; + self.log:notice('HG_DESTINATION - number: ', destination.number, ', hunt_group_member.number: ', hunt_group_member.number); + + + caller.destination_number = destination.number; + + require 'dialplan.router' + local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = caller, variables = caller }:route_run('outbound', true); + + if route then + destination = dialplan_object:destination_new{ ['type'] = route.type, id = route.id, number = route.destination_number } + + local ignore_keys = { + id = true, + ['type'] = true, + channel_variables = true, + }; + + for key, value in pairs(route) do + if not ignore_keys[key] then + destination[key] = value; + end + end + table.insert(destinations, destination); end else @@ -120,6 +134,9 @@ function HuntGroup.run(self, dialplan_object, caller, destination) end end + caller.destination = save_destination; + caller.destination_number = save_destination.number; + local forwarding_destination = nil; if caller.forwarding_service == 'assistant' and caller.auth_account then forwarding_destination = dialplan_object:destination_new{ type = caller.auth_account.class, id = caller.auth_account.id, number = forwarding_number } -- cgit v1.2.3 From cc16ae7cc59189468854c455bde43a2609350964 Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 20 Jan 2013 16:18:19 +0100 Subject: unused variable removed --- misc/freeswitch/scripts/send_fax.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/send_fax.lua b/misc/freeswitch/scripts/send_fax.lua index 35460a3..11cd1d7 100644 --- a/misc/freeswitch/scripts/send_fax.lua +++ b/misc/freeswitch/scripts/send_fax.lua @@ -94,7 +94,7 @@ else local result = dialplan:retrieve_caller_data(); local dialplan_router = require('dialplan.router'); - local routes = dialplan_router.Router:new{ log = log, database = database, caller = caller, variables = caller }:route_run('outbound', destination_number); + local routes = dialplan_router.Router:new{ log = log, database = database, caller = caller, variables = caller }:route_run('outbound'); if not routes or #routes == 0 then log:notice('SWITCH - no route - number: ', destination_number); -- cgit v1.2.3 From 6e269043f470b597dcc256170c9167e164e74fec Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 20 Jan 2013 16:21:41 +0100 Subject: deep-sixed old call routing engine --- misc/freeswitch/scripts/common/routing_tables.lua | 66 ------ misc/freeswitch/scripts/dialplan/route.lua | 265 ---------------------- 2 files changed, 331 deletions(-) delete mode 100644 misc/freeswitch/scripts/common/routing_tables.lua delete mode 100644 misc/freeswitch/scripts/dialplan/route.lua diff --git a/misc/freeswitch/scripts/common/routing_tables.lua b/misc/freeswitch/scripts/common/routing_tables.lua deleted file mode 100644 index f28b5c5..0000000 --- a/misc/freeswitch/scripts/common/routing_tables.lua +++ /dev/null @@ -1,66 +0,0 @@ --- Gemeinschaft 5 module: routing table functions --- (c) AMOOMA GmbH 2012-2013 --- - -module(...,package.seeall) - -function expand_variables(line, variables_list) - variables_list = variables_list or {}; - - return (line:gsub('{([%a%d_]+)}', function(captured) - return variables_list[captured] or ''; - end)) -end - - -function match_route(entry, search_str, variables_list) - if not entry or not search_str then - return { error = 'No input values' }; - end - - local result = nil; - local success = nil; - success, result = pcall(string.find, search_str, entry[1]); - - if not success then - return { error = result, line = line } - elseif result then - local route = { - pattern = entry[1], - value = search_str:gsub(entry[1], expand_variables(entry[#entry], variables_list)), - } - - for index = 2, #entry-1 do - local attribute = entry[index]:match('^(.-)%s*='); - if attribute then - route[attribute] = entry[index]:match('=%s*(.-)$'); - end - end - - return route; - end - - return {}; -end - - -function match_caller_id(entry, search_str, variables_list) - if not entry or not search_str then - return { error = 'No input values' }; - end - local result = nil; - local success = nil; - success, result = pcall(string.find, search_str, entry[1]); - if not success then - return { error = result, line = line } - elseif result then - return { - value = search_str:gsub(entry[1], expand_variables(entry[4], variables_list)), - class = entry[2], - endpoint = entry[3], - pattern = entry[1], - } - end - - return {}; -end diff --git a/misc/freeswitch/scripts/dialplan/route.lua b/misc/freeswitch/scripts/dialplan/route.lua deleted file mode 100644 index a12b5f9..0000000 --- a/misc/freeswitch/scripts/dialplan/route.lua +++ /dev/null @@ -1,265 +0,0 @@ --- Gemeinschaft 5 module: routing class --- (c) AMOOMA GmbH 2012-2013 --- - -module(...,package.seeall) - -Route = {} - --- create route object -function Route.new(self, arg) - arg = arg or {} - object = arg.object or {} - setmetatable(object, self); - self.__index = self; - self.log = arg.log; - self.database = arg.database; - self.routing_table = arg.routing_table; - self.expandable = arg.expandable or {}; - return object; -end - --- find matching routes -function Route.prerouting(self, caller, number) - require 'common.routing_tables' - - for index, routing_entry in pairs(self.routing_table.prerouting) do - local route = common.routing_tables.match_route(routing_entry, number); - if route.error then - self.log:error('PREROUTE - error: ', route.error); - elseif route.value then - self.log:info('ROUTE_PREROUTING - called number: ', number, ', value: ', route.value, ', pattern: ', route.pattern); - return route; - end - end -end - --- find matching routes -function Route.outbound(self, caller, number) - local routes = {}; - require 'common.routing_tables' - require 'common.str' - - local ignore_arguments = { - class=true, - endpoint=true, - pattern=true, - value=true, - group=true, - phrase=true, - } - - local clip_no_screening = common.str.try(caller, 'account.record.clip_no_screening'); - local caller_id_numbers = {} - if not common.str.blank(clip_no_screening) then - for index, number in ipairs(common.str.strip_to_a(clip_no_screening, ',')) do - table.insert(caller_id_numbers, number); - end - end - for index, number in ipairs(caller.caller_phone_numbers) do - table.insert(caller_id_numbers, number); - end - self.log:info('CALLER_ID_NUMBER - caller_id_numbers: ', table.concat(caller_id_numbers, ',')); - - for index, routing_entry in pairs(self.routing_table.outbound) do - local route = common.routing_tables.match_route(routing_entry, number); - if route.error then - self.log:error('ROUTE_OUTBOUND - error: ', route.error); - elseif route.value then - local valid_route = true; - - for argument, value in pairs(route) do - if not ignore_arguments[argument] then - local table_value = common.str.downcase(tostring(common.str.try(caller, argument))); - value = common.str.downcase(tostring(value)); - if table_value:match(value) then - self.log:info('ROUTE_OUTBOUND_POSITIVE - ', argument, '=', value, ' ~ ', table_value, ', pattern: ', route.pattern); - else - self.log:info('ROUTE_OUTBOUND_NEGATIVE - ', argument, '=', value, ' !~ ', table_value, ', pattern: ', route.pattern); - valid_route = false; - end - end - end - - if route.group then - if common.str.try(caller.auth_account, 'owner.groups.' .. tostring(route.group)) then - self.log:info('ROUTE_OUTBOUND_POSITIVE - group=', route.group, ', pattern: ', route.pattern); - else - self.log:info('ROUTE_OUTBOUND_NEGATIVE - group=', route.group, ', pattern: ', route.pattern); - valid_route = false; - end - end - - if route.cidn then - if caller.caller_id_number:match(route.cidn) then - self.log:info('ROUTE_OUTBOUND_POSITIVE - cidn=', route.cidn, ' ~ ', caller.caller_id_number,', pattern: ', route.pattern); - else - self.log:info('ROUTE_OUTBOUND_NEGATIVE - cidn=', route.cidn, ' !~ ', caller.caller_id_number, ', pattern: ', route.pattern); - valid_route = false; - end - end - - if valid_route then - if route.class ~= 'hangup' then - route.caller_id_number = self:outbound_cid_number(caller, caller_id_numbers, route.endpoint, route.class); - self.expandable.caller_id_number = route.caller_id_number; - route.caller_id_name = self:outbound_cid_name(caller, route.endpoint, route.class); - end - table.insert(routes, route); - self.log:info('ROUTE_OUTBOUND ', #routes,' - ', route.class, '=', route.endpoint, ', value: ', route.value, ', caller_id_number: ', route.caller_id_number, ', caller_id_name: ', route.caller_id_name); - end - end - end - - return routes; -end - - -function Route.inbound(self, caller, number) - require 'common.routing_tables' - - local ignore_arguments = { - class=true, - endpoint=true, - pattern=true, - value=true, - group=true, - phrase=true, - } - - for index, routing_entry in pairs(self.routing_table.inbound) do - local route = common.routing_tables.match_route(routing_entry, number); - if route.error then - self.log:error('ROUTE_INBOUND - error: ', route.error); - elseif route.value then - local valid_route = true; - - for argument, value in pairs(route) do - if not ignore_arguments[argument] then - local table_value = common.str.downcase(tostring(common.str.try(caller, argument))); - value = common.str.downcase(tostring(value)); - if table_value:match(value) then - self.log:info('ROUTE_INBOUND_POSITIVE - ', argument, '=', value, ' ~ ', table_value, ', pattern: ', route.pattern); - else - self.log:info('ROUTE_INBOUND_NEGATIVE - ', argument, '=', value, ' !~ ', table_value, ', pattern: ', route.pattern); - valid_route = false; - end - end - end - - if route.class and route.endpoint then - if route.class == 'gateway' and caller.gateway_name:match(route.endpoint) then - self.log:info('ROUTE_INBOUND_POSITIVE - ', route.class, '=', route.endpoint, ' ~ ', caller.gateway_name, ', pattern: ', route.pattern); - else - self.log:info('ROUTE_INBOUND_NEGATIVE - ', route.class, '=', route.endpoint, ' !~ ', caller.gateway_name, ', pattern: ', route.pattern); - valid_route = false; - end - end - - if valid_route then - self.log:info('ROUTE_INBOUND - called number: ', number, ', value: ', route.value, ', pattern: ', route.pattern); - return route; - end - end - end -end - --- find caller id -function Route.caller_id(self, caller, cid_entry, search_str, endpoint, class) - local ignore_arguments = { - class=true, - endpoint=true, - pattern=true, - value=true, - group=true, - phrase=true, - } - - local route = common.routing_tables.match_route(cid_entry, search_str, self.expandable); - if route.error then - self.log:error('CALLER_ID - error: ', route.error); - elseif route.value then - local valid_route = true; - - for argument, value in pairs(route) do - if not ignore_arguments[argument] then - local table_value = common.str.downcase(tostring(common.str.try(caller, argument))); - value = common.str.downcase(tostring(value)); - if table_value:match(value) then - self.log:debug('CALLER_ID_POSITIVE - ', argument, '=', value, ' ~ ', table_value, ', pattern: ', route.pattern); - else - self.log:debug('CALLER_ID_NEGATIVE - ', argument, '=', value, ' !~ ', table_value, ', pattern: ', route.pattern); - valid_route = false; - end - end - end - - if route.group then - if common.str.try(caller.auth_account, 'owner.groups.' .. tostring(route.group)) then - self.log:debug('CALLER_ID_POSITIVE - group=', route.group, ', pattern: ', route.pattern); - else - self.log:debug('CALLER_ID_NEGATIVE - group=', route.group, ', pattern: ', route.pattern); - valid_route = false; - end - end - - endpoint = tostring(endpoint); - if route.class and route.endpoint then - if route.class == 'gateway' and endpoint:match(route.endpoint) then - self.log:debug('CALLER_ID_POSITIVE - ', route.class, '=', route.endpoint, ' ~ ', endpoint, ', pattern: ', route.pattern); - else - self.log:debug('CALLER_ID_NEGATIVE - ', route.class, '=', route.endpoint, ' !~ ', endpoint, ', pattern: ', route.pattern); - valid_route = false; - end - end - - if valid_route then - self.log:debug('CALLER_ID ', route.class, '=', route.endpoint, ', value: ', route.value); - return route.value; - end - end - - return nil; -end - --- find matching caller id number -function Route.outbound_cid_number(self, caller, caller_id_numbers, endpoint, class) - for route_index, cid_entry in pairs(self.routing_table.outbound_cid_number) do - for index, number in ipairs(caller_id_numbers) do - local route = self:caller_id(caller, cid_entry, number, endpoint, class); - if route then - return route; - end - end - end -end - --- find matching caller id name -function Route.outbound_cid_name(self, caller, endpoint, class) - for route_index, cid_entry in pairs(self.routing_table.outbound_cid_name) do - local route = self:caller_id(caller, cid_entry, caller.caller_id_name, endpoint, class); - if route then - return route; - end - end -end - --- find matching caller id number -function Route.inbound_cid_number(self, caller, endpoint, class) - for route_index, cid_entry in pairs(self.routing_table.inbound_cid_number) do - local route = self:caller_id(caller, cid_entry, caller.caller_id_number, endpoint, class); - if route then - return route; - end - end -end - --- find matching caller id name -function Route.inbound_cid_name(self, caller, endpoint, class) - for route_index, cid_entry in pairs(self.routing_table.inbound_cid_name) do - local route = self:caller_id(caller, cid_entry, caller.caller_id_name, endpoint, class); - if route then - return route; - end - end -end -- cgit v1.2.3 From 23886159814997bff0afd4ac493657ff9f451500 Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 20 Jan 2013 16:24:18 +0100 Subject: log line --- misc/freeswitch/scripts/dialplan/hunt_group.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/hunt_group.lua b/misc/freeswitch/scripts/dialplan/hunt_group.lua index 07f403e..2c73bf8 100644 --- a/misc/freeswitch/scripts/dialplan/hunt_group.lua +++ b/misc/freeswitch/scripts/dialplan/hunt_group.lua @@ -104,8 +104,6 @@ function HuntGroup.run(self, dialplan_object, caller, destination) for index, hunt_group_member in ipairs(hunt_group_members) do local destination = dialplan_object:destination_new{ number = hunt_group_member.number }; if destination.type == 'unknown' then - self.log:notice('HG_DESTINATION - number: ', destination.number, ', hunt_group_member.number: ', hunt_group_member.number); - caller.destination_number = destination.number; -- cgit v1.2.3 From f0f27ea9b4a1ae9f0d47c2e900da7882fe0bceaa Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 19:11:55 +0100 Subject: added gem 'quiet_assets' --- Gemfile | 1 + Gemfile.lock | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index bec37ee..6fec7e7 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,7 @@ group :development do gem 'factory_girl_rails' gem 'factory_girl' gem 'sextant' # Rails 4 stuff + gem 'quiet_assets' # turns off assets logging end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 3ee9d06..b21a99e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,6 +116,8 @@ GEM polyglot (0.3.3) private_pub (1.0.3) faye + quiet_assets (1.0.1) + railties (~> 3.1) rack (1.4.4) rack-cache (1.2) rack (>= 0.4) @@ -211,6 +213,7 @@ DEPENDENCIES mysql2 nokogiri private_pub + quiet_assets rails (= 3.2.11) sass-rails sextant -- cgit v1.2.3 From 66147369d3f1a96ebd7c20bb89165a116ec1e147 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 19:20:30 +0100 Subject: Use thin to get rid of those annoying "WARN Could not determine content-length of response body." log entries. --- Gemfile | 2 ++ Gemfile.lock | 6 ++++++ config/environments/development.rb | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6fec7e7..2738418 100644 --- a/Gemfile +++ b/Gemfile @@ -73,6 +73,8 @@ gem 'uuid' # Application server gem 'unicorn' +gem 'thin' + # Local Variables: # mode: ruby # End: diff --git a/Gemfile.lock b/Gemfile.lock index b21a99e..79c6339 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,7 @@ GEM compass-rails (1.0.3) compass (>= 0.12.2, < 0.14) cookiejar (0.3.0) + daemons (1.1.9) dalli (2.6.0) delayed_job (3.0.4) activesupport (~> 3.0) @@ -168,6 +169,10 @@ GEM railties (~> 3.0) subexec (0.2.2) systemu (2.5.2) + thin (1.5.0) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) thor (0.16.0) tilt (1.3.3) treetop (1.4.12) @@ -221,6 +226,7 @@ DEPENDENCIES sqlite3 state_machine strong_parameters + thin uglifier (>= 1.3.0) unicorn uuid diff --git a/config/environments/development.rb b/config/environments/development.rb index 5076f48..1a3acae 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,7 +40,7 @@ Gemeinschaft42c::Application.configure do # Enable Hirb: extend Hirb::Console - Hirb::View.enable + Hirb::View.enable end -- cgit v1.2.3 From 525e7ad4cac6fff7bd0370828b06159d610573ef Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 19:45:36 +0100 Subject: Added caching. --- app/views/call_routes/_index_core.html.haml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml index aa22437..124f4d0 100644 --- a/app/views/call_routes/_index_core.html.haml +++ b/app/views/call_routes/_index_core.html.haml @@ -1,13 +1,15 @@ -%table - %tr - %th= t('call_routes.index.name') - %th= t('call_routes.index.endpoint_type') - %th= t('call_routes.index.endpoint_id') +- cache(['call_routes_table', call_routes.count, call_routes.reorder(:updated_at).last]) do + %table + %tr + %th= t('call_routes.index.name') + %th= t('call_routes.index.endpoint_type') + %th= t('call_routes.index.endpoint_id') - - reset_cycle - - for call_route in call_routes - %tr{:class => cycle('odd', 'even')} - %td= call_route.name - %td= call_route.endpoint_type - %td= call_route.endpoint_id - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route} \ No newline at end of file + - reset_cycle + - for call_route in call_routes + %tr{:class => cycle('odd', 'even')} + - cache(['call_route_single_table_row', call_route]) do + %td= call_route.name + %td= call_route.endpoint_type + %td= call_route.endpoint_id + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => call_route} \ No newline at end of file -- cgit v1.2.3 From 93a839b41f7172eecd1aeb497ccec6c73d2c4c1e Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 19:46:13 +0100 Subject: Better cache key. --- app/views/call_routes/_index_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml index 124f4d0..32877b2 100644 --- a/app/views/call_routes/_index_core.html.haml +++ b/app/views/call_routes/_index_core.html.haml @@ -8,7 +8,7 @@ - reset_cycle - for call_route in call_routes %tr{:class => cycle('odd', 'even')} - - cache(['call_route_single_table_row', call_route]) do + - cache(['call_route_single_table_row_within_tr', call_route]) do %td= call_route.name %td= call_route.endpoint_type %td= call_route.endpoint_id -- cgit v1.2.3 From 5b5cbfddd9fa3a26de90ca8aa42668eb95648605 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 19:48:19 +0100 Subject: Small logic fix. --- app/views/call_routes/_index_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml index 32877b2..12e89ee 100644 --- a/app/views/call_routes/_index_core.html.haml +++ b/app/views/call_routes/_index_core.html.haml @@ -8,7 +8,7 @@ - reset_cycle - for call_route in call_routes %tr{:class => cycle('odd', 'even')} - - cache(['call_route_single_table_row_within_tr', call_route]) do + - cache(['call_route_single_table_row_within_tr', call_route, call_routes.count]) do %td= call_route.name %td= call_route.endpoint_type %td= call_route.endpoint_id -- cgit v1.2.3 From 4ea0e252683d89794deff7b1b3689d2cdf61e0d0 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 19:54:11 +0100 Subject: Added a gateways table to tenant#view. --- app/views/gateways/show.html.haml | 2 +- app/views/tenants/_admin_area.de.html.haml | 4 +++- app/views/tenants/_admin_area.html.haml | 4 +++- app/views/tenants/_call_routes.html.haml | 2 +- app/views/tenants/_gateways.html.haml | 8 ++++++++ config/locales/views/gateways/de.yml | 8 ++++---- 6 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 app/views/tenants/_gateways.html.haml diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml index a9b0d18..9d0ee53 100644 --- a/app/views/gateways/show.html.haml +++ b/app/views/gateways/show.html.haml @@ -28,8 +28,8 @@ %br = render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewaySetting } +%h3= t('gateway_parameters.index.page_title') - if @gateway.gateway_parameters.any? - %h3= t('gateway_parameters.index.page_title') = render "gateway_parameters/index_core", :gateway_parameters => @gateway.gateway_parameters %br = render :partial => 'shared/create_link', :locals => { :parent => @gateway, :child_class => GatewayParameter } diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index ba64e9a..6a4bef9 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -27,4 +27,6 @@ = succeed '.' do =link_to manufacturer, manufacturer_path(manufacturer) -= render :partial => 'call_routes', :locals => {:tenant => @tenant} \ No newline at end of file += render :partial => 'call_routes', :locals => {:tenant => @tenant} + += render :partial => 'gateways', :locals => {:tenant => @tenant} \ No newline at end of file diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index 50ed372..b974c02 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -25,4 +25,6 @@ =link_to manufacturer, manufacturer_path(manufacturer) - else = succeed '.' do - =link_to manufacturer, manufacturer_path(manufacturer) \ No newline at end of file + =link_to manufacturer, manufacturer_path(manufacturer) + += render :partial => 'call_routes', :locals => {:tenant => @tenant} \ No newline at end of file diff --git a/app/views/tenants/_call_routes.html.haml b/app/views/tenants/_call_routes.html.haml index ade24c9..41066ae 100644 --- a/app/views/tenants/_call_routes.html.haml +++ b/app/views/tenants/_call_routes.html.haml @@ -1,7 +1,7 @@ %h2= t("call_routes.index.page_title") - if CallRoute.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') - = render "call_routes/index_core", :call_routes => CallRoute.call + = render "call_routes/index_core", :call_routes => CallRoute.all = render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} - else %p diff --git a/app/views/tenants/_gateways.html.haml b/app/views/tenants/_gateways.html.haml new file mode 100644 index 0000000..c861ad3 --- /dev/null +++ b/app/views/tenants/_gateways.html.haml @@ -0,0 +1,8 @@ +%h2= t("gateways.index.page_title") + +- if Gateway.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "gateways/index_core", :gateways => Gateway.all + = render :partial => 'shared/create_link', :locals => {:child_class => Gateway} +- else + %p + = link_to t("gateways.index.page_title"), gateways_path \ No newline at end of file diff --git a/config/locales/views/gateways/de.yml b/config/locales/views/gateways/de.yml index 28bc46c..befe6b6 100644 --- a/config/locales/views/gateways/de.yml +++ b/config/locales/views/gateways/de.yml @@ -6,9 +6,9 @@ de: successfuly_updated: 'Gateway wurde aktualisiert.' successfuly_destroyed: 'Gateway wurde gelöscht.' index: - page_title: 'Übersicht von Gateway' + page_title: 'Liste aller Gateways' name: 'Name' - technology: 'Technology' + technology: 'Technologie' inbound: 'Inbound' outbound: 'Outbound' description: 'Description' @@ -23,7 +23,7 @@ de: page_title: 'Gateway' id: 'ID' name: 'Name' - technology: 'Technology' + technology: 'Technologie' inbound: 'Inbound' outbound: 'Outbound' description: 'Description' @@ -47,7 +47,7 @@ de: label: 'Name' hint: '' technology: - label: 'Technology' + label: 'Technologie' hint: '' inbound: label: 'Inbound' -- cgit v1.2.3 From fe5b9f2c046561f9918a5660b4a5193ef66fd3aa Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 20:01:06 +0100 Subject: Replaced some order with reorder within cache key generation. --- app/views/gs_parameters/index.html.haml | 2 +- app/views/tenants/_gs_parameter_table.html.haml | 6 +++--- app/views/tenants/_table_of_functions.html.haml | 10 +++++----- app/views/users/_index_core.html.haml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/gs_parameters/index.html.haml b/app/views/gs_parameters/index.html.haml index 37fe825..3844c3d 100644 --- a/app/views/gs_parameters/index.html.haml +++ b/app/views/gs_parameters/index.html.haml @@ -1,7 +1,7 @@ - title t("gs_parameters.index.page_title") - if @gs_parameters && @gs_parameters.count > 0 - - cache(['gs_parameters_table', I18n.locale, @gs_parameters_unordered.order(:updated_at).last, @gs_parameters_unordered.count]) do + - cache(['gs_parameters_table', I18n.locale, @gs_parameters_unordered.reorder(:updated_at).last, @gs_parameters_unordered.count]) do - if @sections %table - @sections.each do |section| diff --git a/app/views/tenants/_gs_parameter_table.html.haml b/app/views/tenants/_gs_parameter_table.html.haml index 3af06cf..94c44e5 100644 --- a/app/views/tenants/_gs_parameter_table.html.haml +++ b/app/views/tenants/_gs_parameter_table.html.haml @@ -1,4 +1,4 @@ -- cache(['gs_parameters_tenant_overview_table', I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do +- cache(['gs_parameters_tenant_overview_table', I18n.locale, tenant, GuiFunction.count, GuiFunction.reorder(:updated_at).last, GsParameter.count, GsParameter.reorder(:updated_at).last]) do %table %tr{:class => 'even'} %th @@ -14,11 +14,11 @@ %td = link_to GuiFunction.count.to_s, gui_functions_path %td - = l GuiFunction.order(:updated_at).last.updated_at, :format => :short + = l GuiFunction.reorder(:updated_at).last.updated_at, :format => :short %tr{:class => 'even'} %td = t("gs_parameters.name") %td = link_to GsParameter.count.to_s, gs_parameters_path %td - = l GsParameter.order(:updated_at).last.updated_at, :format => :short + = l GsParameter.reorder(:updated_at).last.updated_at, :format => :short diff --git a/app/views/tenants/_table_of_functions.html.haml b/app/views/tenants/_table_of_functions.html.haml index 75b2332..957687b 100644 --- a/app/views/tenants/_table_of_functions.html.haml +++ b/app/views/tenants/_table_of_functions.html.haml @@ -1,4 +1,4 @@ -- cache(['table_of_pbx_features', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last, tenant.conferences.count, tenant.conferences.order(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do +- cache(['table_of_pbx_features', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.reorder(:updated_at).last, tenant.conferences.count, tenant.conferences.reorder(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.reorder(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.reorder(:updated_at).last]) do %table %tr{:class => 'even'} %th @@ -6,7 +6,7 @@ %th Anzahl %th - - cache(['table_of_pbx_features_callthroughs_row', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last]) do + - cache(['table_of_pbx_features_callthroughs_row', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.reorder(:updated_at).last]) do %tr{:class => 'odd'} %td = t("callthroughs.name") @@ -17,7 +17,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Callthrough} - - cache(['table_of_pbx_features_conferences_row', I18n.locale, tenant, tenant.conferences.count, tenant.conferences.order(:updated_at).last]) do + - cache(['table_of_pbx_features_conferences_row', I18n.locale, tenant, tenant.conferences.count, tenant.conferences.reorder(:updated_at).last]) do %tr{:class => 'even'} %td = t("conferences.name") @@ -28,7 +28,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Conference} - - cache(['table_of_pbx_features_hunt_groups_row', I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last]) do + - cache(['table_of_pbx_features_hunt_groups_row', I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.reorder(:updated_at).last]) do %tr{:class => 'odd'} %td = t("hunt_groups.name") @@ -39,7 +39,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => HuntGroup} - - cache(['table_of_pbx_features_automatic_call_distributors_row', I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do + - cache(['table_of_pbx_features_automatic_call_distributors_row', I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.reorder(:updated_at).last]) do %tr{:class => 'even'} %td = t("automatic_call_distributors.name") diff --git a/app/views/users/_index_core.html.haml b/app/views/users/_index_core.html.haml index 9376826..5f0cb41 100644 --- a/app/views/users/_index_core.html.haml +++ b/app/views/users/_index_core.html.haml @@ -1,4 +1,4 @@ -- cache(['user_table_row_inner_td', I18n.locale, current_user, users.order(:updated_at).last, users.count, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do +- cache(['user_table_row_inner_td', I18n.locale, current_user, users.reorder(:updated_at).last, users.count, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do %table %tr %th -- cgit v1.2.3 From a2abe7dffb8fe31687910ca4be6dc0374a247d00 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 20:07:28 +0100 Subject: Fixed some strange cancan problem. #119 --- app/controllers/call_routes_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 5ef7c4b..0f4a02d 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -1,5 +1,5 @@ class CallRoutesController < ApplicationController - load_and_authorize_resource :call_route + authorize_resource :call_route before_filter :spread_breadcrumbs def index @@ -25,6 +25,7 @@ class CallRoutesController < ApplicationController end def edit + @call_route = CallRoute.find(params[:id]) end def update -- cgit v1.2.3 From 4e67f8769a3a3199bfb5b363fe9baa231c329a2b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 20:57:35 +0100 Subject: Refactoring --- app/controllers/tenants_controller.rb | 19 +++++++++++++++-- app/models/gateway.rb | 7 ++++++ app/models/tenant.rb | 11 ++-------- app/views/gateways/_index_core.html.haml | 34 ++++++++++++++++-------------- app/views/tenants/_admin_area.de.html.haml | 32 ---------------------------- app/views/tenants/_admin_area.html.haml | 24 +++++++++++---------- app/views/tenants/show.html.haml | 4 ++-- 7 files changed, 59 insertions(+), 72 deletions(-) delete mode 100644 app/views/tenants/_admin_area.de.html.haml diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb index 7bb8ecd..cb67e5f 100644 --- a/app/controllers/tenants_controller.rb +++ b/app/controllers/tenants_controller.rb @@ -1,13 +1,17 @@ class TenantsController < ApplicationController - load_and_authorize_resource :tenant + authorize_resource :tenant def index + @tenants = Tenant.scoped end def show + @tenant = Tenant.find(params[:id]) + @gateways = Gateway.order(:updated_at) end def new + @tenant = Tenant.new @tenant.name = generate_a_new_name(@tenant) @tenant.sip_domain = SipDomain.last @tenant.country = GemeinschaftSetup.first.country @@ -18,6 +22,8 @@ class TenantsController < ApplicationController end def create + @tenant = Tenant.new(tenant_params) + if @tenant.save # Become a member of this tenant. # @@ -86,10 +92,12 @@ class TenantsController < ApplicationController end def edit + @tenant = Tenant.find(params[:id]) end def update - if @tenant.update_attributes(params[:tenant]) + @tenant = Tenant.find(params[:id]) + if @tenant.update_attributes(tenant_params) redirect_to @tenant, :notice => t('tenants.controller.successfuly_updated') else render :edit @@ -97,8 +105,15 @@ class TenantsController < ApplicationController end def destroy + @tenant = Tenant.find(params[:id]) @tenant.destroy redirect_to tenants_url, :notice => t('tenants.controller.successfuly_destroyed') end + + private + def tenant_params + params.require(:tenant).permit(:name, :description, :sip_domain_id, :country_id, :language_id, :from_field_pin_change_email, :from_field_voicemail_email +) + end end diff --git a/app/models/gateway.rb b/app/models/gateway.rb index 21dc831..3e791a6 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -14,6 +14,7 @@ class Gateway < ActiveRecord::Base :presence => true, :inclusion => { :in => TECHNOLOGIES } + after_initialize :set_defaults before_validation :downcase_technology def to_s @@ -25,4 +26,10 @@ class Gateway < ActiveRecord::Base self.technology = self.technology.downcase if !self.technology.blank? end + def set_defaults + if TECHNOLOGIES.count == 1 + self.technology = TECHNOLOGIES.first + end + end + end diff --git a/app/models/tenant.rb b/app/models/tenant.rb index c3e2926..419ac3a 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -1,15 +1,8 @@ # encoding: UTF-8 class Tenant < ActiveRecord::Base - attr_accessible :name, :description, :sip_domain_id, :country_id, :language_id, :from_field_pin_change_email, :from_field_voicemail_email - - if GsParameter.get('STRICT_INTERNAL_EXTENSION_HANDLING') == true - attr_accessible :internal_extension_ranges - end - - if GsParameter.get('STRICT_DID_HANDLING') == true - attr_accessible :did_list - end + # https://github.com/rails/strong_parameters + include ActiveModel::ForbiddenAttributesProtection # Associations: # diff --git a/app/views/gateways/_index_core.html.haml b/app/views/gateways/_index_core.html.haml index 21414c3..dd2d1f5 100644 --- a/app/views/gateways/_index_core.html.haml +++ b/app/views/gateways/_index_core.html.haml @@ -1,17 +1,19 @@ -%table - %tr - %th= t('gateways.index.name') - %th= t('gateways.index.technology') - %th= t('gateways.index.inbound') - %th= t('gateways.index.outbound') - %th= t('gateways.index.description') +- cache(['gateways_table', gateways.count, gateways.first, gateways.last]) do + %table + %tr + %th= t('gateways.index.name') + %th= t('gateways.index.technology') + %th= t('gateways.index.inbound') + %th= t('gateways.index.outbound') + %th= t('gateways.index.description') - - reset_cycle - - for gateway in gateways - %tr{:class => cycle('odd', 'even')} - %td= gateway.name - %td= gateway.technology - %td= gateway.inbound - %td= gateway.outbound - %td= gateway.description - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gateway} \ No newline at end of file + - reset_cycle + - for gateway in gateways + %tr{:class => cycle('odd', 'even')} + - cache(['gateway_single_table_row_within_tr', gateway, gateways.count]) do + %td= gateway.name + %td= gateway.technology + %td= gateway.inbound + %td= gateway.outbound + %td= gateway.description + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gateway} \ No newline at end of file diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml deleted file mode 100644 index 6a4bef9..0000000 --- a/app/views/tenants/_admin_area.de.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -= render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} - -= render :partial => 'users_table', :locals => {:tenant => @tenant} - -= render :partial => 'user_groups_table', :locals => {:tenant => @tenant} - -%h2 Features -= render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} - -= render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} - -%h2 Gemeinschaft Konfiguration -= render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} - -%p - Das System kann - = PhoneModel.count - verschiedene Telefonmodelle von den folgenden Herstellern verwalten: - - Manufacturer.all.each do |manufacturer| - - if manufacturer != Manufacturer.last && manufacturer != Manufacturer.limit(Manufacturer.count - 1).last - = succeed ', ' do - =link_to manufacturer, manufacturer_path(manufacturer) - - elsif manufacturer == Manufacturer.limit(Manufacturer.count - 1).last - = succeed ' und ' do - =link_to manufacturer, manufacturer_path(manufacturer) - - else - = succeed '.' do - =link_to manufacturer, manufacturer_path(manufacturer) - -= render :partial => 'call_routes', :locals => {:tenant => @tenant} - -= render :partial => 'gateways', :locals => {:tenant => @tenant} \ No newline at end of file diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index b974c02..7e7e46b 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -1,30 +1,32 @@ -= render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} += render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => tenant} -= render :partial => 'users_table', :locals => {:tenant => @tenant} += render :partial => 'users_table', :locals => {:tenant => tenant} -= render :partial => 'user_groups_table', :locals => {:tenant => @tenant} += render :partial => 'user_groups_table', :locals => {:tenant => tenant} %h2 Features -= render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} += render :partial => 'tenants/table_of_functions', :locals => {:tenant => tenant} -= render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} += render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} -%h2 Gemeinschaft Configuration -= render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} +%h2 Gemeinschaft Konfiguration += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => tenant} %p - This system can setup + Das System kann = PhoneModel.count - different phone models from the manufacturers + verschiedene Telefonmodelle von den folgenden Herstellern verwalten: - Manufacturer.all.each do |manufacturer| - if manufacturer != Manufacturer.last && manufacturer != Manufacturer.limit(Manufacturer.count - 1).last = succeed ', ' do =link_to manufacturer, manufacturer_path(manufacturer) - elsif manufacturer == Manufacturer.limit(Manufacturer.count - 1).last - = succeed ' and ' do + = succeed ' und ' do =link_to manufacturer, manufacturer_path(manufacturer) - else = succeed '.' do =link_to manufacturer, manufacturer_path(manufacturer) -= render :partial => 'call_routes', :locals => {:tenant => @tenant} \ No newline at end of file += render :partial => 'call_routes', :locals => {:tenant => tenant} + += render :partial => 'gateways', :locals => {:tenant => tenant, :gateways => gateways} \ No newline at end of file diff --git a/app/views/tenants/show.html.haml b/app/views/tenants/show.html.haml index f5cff5f..9b9d4ec 100644 --- a/app/views/tenants/show.html.haml +++ b/app/views/tenants/show.html.haml @@ -7,5 +7,5 @@ = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @tenant } -- if @tenant.user_groups.where(:name => 'Admins').count > 0 && @tenant.user_groups.where(:name => 'Admins').first.users.include?(current_user) - = render 'admin_area' \ No newline at end of file +- if @tenant.user_groups.where(:name => 'Admins').any? && @tenant.user_groups.where(:name => 'Admins').first.users.include?(current_user) + = render :partial => 'admin_area', :locals => { :tenant => @tenant, :gateways => @gateways} \ No newline at end of file -- cgit v1.2.3 From fb18fd9bae2d24bef4652b40a4b0d206b77ebb4f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 20 Jan 2013 21:09:10 +0100 Subject: Added breadcrumbs. --- app/controllers/call_routes_controller.rb | 9 +++++++-- app/controllers/gateways_controller.rb | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 0f4a02d..2437d8d 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -1,22 +1,25 @@ class CallRoutesController < ApplicationController authorize_resource :call_route - before_filter :spread_breadcrumbs def index @call_routes = CallRoute.order([:routing_table, :position]) @routing_tables = @call_routes.pluck(:routing_table).uniq.sort + spread_breadcrumbs end def show @call_route = CallRoute.find(params[:id]) + spread_breadcrumbs end def new @call_route = CallRoute.new + spread_breadcrumbs end def create @call_route = CallRoute.new(call_route_parameter_params) + spread_breadcrumbs if @call_route.save redirect_to @call_route, :notice => t('call_routes.controller.successfuly_created') else @@ -26,10 +29,12 @@ class CallRoutesController < ApplicationController def edit @call_route = CallRoute.find(params[:id]) + spread_breadcrumbs end def update @call_route = CallRoute.find(params[:id]) + spread_breadcrumbs if @call_route.update_attributes(call_route_parameter_params) redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated') else @@ -61,7 +66,7 @@ class CallRoutesController < ApplicationController def spread_breadcrumbs add_breadcrumb t("call_routes.index.page_title"), call_routes_path if @call_route && !@call_route.new_record? - add_breadcrumb @call_route, call_route_path(@call_route) + add_breadcrumb @call_route, @call_route end end diff --git a/app/controllers/gateways_controller.rb b/app/controllers/gateways_controller.rb index 6173ca3..5741195 100644 --- a/app/controllers/gateways_controller.rb +++ b/app/controllers/gateways_controller.rb @@ -1,18 +1,24 @@ class GatewaysController < ApplicationController + authorize_resource :gateway + def index @gateways = Gateway.all + spread_breadcrumbs end def show @gateway = Gateway.find(params[:id]) + spread_breadcrumbs end def new @gateway = Gateway.new + spread_breadcrumbs end def create @gateway = Gateway.new(params[:gateway]) + spread_breadcrumbs if @gateway.save redirect_to @gateway, :notice => t('gateways.controller.successfuly_created') else @@ -22,10 +28,12 @@ class GatewaysController < ApplicationController def edit @gateway = Gateway.find(params[:id]) + spread_breadcrumbs end def update @gateway = Gateway.find(params[:id]) + spread_breadcrumbs if @gateway.update_attributes(params[:gateway]) redirect_to @gateway, :notice => t('gateways.controller.successfuly_updated') else @@ -38,4 +46,12 @@ class GatewaysController < ApplicationController @gateway.destroy redirect_to gateways_url, :notice => t('gateways.controller.successfuly_destroyed') end + + private + def spread_breadcrumbs + add_breadcrumb t("gateways.index.page_title"), gateways_path + if @gateway && !@gateway.new_record? + add_breadcrumb @gateway, @gateway + end + end end -- cgit v1.2.3 From a6779c02f83d1873ebc33b1610013dcbadfeb10b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 21 Jan 2013 11:07:54 +0100 Subject: Bug fix #121 --- app/controllers/call_routes_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 2437d8d..0259a10 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -49,11 +49,13 @@ class CallRoutesController < ApplicationController end def move_higher + @call_route = CallRoute.find(params[:id]) @call_route.move_higher redirect_to :back end def move_lower + @call_route = CallRoute.find(params[:id]) @call_route.move_lower redirect_to :back end -- cgit v1.2.3 From f916b83b562edf5a3961fbbba107840c343a53a1 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 21 Jan 2013 13:01:35 +0100 Subject: set caller.destination_number from destination.number --- misc/freeswitch/scripts/dialplan/dialplan.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index cc222fc..b92dc70 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -1004,6 +1004,7 @@ function Dialplan.run(self, destination) self.log:info('LOOP ', loop, ' NEW_DESTINATION_NUMBER - number: ', result.number ); destination = self:destination_new{ number = result.number } self.caller.destination = destination; + self.caller.destination_number = destination.number; end end -- cgit v1.2.3 From f7c8227521a758f769d3bde892b8b7201bf841dc Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 21 Jan 2013 13:02:49 +0100 Subject: factory_defaults_prerouting method added --- app/models/call_route.rb | 212 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 1fe61e9..0bf7816 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -26,4 +26,216 @@ class CallRoute < ActiveRecord::Base def move_down? return self.position.to_i < CallRoute.where(:routing_table => self.routing_table ).order(:position).last.position.to_i end + + def self.factory_defaults_prerouting(country_code, national_prefix = '', international_prefix = '', trunk_prefix = '', area_code = '') + CallRoute.where(:routing_table => "prerouting").destroy_all + + CallRoute.create_prerouting_entry('international call', [ + { :pattern => '^'+trunk_prefix+international_prefix+'([1-9]%d+)$', :replacement => '+%1', }, + ], 'phonenumber') + + CallRoute.create_prerouting_entry('national call', [ + { :pattern => '^'+trunk_prefix+national_prefix+'([1-9]%d+)$', :replacement => '+'+country_code+'%1', }, + ], 'phonenumber') + + if !trunk_prefix.blank? && !area_code.blank? + CallRoute.create_prerouting_entry('local call', [ + { :pattern => '^'+trunk_prefix+'([1-9]%d+)$', :replacement => '+'+country_code+area_code+'%1', }, + ], 'phonenumber') + end + + CallRoute.create_prerouting_entry('log in', [ + { :pattern => '^%*0%*$', :replacement => 'f-li', }, + { :pattern => '^%*0%*(%+?%d+)#*$', :replacement => 'f-li-%1', }, + { :pattern => '^%*0%*(%+?%d+)%*(%d+)#*$', :replacement => 'f-li-%1-%2', }, + ]) + + CallRoute.create_prerouting_entry('log out', [ + { :pattern => '^#0#$', :replacement => 'f-lo', }, + ]) + + CallRoute.create_prerouting_entry('toggle ACD membership', [ + { :pattern => '^%*5%*(%+?%d+)#$', :replacement => 'f-acdmtg-0-%1', }, + ]) + + CallRoute.create_prerouting_entry('activate CLIP', [ + { :pattern => '^%*30#$', :replacement => 'f-clipon', }, + ]) + + CallRoute.create_prerouting_entry('deactivate CLIP', [ + { :pattern => '^#30#$', :replacement => 'f-clipoff', }, + ]) + + CallRoute.create_prerouting_entry('activate CLIR', [ + { :pattern => '^#31#$', :replacement => 'f-cliron', }, + ]) + + CallRoute.create_prerouting_entry('deactivate CLIR', [ + { :pattern => '^%*31#$', :replacement => 'f-cliroff', }, + ]) + + elements = [ + { :pattern => '^#31#(%+?[1-9]%d+)$', :replacement => 'f-dcliron-%1', }, + { :pattern => '^#31#'+trunk_prefix+international_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+%1' }, + { :pattern => '^#31#'+trunk_prefix+national_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+'+country_code+'%1' }, + ] + + if !trunk_prefix.blank? && !area_code.blank? + elements << { :pattern => '^#31#'+trunk_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+'+country_code+area_code+'%1' } + end + + CallRoute.create_prerouting_entry('activate CLIR for call', elements) + + elements = [ + { :pattern => '^%*31#(%+?[1-9]%d+)$', :replacement => 'f-dcliroff-%1', }, + { :pattern => '^%*31#'+trunk_prefix+international_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+%1' }, + { :pattern => '^%*31#'+trunk_prefix+national_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+'+country_code+'%1' }, + ] + + if !trunk_prefix.blank? && !area_code.blank? + elements << { :pattern => '^%*31#'+trunk_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+'+country_code+area_code+'%1' } + end + + CallRoute.create_prerouting_entry('deactivate CLIR for call', elements) + + CallRoute.create_prerouting_entry('activate call waiting', [ + { :pattern => '^%*43#$', :replacement => 'f-cwaon', }, + ]) + + CallRoute.create_prerouting_entry('deactivate call waiting', [ + { :pattern => '^#43#$', :replacement => 'f-cwaoff', }, + ]) + + CallRoute.create_prerouting_entry('deactivate all call forwards', [ + { :pattern => '^#002#$', :replacement => 'f-cfoff', }, + ]) + + CallRoute.create_prerouting_entry('delete all call forwards', [ + { :pattern => '^##002#$', :replacement => 'f-cfdel', }, + ]) + + elements = [ + { :pattern => '^%*21#$', :replacement => 'f-cfu', }, + { :pattern => '^%*%*?21%*(%+?[1-9]%d+)#$', :replacement => 'f-cfu-%1', }, + { :pattern => '^%*%*?21%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+%1', }, + { :pattern => '^%*%*?21%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+'+country_code+'%1', }, + ] + + if !trunk_prefix.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?21%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+'+country_code+area_code+'%1' } + end + + CallRoute.create_prerouting_entry('set unconditional call forwarding', elements) + + CallRoute.create_prerouting_entry('deactivate unconditional call forwarding', [ + { :pattern => '^#21#$', :replacement => 'f-cfuoff', }, + ]) + + CallRoute.create_prerouting_entry('delete unconditional call forwarding', [ + { :pattern => '^##21#$', :replacement => 'f-cfudel', }, + ]) + + elements = [ + { :pattern => '^%*61#$', :replacement => 'f-cfn', }, + { :pattern => '^%*%*?61%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+%1', }, + { :pattern => '^%*%*?61%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+'+country_code+'%1', }, + { :pattern => '^%*%*?61%*(%+?[1-9]%d+)#$', :replacement => 'f-cfn-%1', }, + { :pattern => '^%*%*?61%*'+trunk_prefix+international_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+%1-%2', }, + { :pattern => '^%*%*?61%*'+trunk_prefix+national_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+'+country_code+'%1-%2', }, + { :pattern => '^%*%*?61%*(%+?[1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', }, + ] + + if !trunk_prefix.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?61%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+'+country_code+area_code+'%1' } + elements << { :pattern => '^%*%*?61%*'+trunk_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+'+country_code+area_code+'%1-%2' } + end + + CallRoute.create_prerouting_entry('call forward if not answered', elements) + + CallRoute.create_prerouting_entry('deactivate call forward if not answered', [ + { :pattern => '^#61#$', :replacement => 'f-cfnoff', }, + ]) + + CallRoute.create_prerouting_entry('delete call forward if not answered', [ + { :pattern => '^##61#$', :replacement => 'f-cfndel', }, + ]) + + elements = [ + { :pattern => '^%*62#$', :replacement => 'f-cfo', }, + { :pattern => '^%*%*?62%*(%+?[1-9]%d+)#$', :replacement => 'f-cfo-%1', }, + { :pattern => '^%*%*?62%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+%1', }, + { :pattern => '^%*%*?62%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+'+country_code+'%1', }, + ] + + if !trunk_prefix.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?62%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+'+country_code+area_code+'%1' } + end + + CallRoute.create_prerouting_entry('call forward if offline', elements) + + CallRoute.create_prerouting_entry('deactivate call forward if offline', [ + { :pattern => '^#62#$', :replacement => 'f-cfooff', }, + ]) + + CallRoute.create_prerouting_entry('delete call forward if offline', [ + { :pattern => '^##62#$', :replacement => 'f-cfodel', }, + ]) + + elements = [ + { :pattern => '^%*67#$', :replacement => 'f-cfb', }, + { :pattern => '^%*%*?67%*(%+?[1-9]%d+)#$', :replacement => 'f-cfb-%1', }, + { :pattern => '^%*%*?67%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+%1', }, + { :pattern => '^%*%*?67%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+'+country_code+'%1', }, + ] + + if !trunk_prefix.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?67%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+'+country_code+area_code+'%1' } + end + + CallRoute.create_prerouting_entry('call forward if busy', elements) + + CallRoute.create_prerouting_entry('deactivate call forward if busy', [ + { :pattern => '^#67#$', :replacement => 'f-cfboff', }, + ]) + + CallRoute.create_prerouting_entry('delete call forward if busy', [ + { :pattern => '^##67#$', :replacement => 'f-cfbdel', }, + ]) + + + CallRoute.create_prerouting_entry('redial', [ + { :pattern => '^%*66#$', :replacement => 'f-redial', }, + ]) + + CallRoute.create_prerouting_entry('check voicemail', [ + { :pattern => '^%*98$', :replacement => 'f-vmcheck', }, + { :pattern => '^%*98#$', :replacement => 'f-vmcheck', }, + { :pattern => '^%*98%*(%+?%d+)#$', :replacement => 'f-vmcheck-%1', }, + ]) + + CallRoute.create_prerouting_entry('acivate auto logout', [ + { :pattern => '^%*1337%*1%*1#$', :replacement => 'f-loaon', }, + ]) + + CallRoute.create_prerouting_entry('deacivate auto logout', [ + { :pattern => '^%*1337%*1%*0#$', :replacement => 'f-loaoff', }, + ]) + end + + def self.create_prerouting_entry(name, elements, endpoint_type = 'dialplanfunction') + call_route = CallRoute.create(:routing_table => 'prerouting', :name => name, :endpoint_type => endpoint_type) + + if !call_route.errors.any? then + elements.each do |element| + call_route.route_elements.create( + :var_in => 'destination_number', + :var_out => 'destination_number', + :pattern => element[:pattern], + :replacement => element[:replacement], + :action => 'match', + :mandatory => false + ) + end + end + end end -- cgit v1.2.3 From 86e94e36e52ff7a3dbc7219db5b3bea5a7f56711 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 21 Jan 2013 14:09:38 +0100 Subject: factory_defaults_prerouting --- app/controllers/gemeinschaft_setups_controller.rb | 8 ++++++++ app/models/gemeinschaft_setup.rb | 12 ++++++++++++ app/views/gemeinschaft_setups/new.de.html.haml | 1 + app/views/gemeinschaft_setups/new.html.haml | 1 + config/locales/views/gemeinschaft_setups/de.yml | 3 +++ config/locales/views/gemeinschaft_setups/en.yml | 3 +++ ...0121123742_add_default_area_code_to_gemeinschaft_setup.rb | 5 +++++ db/schema.rb | 7 ++++--- 8 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20130121123742_add_default_area_code_to_gemeinschaft_setup.rb diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 27c0a83..347e043 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -45,6 +45,14 @@ 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 CallRoute defaults + CallRoute.factory_defaults_prerouting(@gemeinschaft_setup.country.country_code, + @gemeinschaft_setup.country.trunk_prefix, + @gemeinschaft_setup.country.international_call_prefix, + '', + @gemeinschaft_setup.default_area_code + ) + # 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}") diff --git a/app/models/gemeinschaft_setup.rb b/app/models/gemeinschaft_setup.rb index 0b3eeae..6056236 100644 --- a/app/models/gemeinschaft_setup.rb +++ b/app/models/gemeinschaft_setup.rb @@ -10,8 +10,20 @@ class GemeinschaftSetup < ActiveRecord::Base # after_create :expire_cache + before_validation :format_default_area_code + private def expire_cache ActionController::Base.expire_page(Rails.application.routes.url_helpers.new_gemeinschaft_setup_path) end + + def format_default_area_code + if self.default_area_code.blank? + self.default_area_code = nil + else + if self.country != nil && !self.country.trunk_prefix.blank? + self.default_area_code.gsub(/^#{self.country.trunk_prefix}/,'') + end + end + end end diff --git a/app/views/gemeinschaft_setups/new.de.html.haml b/app/views/gemeinschaft_setups/new.de.html.haml index 2e148f3..1afa5d4 100644 --- a/app/views/gemeinschaft_setups/new.de.html.haml +++ b/app/views/gemeinschaft_setups/new.de.html.haml @@ -20,6 +20,7 @@ = 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') .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 ab5a70f..da3c60e 100644 --- a/app/views/gemeinschaft_setups/new.html.haml +++ b/app/views/gemeinschaft_setups/new.html.haml @@ -20,6 +20,7 @@ = 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') .actions = f.button :submit, conditional_t('gemeinschaft_setups.form.submit') \ No newline at end of file diff --git a/config/locales/views/gemeinschaft_setups/de.yml b/config/locales/views/gemeinschaft_setups/de.yml index a1dd989..d087583 100644 --- a/config/locales/views/gemeinschaft_setups/de.yml +++ b/config/locales/views/gemeinschaft_setups/de.yml @@ -25,4 +25,7 @@ de: language_id: label: 'Sprache' 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 diff --git a/config/locales/views/gemeinschaft_setups/en.yml b/config/locales/views/gemeinschaft_setups/en.yml index aef2686..5e22e58 100644 --- a/config/locales/views/gemeinschaft_setups/en.yml +++ b/config/locales/views/gemeinschaft_setups/en.yml @@ -25,4 +25,7 @@ en: language_id: label: 'Language' hint: '' + default_area_code: + label: 'Default area code' + hint: '' button: 'Submit' \ No newline at end of file diff --git a/db/migrate/20130121123742_add_default_area_code_to_gemeinschaft_setup.rb b/db/migrate/20130121123742_add_default_area_code_to_gemeinschaft_setup.rb new file mode 100644 index 0000000..63a9fd1 --- /dev/null +++ b/db/migrate/20130121123742_add_default_area_code_to_gemeinschaft_setup.rb @@ -0,0 +1,5 @@ +class AddDefaultAreaCodeToGemeinschaftSetup < ActiveRecord::Migration + def change + add_column :gemeinschaft_setups, :default_area_code, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 31fdaf7..1d91458 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 => 20130117191840) do +ActiveRecord::Schema.define(:version => 20130121123742) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -535,8 +535,9 @@ ActiveRecord::Schema.define(:version => 20130117191840) 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" end create_table "gs_cluster_sync_log_entries", :force => true do |t| -- cgit v1.2.3 From 7159618255c6911075723f6b11ba84b85e9e40cd Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 21 Jan 2013 14:49:11 +0100 Subject: naming --- app/models/call_route.rb | 64 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 0bf7816..28120c1 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -27,20 +27,20 @@ class CallRoute < ActiveRecord::Base return self.position.to_i < CallRoute.where(:routing_table => self.routing_table ).order(:position).last.position.to_i end - def self.factory_defaults_prerouting(country_code, national_prefix = '', international_prefix = '', trunk_prefix = '', area_code = '') + def self.factory_defaults_prerouting(country_code, national_prefix = '', international_prefix = '', trunk_access_code = '', area_code = '') CallRoute.where(:routing_table => "prerouting").destroy_all CallRoute.create_prerouting_entry('international call', [ - { :pattern => '^'+trunk_prefix+international_prefix+'([1-9]%d+)$', :replacement => '+%1', }, + { :pattern => '^'+trunk_access_code+international_prefix+'([1-9]%d+)$', :replacement => '+%1', }, ], 'phonenumber') CallRoute.create_prerouting_entry('national call', [ - { :pattern => '^'+trunk_prefix+national_prefix+'([1-9]%d+)$', :replacement => '+'+country_code+'%1', }, + { :pattern => '^'+trunk_access_code+national_prefix+'([1-9]%d+)$', :replacement => '+'+country_code+'%1', }, ], 'phonenumber') - if !trunk_prefix.blank? && !area_code.blank? + if !trunk_access_code.blank? && !area_code.blank? CallRoute.create_prerouting_entry('local call', [ - { :pattern => '^'+trunk_prefix+'([1-9]%d+)$', :replacement => '+'+country_code+area_code+'%1', }, + { :pattern => '^'+trunk_access_code+'([1-9]%d+)$', :replacement => '+'+country_code+area_code+'%1', }, ], 'phonenumber') end @@ -76,24 +76,24 @@ class CallRoute < ActiveRecord::Base elements = [ { :pattern => '^#31#(%+?[1-9]%d+)$', :replacement => 'f-dcliron-%1', }, - { :pattern => '^#31#'+trunk_prefix+international_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+%1' }, - { :pattern => '^#31#'+trunk_prefix+national_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+'+country_code+'%1' }, + { :pattern => '^#31#'+trunk_access_code+international_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+%1' }, + { :pattern => '^#31#'+trunk_access_code+national_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+'+country_code+'%1' }, ] - if !trunk_prefix.blank? && !area_code.blank? - elements << { :pattern => '^#31#'+trunk_prefix+'([1-9]%d+)$', :replacement => 'f-dcliron-+'+country_code+area_code+'%1' } + if !trunk_access_code.blank? && !area_code.blank? + elements << { :pattern => '^#31#'+trunk_access_code+'([1-9]%d+)$', :replacement => 'f-dcliron-+'+country_code+area_code+'%1' } end CallRoute.create_prerouting_entry('activate CLIR for call', elements) elements = [ { :pattern => '^%*31#(%+?[1-9]%d+)$', :replacement => 'f-dcliroff-%1', }, - { :pattern => '^%*31#'+trunk_prefix+international_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+%1' }, - { :pattern => '^%*31#'+trunk_prefix+national_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+'+country_code+'%1' }, + { :pattern => '^%*31#'+trunk_access_code+international_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+%1' }, + { :pattern => '^%*31#'+trunk_access_code+national_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+'+country_code+'%1' }, ] - if !trunk_prefix.blank? && !area_code.blank? - elements << { :pattern => '^%*31#'+trunk_prefix+'([1-9]%d+)$', :replacement => 'f-dcliroff-+'+country_code+area_code+'%1' } + if !trunk_access_code.blank? && !area_code.blank? + elements << { :pattern => '^%*31#'+trunk_access_code+'([1-9]%d+)$', :replacement => 'f-dcliroff-+'+country_code+area_code+'%1' } end CallRoute.create_prerouting_entry('deactivate CLIR for call', elements) @@ -117,12 +117,12 @@ class CallRoute < ActiveRecord::Base elements = [ { :pattern => '^%*21#$', :replacement => 'f-cfu', }, { :pattern => '^%*%*?21%*(%+?[1-9]%d+)#$', :replacement => 'f-cfu-%1', }, - { :pattern => '^%*%*?21%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+%1', }, - { :pattern => '^%*%*?21%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+'+country_code+'%1', }, + { :pattern => '^%*%*?21%*'+trunk_access_code+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+%1', }, + { :pattern => '^%*%*?21%*'+trunk_access_code+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+'+country_code+'%1', }, ] - if !trunk_prefix.blank? && !area_code.blank? - elements << { :pattern => '^%*%*?21%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfu-+'+country_code+area_code+'%1' } + if !trunk_access_code.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?21%*'+trunk_access_code+'([1-9]%d+)#$', :replacement => 'f-cfu-+'+country_code+area_code+'%1' } end CallRoute.create_prerouting_entry('set unconditional call forwarding', elements) @@ -137,17 +137,17 @@ class CallRoute < ActiveRecord::Base elements = [ { :pattern => '^%*61#$', :replacement => 'f-cfn', }, - { :pattern => '^%*%*?61%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+%1', }, - { :pattern => '^%*%*?61%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+'+country_code+'%1', }, + { :pattern => '^%*%*?61%*'+trunk_access_code+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+%1', }, + { :pattern => '^%*%*?61%*'+trunk_access_code+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+'+country_code+'%1', }, { :pattern => '^%*%*?61%*(%+?[1-9]%d+)#$', :replacement => 'f-cfn-%1', }, - { :pattern => '^%*%*?61%*'+trunk_prefix+international_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+%1-%2', }, - { :pattern => '^%*%*?61%*'+trunk_prefix+national_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+'+country_code+'%1-%2', }, + { :pattern => '^%*%*?61%*'+trunk_access_code+international_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+%1-%2', }, + { :pattern => '^%*%*?61%*'+trunk_access_code+national_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+'+country_code+'%1-%2', }, { :pattern => '^%*%*?61%*(%+?[1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', }, ] - if !trunk_prefix.blank? && !area_code.blank? - elements << { :pattern => '^%*%*?61%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfn-+'+country_code+area_code+'%1' } - elements << { :pattern => '^%*%*?61%*'+trunk_prefix+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+'+country_code+area_code+'%1-%2' } + if !trunk_access_code.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?61%*'+trunk_access_code+'([1-9]%d+)#$', :replacement => 'f-cfn-+'+country_code+area_code+'%1' } + elements << { :pattern => '^%*%*?61%*'+trunk_access_code+'([1-9]%d+)%*(%d+)#$', :replacement => 'f-cfn-+'+country_code+area_code+'%1-%2' } end CallRoute.create_prerouting_entry('call forward if not answered', elements) @@ -163,12 +163,12 @@ class CallRoute < ActiveRecord::Base elements = [ { :pattern => '^%*62#$', :replacement => 'f-cfo', }, { :pattern => '^%*%*?62%*(%+?[1-9]%d+)#$', :replacement => 'f-cfo-%1', }, - { :pattern => '^%*%*?62%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+%1', }, - { :pattern => '^%*%*?62%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+'+country_code+'%1', }, + { :pattern => '^%*%*?62%*'+trunk_access_code+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+%1', }, + { :pattern => '^%*%*?62%*'+trunk_access_code+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+'+country_code+'%1', }, ] - if !trunk_prefix.blank? && !area_code.blank? - elements << { :pattern => '^%*%*?62%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfo-+'+country_code+area_code+'%1' } + if !trunk_access_code.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?62%*'+trunk_access_code+'([1-9]%d+)#$', :replacement => 'f-cfo-+'+country_code+area_code+'%1' } end CallRoute.create_prerouting_entry('call forward if offline', elements) @@ -184,12 +184,12 @@ class CallRoute < ActiveRecord::Base elements = [ { :pattern => '^%*67#$', :replacement => 'f-cfb', }, { :pattern => '^%*%*?67%*(%+?[1-9]%d+)#$', :replacement => 'f-cfb-%1', }, - { :pattern => '^%*%*?67%*'+trunk_prefix+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+%1', }, - { :pattern => '^%*%*?67%*'+trunk_prefix+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+'+country_code+'%1', }, + { :pattern => '^%*%*?67%*'+trunk_access_code+international_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+%1', }, + { :pattern => '^%*%*?67%*'+trunk_access_code+national_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+'+country_code+'%1', }, ] - if !trunk_prefix.blank? && !area_code.blank? - elements << { :pattern => '^%*%*?67%*'+trunk_prefix+'([1-9]%d+)#$', :replacement => 'f-cfb-+'+country_code+area_code+'%1' } + if !trunk_access_code.blank? && !area_code.blank? + elements << { :pattern => '^%*%*?67%*'+trunk_access_code+'([1-9]%d+)#$', :replacement => 'f-cfb-+'+country_code+area_code+'%1' } end CallRoute.create_prerouting_entry('call forward if busy', elements) -- cgit v1.2.3 From 5fbbe9c7479a7dc615b8d5630b9e1b2a6ce11b15 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 21 Jan 2013 15:43:28 +0100 Subject: umlauts added --- app/controllers/config_snom_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 24f6e59..149e601 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -5,13 +5,13 @@ class ConfigSnomController < ApplicationController KEY_REGEXP = { '0' => "[ -.,_0]+", '1' => "[ -.,_1]+", - '2' => "[abc2]", - '3' => "[def3]", - '4' => "[ghi4]", + '2' => "[abc2\xC3\xA4]", + '3' => "[def3\xC3\xA9]", + '4' => "[ghi4\xC3\xAF]", '5' => "[jkl5]", - '6' => "[mno6]", - '7' => "[pqrs7]", - '8' => "[tuv8]", + '6' => "[mno6\xC3\xB6]", + '7' => "[pqrs7\xC3\x9F]", + '8' => "[tuv8\xC3\xBC]", '9' => "[wxyz9]", } -- cgit v1.2.3 From b116d8c75368e4e5593d0bd46850ea04eace83a2 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 21 Jan 2013 15:53:29 +0100 Subject: migration removed --- db/migrate/20130116203000_set_prerouting_table.rb | 99 ----------------------- 1 file changed, 99 deletions(-) delete mode 100644 db/migrate/20130116203000_set_prerouting_table.rb diff --git a/db/migrate/20130116203000_set_prerouting_table.rb b/db/migrate/20130116203000_set_prerouting_table.rb deleted file mode 100644 index 8b0365f..0000000 --- a/db/migrate/20130116203000_set_prerouting_table.rb +++ /dev/null @@ -1,99 +0,0 @@ -class SetPreroutingTable < ActiveRecord::Migration - def up - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*$', :replacement => 'f-li', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)#*$', :replacement => 'f-li-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*(%d+)%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)%*(%d+)#*$', :replacement => 'f-li-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#0#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#0#$', :replacement => 'f-lo', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*5%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*5%*(%d+)#$', :replacement => 'f-acdmtg-0-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*30#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*30#$', :replacement => 'f-clipon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#30#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#30#$', :replacement => 'f-clipoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*31#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#$', :replacement => 'f-cliroff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#31#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#$', :replacement => 'f-cliron', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#(%d+)$', :replacement => 'f-dcliroff-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#(%d+)$', :replacement => 'f-dcliron-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*43#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*43#$', :replacement => 'f-cwaon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#43#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#43#$', :replacement => 'f-cwaoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#002#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#002#$', :replacement => 'f-cfoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##002#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##002#$', :replacement => 'f-cfdel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*21#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21#$', :replacement => 'f-cfu', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#21#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#21#$', :replacement => 'f-cfuoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##21#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##21#$', :replacement => 'f-cfudel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61#$', :replacement => 'f-cfn', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#61#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#61#$', :replacement => 'f-cfnoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##61#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##61#$', :replacement => 'f-cfndel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*62#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62#$', :replacement => 'f-cfo', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#62#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#62#$', :replacement => 'f-cfooff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##62#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##62#$', :replacement => 'f-cfodel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*67#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67#$', :replacement => 'f-cfb', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#67#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#67#$', :replacement => 'f-cfboff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##67#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##67#$', :replacement => 'f-cfbdel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*66#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*66#$', :replacement => 'f-redial', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98#$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98%*(%d+)#$', :replacement => 'f-vmcheck-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*1337%*1%*1#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*1#$', :replacement => 'f-loaon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*1337%*1%*0#$', :endpoint_type => 'dialplanfunction').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*0#$', :replacement => 'f-loaoff', :action => 'set_route_var', :mandatory => true) - - CallRoute.create(:routing_table => 'prerouting', :name => 'international prefix', :endpoint_type => 'phonenumber').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^00(%d+)$', :replacement => '+%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:routing_table => 'prerouting', :name => 'national prefix', :endpoint_type => 'phonenumber').route_elements. - create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^0(%d+)$', :replacement => '+49%1', :action => 'set_route_var', :mandatory => true) - end - - def down - CallRoute.where(:routing_table => "prerouting").destroy_all - end -end -- cgit v1.2.3 From 495bbfdf78206c8adaec057e83900dda6754092c Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 21 Jan 2013 23:21:48 +0100 Subject: order and limit added to redial query --- misc/freeswitch/scripts/dialplan/functions.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index 3fa1589..2ca51c8 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -516,7 +516,13 @@ function Functions.redial(self, caller) return { continue = false, code = 403, phrase = 'Incompatible caller', no_cdr = true } end - local sql_query = 'SELECT `destination_number` FROM `call_histories` WHERE `entry_type` = "dialed" AND `call_historyable_type` = "SipAccount" AND `call_historyable_id` = ' .. caller_sip_account.record.id; + local sql_query = 'SELECT `destination_number` \ + FROM `call_histories` \ + WHERE `entry_type` = "dialed" \ + AND `call_historyable_type` = "SipAccount" \ + AND `call_historyable_id` = ' .. caller_sip_account.record.id .. ' \ + ORDER BY `start_stamp` DESC LIMIT 1'; + local phone_number = self.database:query_return_value(sql_query); common_str = require 'common.str'; -- cgit v1.2.3 From 18ed88c7e3c789366f6e5443dc4ee0bc981a4b88 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 21 Jan 2013 20:18:16 +0100 Subject: Started the migration to Twitter Bootstrap. --- app/assets/images/amooma-logo.png | Bin 1314 -> 0 bytes app/assets/images/bg-body.png | Bin 1768 -> 0 bytes .../images/gradients/light-to-dark-blue-x63.png | Bin 187 -> 0 bytes .../images/gradients/white-gray-x29-reverse.png | Bin 123 -> 0 bytes app/assets/images/gradients/white-gray-x29.png | Bin 126 -> 0 bytes app/assets/images/gradients/white-texture-x63.png | Bin 6927 -> 0 bytes app/assets/images/icons/cellphone-32x.png | Bin 1938 -> 0 bytes app/assets/images/icons/clock-32x.png | Bin 5968 -> 0 bytes app/assets/images/icons/cross-16x.png | Bin 3350 -> 0 bytes app/assets/images/icons/facebook-32x.png | Bin 402 -> 0 bytes app/assets/images/icons/fax-32x.png | Bin 5762 -> 0 bytes .../images/icons/glyphicons-halflings-white.png | Bin 0 -> 8777 bytes app/assets/images/icons/glyphicons-halflings.png | Bin 0 -> 12799 bytes app/assets/images/icons/gs_envelope_16x.png | Bin 371 -> 0 bytes app/assets/images/icons/gs_forward_16x.png | Bin 301 -> 0 bytes app/assets/images/icons/gs_missed_16x.png | Bin 354 -> 0 bytes app/assets/images/icons/gs_placed_16x.png | Bin 397 -> 0 bytes app/assets/images/icons/gs_received_16x.png | Bin 390 -> 0 bytes app/assets/images/icons/headphones-16x.png | Bin 3285 -> 0 bytes app/assets/images/icons/headphones-32x.png | Bin 5906 -> 0 bytes app/assets/images/icons/house-32x.png | Bin 5741 -> 0 bytes app/assets/images/icons/mic-32x.png | Bin 5837 -> 0 bytes app/assets/images/icons/microphone-16x.png | Bin 3239 -> 0 bytes app/assets/images/icons/microphone-32x.png | Bin 5837 -> 0 bytes app/assets/images/icons/mute-16x.png | Bin 3349 -> 0 bytes app/assets/images/icons/phone-down-32x.png | Bin 5879 -> 0 bytes app/assets/images/icons/phone-down-green-32x.png | Bin 3426 -> 0 bytes app/assets/images/icons/phone-down-grey-32x.png | Bin 3283 -> 0 bytes app/assets/images/icons/phone-down-red-32x.png | Bin 3312 -> 0 bytes app/assets/images/icons/phone-mobile-32x.png | Bin 5509 -> 0 bytes app/assets/images/icons/phone-up-32x.png | Bin 5861 -> 0 bytes app/assets/images/icons/search-13x16.png | Bin 849 -> 0 bytes app/assets/images/icons/skype-32x.png | Bin 625 -> 0 bytes app/assets/images/icons/star-16x.png | Bin 3379 -> 0 bytes app/assets/images/icons/suitcase-32x.png | Bin 5550 -> 0 bytes app/assets/images/icons/tag-16x.png | Bin 3286 -> 0 bytes app/assets/images/icons/twitter-32x.png | Bin 397 -> 0 bytes app/assets/images/icons/unmute-16x.png | Bin 3373 -> 0 bytes app/assets/images/icons/user-16x.png | Bin 3287 -> 0 bytes app/assets/images/icons/user-female-16x.png | Bin 1680 -> 0 bytes app/assets/images/icons/user-male-16x.png | Bin 1559 -> 0 bytes app/assets/images/logo.png | Bin 7490 -> 0 bytes app/assets/images/phones/snom/Visio_snom300.png | Bin 0 -> 51018 bytes app/assets/images/phones/snom/Visio_snom320.png | Bin 0 -> 66491 bytes app/assets/images/phones/snom/Visio_snom360.png | Bin 0 -> 68592 bytes app/assets/images/phones/snom/Visio_snom370.png | Bin 0 -> 68924 bytes app/assets/images/phones/snom/Visio_snom820.png | Bin 0 -> 60875 bytes app/assets/images/phones/snom/Visio_snom821.png | Bin 0 -> 60875 bytes app/assets/images/phones/snom/Visio_snom870.png | Bin 0 -> 59457 bytes .../images/screenshots/gs5/gs5_boot_menu.png | Bin 0 -> 94638 bytes .../images/screenshots/gs5/gs5_conferences_new.png | Bin 0 -> 195085 bytes app/assets/images/screenshots/gs5/gs5_login.png | Bin 0 -> 65422 bytes .../screenshots/gs5/gs5_phone_book_entries.png | Bin 0 -> 216341 bytes .../images/screenshots/gs5/gs5_phones_new.png | Bin 0 -> 195178 bytes .../images/screenshots/gs5/gs5_setup_admin.png | Bin 0 -> 185624 bytes .../images/screenshots/gs5/gs5_tenants_new.png | Bin 0 -> 208446 bytes app/assets/images/stefan-wintermeyer-klein.jpg | Bin 0 -> 1610 bytes app/assets/images/stefan-wintermeyer.jpg | Bin 0 -> 2100110 bytes app/assets/images/stubs/user-36x.jpg | Bin 2093 -> 0 bytes app/assets/images/user.png | Bin 4800 -> 0 bytes app/assets/javascripts/api/rows.js.coffee | 3 - app/assets/javascripts/application.js | 19 +- app/assets/javascripts/bootstrap.js | 2025 +++++++ app/assets/javascripts/config_siemens.js.coffee | 3 - app/assets/javascripts/core.coffee | 5 - app/assets/javascripts/phones.js.coffee | 3 - app/assets/javascripts/softkeys.js.coffee | 25 - app/assets/javascripts/vendor/autoresize.jquery.js | 94 - .../vendor/fancybox/jquery.easing-1.3.pack.js | 205 - .../vendor/fancybox/jquery.fancybox-1.3.4.pack.js | 46 - .../fancybox/jquery.mousewheel-3.0.4.pack.js | 14 - app/assets/javascripts/vendor/html5boilerplate.js | 20 - app/assets/javascripts/vendor/jquery-1.6.2.min.js | 18 - app/assets/javascripts/vendor/jquery.condom.js | 52 - .../javascripts/vendor/jquery.easy-slider-1.7.js | 225 - .../javascripts/vendor/jquery.survival-kit.coffee | 36 - app/assets/javascripts/vendor/jquery.tmpl.js | 486 -- .../javascripts/vendor/modernizr-2.0.6.min.js | 1116 ---- app/assets/stylesheets/api/rows.css.scss | 3 - app/assets/stylesheets/app/layouts/_app.scss | 24 - .../stylesheets/app/layouts/_conference.scss | 136 - .../stylesheets/app/layouts/_phone-book-entry.scss | 176 - app/assets/stylesheets/app/pages/_phone_book.scss | 25 - app/assets/stylesheets/app/shared/_contents.scss | 374 -- app/assets/stylesheets/app/shared/_footers.scss | 90 - app/assets/stylesheets/app/shared/_handheld.scss | 25 - app/assets/stylesheets/app/shared/_headers.scss | 145 - app/assets/stylesheets/app/shared/_ie.scss | 7 - app/assets/stylesheets/app/shared/_media.scss | 16 - app/assets/stylesheets/app/shared/_print.scss | 17 - app/assets/stylesheets/application.css | 15 + app/assets/stylesheets/application.css.scss | 117 - .../stylesheets/bootstrap/bootstrap-responsive.css | 1088 ++++ app/assets/stylesheets/bootstrap/bootstrap.css.erb | 5893 ++++++++++++++++++++ .../stylesheets/gemeinschaft-generic.css.scss | 13 + app/assets/stylesheets/scaffolds.css.scss | 56 - app/assets/stylesheets/vendor/README | 1 - .../stylesheets/vendor/boilerplate-1.0/README | 15 - .../stylesheets/vendor/boilerplate-1.0/_reset.scss | 37 - .../vendor/boilerplate-1.0/_styles.scss | 171 - .../stylesheets/vendor/boilerplate-2.0/README | 16 - .../vendor/boilerplate-2.0/_styles.scss | 209 - .../stylesheets/vendor/easy-slider/_numeric.scss | 44 - .../stylesheets/vendor/facebox/_facebox.scss | 85 - app/assets/stylesheets/vendor/fancy-box/README | 4 - .../stylesheets/vendor/fancy-box/_fancy-box.scss | 336 -- app/assets/stylesheets/vendor/fancy-buttons/README | 3 - .../vendor/fancy-buttons/_fancy-buttons.scss | 189 - .../vendor/fancy-buttons/_fancy-gradient.scss | 28 - .../stylesheets/vendor/survival-kit/_blog.scss | 99 - .../stylesheets/vendor/survival-kit/_effects.scss | 97 - .../stylesheets/vendor/survival-kit/_forms.scss | 313 -- .../stylesheets/vendor/survival-kit/_headers.scss | 36 - .../stylesheets/vendor/survival-kit/_images.scss | 121 - .../stylesheets/vendor/survival-kit/_lists.scss | 37 - .../stylesheets/vendor/survival-kit/_loader.scss | 11 - .../vendor/survival-kit/_navigation.scss | 230 - .../stylesheets/vendor/survival-kit/_secure.scss | 3 - .../stylesheets/vendor/survival-kit/_tools.scss | 267 - .../access_authorizations/_index_core.html.haml | 2 +- app/views/access_authorizations/edit.html.haml | 2 +- app/views/access_authorizations/index.html.haml | 2 +- app/views/access_authorizations/new.html.haml | 2 +- app/views/access_authorizations/show.html.haml | 2 +- app/views/acd_agents/_index_core.html.haml | 2 +- app/views/acd_agents/edit.html.haml | 2 +- app/views/acd_agents/index.html.haml | 2 +- app/views/acd_agents/new.html.haml | 2 +- app/views/acd_agents/show.html.haml | 2 +- app/views/acd_callers/_index_core.html.haml | 2 +- app/views/acd_callers/index.html.haml | 2 +- app/views/acd_callers/show.html.haml | 2 +- app/views/addresses/_index_core.html.haml | 2 +- app/views/addresses/edit.html.haml | 2 +- app/views/addresses/index.html.haml | 2 +- app/views/addresses/new.html.haml | 2 +- app/views/addresses/show.html.haml | 2 +- .../_index_core.html.haml | 2 +- .../automatic_call_distributors/edit.html.haml | 2 +- .../automatic_call_distributors/index.html.haml | 2 +- .../automatic_call_distributors/new.html.haml | 2 +- .../automatic_call_distributors/show.html.haml | 4 +- app/views/call_forwards/_index_core.html.haml | 2 +- app/views/call_forwards/edit.html.haml | 2 +- app/views/call_forwards/index.html.haml | 2 +- app/views/call_forwards/new.html.haml | 2 +- app/views/call_forwards/show.html.haml | 2 +- app/views/call_histories/_index_core.html.haml | 2 +- app/views/call_histories/index.html.haml | 4 +- app/views/call_routes/_index_core.html.haml | 4 +- app/views/call_routes/edit.html.haml | 2 +- app/views/call_routes/index.html.haml | 4 +- app/views/call_routes/new.html.haml | 2 +- app/views/call_routes/show.html.haml | 2 +- app/views/calls/_index_core.html.haml | 2 +- app/views/calls/index.html.haml | 2 +- app/views/callthroughs/_index_core.html.haml | 2 +- app/views/callthroughs/edit.html.haml | 2 +- app/views/callthroughs/index.html.haml | 2 +- app/views/callthroughs/new.html.haml | 2 +- app/views/callthroughs/show.html.haml | 2 +- .../conference_invitees/_index_core.html.haml | 2 +- app/views/conference_invitees/edit.html.haml | 2 +- app/views/conference_invitees/index.html.haml | 2 +- app/views/conference_invitees/new.html.haml | 2 +- app/views/conference_invitees/show.html.haml | 2 +- app/views/conferences/_index_core.html.haml | 2 +- app/views/conferences/edit.html.haml | 2 +- app/views/conferences/index.html.haml | 2 +- app/views/conferences/new.html.haml | 2 +- app/views/conferences/show.html.haml | 2 +- app/views/config_polycom/_call_history.xml.haml | 2 +- app/views/config_polycom/_phone_book.xml.haml | 2 +- app/views/fax_accounts/_index_core.html.haml | 2 +- app/views/fax_accounts/edit.html.haml | 2 +- app/views/fax_accounts/index.html.haml | 2 +- app/views/fax_accounts/new.html.haml | 2 +- app/views/fax_accounts/show.html.haml | 2 +- app/views/fax_documents/_index_core.html.haml | 2 +- app/views/fax_documents/edit.html.haml | 2 +- app/views/fax_documents/index.html.haml | 2 +- app/views/fax_documents/new.html.haml | 2 +- app/views/fax_documents/show.html.haml | 2 +- .../_index_core.html.haml | 2 +- .../freeswitch_voicemail_msgs/index.html.haml | 2 +- app/views/gateway_parameters/_index_core.html.haml | 2 +- app/views/gateway_parameters/edit.html.haml | 2 +- app/views/gateway_parameters/index.html.haml | 2 +- app/views/gateway_parameters/new.html.haml | 2 +- app/views/gateway_parameters/show.html.haml | 2 +- app/views/gateway_settings/_index_core.html.haml | 2 +- app/views/gateway_settings/edit.html.haml | 2 +- app/views/gateway_settings/index.html.haml | 2 +- app/views/gateway_settings/new.html.haml | 2 +- app/views/gateway_settings/show.html.haml | 2 +- app/views/gateways/_index_core.html.haml | 2 +- app/views/gateways/edit.html.haml | 2 +- app/views/gateways/index.html.haml | 2 +- app/views/gateways/new.html.haml | 2 +- app/views/gateways/show.html.haml | 2 +- app/views/gemeinschaft_setups/new.de.html.haml | 3 +- app/views/gemeinschaft_setups/new.html.haml | 3 +- .../_index_core.html.haml | 2 +- .../gs_cluster_sync_log_entries/edit.html.haml | 2 +- .../gs_cluster_sync_log_entries/index.html.haml | 2 +- .../gs_cluster_sync_log_entries/new.html.haml | 2 +- .../gs_cluster_sync_log_entries/show.html.haml | 2 +- app/views/gs_nodes/_index_core.html.haml | 2 +- app/views/gs_nodes/edit.html.haml | 2 +- app/views/gs_nodes/index.html.haml | 2 +- app/views/gs_nodes/new.html.haml | 2 +- app/views/gs_nodes/show.html.haml | 2 +- app/views/gs_parameters/edit.html.haml | 2 +- app/views/gs_parameters/index.html.haml | 6 +- app/views/gs_parameters/show.html.haml | 2 +- app/views/gui_functions/_index_core.html.haml | 2 +- app/views/gui_functions/edit.html.haml | 2 +- app/views/gui_functions/index.html.haml | 2 +- app/views/gui_functions/new.html.haml | 2 +- app/views/gui_functions/show.html.haml | 2 +- app/views/hunt_group_members/_index_core.html.haml | 2 +- app/views/hunt_group_members/edit.html.haml | 2 +- app/views/hunt_group_members/index.html.haml | 2 +- app/views/hunt_group_members/new.html.haml | 2 +- app/views/hunt_group_members/show.html.haml | 2 +- app/views/hunt_groups/_index_core.html.haml | 2 +- app/views/hunt_groups/edit.html.haml | 2 +- app/views/hunt_groups/index.html.haml | 2 +- app/views/hunt_groups/new.html.haml | 2 +- app/views/hunt_groups/show.html.haml | 2 +- app/views/layouts/_footer.html.haml | 3 + app/views/layouts/_navbar.html.haml | 21 + app/views/layouts/application.html.haml | 73 +- app/views/layouts/old-application.html.haml | 48 + app/views/layouts/old_navbar.html.haml | 10 + app/views/layouts/test.haml | 0 app/views/manufacturers/_index_core.html.haml | 2 +- app/views/manufacturers/edit.html.haml | 2 +- app/views/manufacturers/index.html.haml | 2 +- app/views/manufacturers/new.html.haml | 2 +- app/views/manufacturers/show.html.haml | 2 +- app/views/page/beginners_intro.de.html.haml | 2 +- app/views/page/beginners_intro.html.haml | 2 +- app/views/page/conference.html.haml | 2 +- app/views/page/index.de.html.haml | 2 +- app/views/page/index.html.haml | 2 +- .../phone_book_entries/_index_core.de.html.haml | 2 +- app/views/phone_book_entries/_index_core.html.haml | 2 +- app/views/phone_book_entries/edit.html.haml | 2 +- app/views/phone_book_entries/index.html.haml | 2 +- app/views/phone_book_entries/new.html.haml | 2 +- app/views/phone_book_entries/show.html.haml | 2 +- .../phone_book_entries/show.html.haml.examlple | 2 +- app/views/phone_books/_index_core.html.haml | 2 +- app/views/phone_books/edit.html.haml | 2 +- app/views/phone_books/index.html.haml | 2 +- app/views/phone_books/new.html.haml | 2 +- app/views/phone_books/show.html.haml | 2 +- app/views/phone_models/_index_core.html.haml | 2 +- app/views/phone_models/edit.html.haml | 2 +- app/views/phone_models/index.html.haml | 2 +- app/views/phone_models/new.html.haml | 2 +- app/views/phone_models/show.html.haml | 2 +- .../phone_number_ranges/_index_core.html.haml | 2 +- app/views/phone_number_ranges/edit.html.haml | 2 +- app/views/phone_number_ranges/index.html.haml | 2 +- app/views/phone_number_ranges/new.html.haml | 2 +- app/views/phone_number_ranges/show.html.haml | 2 +- app/views/phone_numbers/_index_core.html.haml | 2 +- app/views/phone_numbers/edit.html.haml | 2 +- app/views/phone_numbers/index.html.haml | 2 +- app/views/phone_numbers/new.html.haml | 2 +- app/views/phone_numbers/show.html.haml | 2 +- app/views/phone_sip_accounts/_index_core.html.haml | 2 +- app/views/phone_sip_accounts/index.html.haml | 2 +- app/views/phone_sip_accounts/new.html.haml | 2 +- app/views/phone_sip_accounts/show.html.haml | 2 +- app/views/phones/_index_core.html.haml | 2 +- app/views/phones/edit.html.haml | 2 +- app/views/phones/index.html.haml | 2 +- app/views/phones/new.html.haml | 2 +- app/views/phones/show.html.haml | 2 +- app/views/ringtones/_index_core.html.haml | 2 +- app/views/ringtones/edit.html.haml | 2 +- app/views/ringtones/index.html.haml | 2 +- app/views/ringtones/new.html.haml | 2 +- app/views/ringtones/show.html.haml | 2 +- app/views/route_elements/_index_core.html.haml | 2 +- app/views/route_elements/edit.html.haml | 2 +- app/views/route_elements/index.html.haml | 2 +- app/views/route_elements/new.html.haml | 2 +- app/views/route_elements/show.html.haml | 2 +- app/views/sessions/new.html.haml | 2 +- app/views/shared/_create_link.html.haml | 13 +- app/views/shared/_flash.html.haml | 19 - .../shared/_index_view_edit_destroy_part.html.haml | 62 +- app/views/shared/_show_edit_destroy_part.html.haml | 20 +- app/views/shared/_system_message.html.haml | 10 - app/views/sip_accounts/_index_core.html.haml | 2 +- app/views/sip_accounts/edit.html.haml | 2 +- app/views/sip_accounts/index.html.haml | 2 +- app/views/sip_accounts/new.html.haml | 2 +- app/views/sip_accounts/show.html.haml | 2 +- app/views/sip_domains/_index_core.html.haml | 2 +- app/views/sip_domains/edit.html.haml | 2 +- app/views/sip_domains/index.html.haml | 2 +- app/views/sip_domains/new.html.haml | 2 +- app/views/sip_domains/show.html.haml | 2 +- app/views/softkeys/_index_core.html.haml | 2 +- app/views/softkeys/edit.html.haml | 2 +- app/views/softkeys/index.html.haml | 2 +- app/views/softkeys/new.html.haml | 2 +- app/views/softkeys/show.html.haml | 2 +- app/views/system_messages/_index_core.html.haml | 2 +- app/views/system_messages/index.html.haml | 2 +- app/views/system_messages/new.html.haml | 2 +- app/views/system_messages/show.html.haml | 2 +- app/views/tenants/_gs_parameter_table.html.haml | 8 +- app/views/tenants/_index_core.html.haml | 2 +- .../tenants/_sip_accounts_and_phones.html.haml | 8 +- app/views/tenants/_table_of_functions.html.haml | 12 +- app/views/tenants/edit.html.haml | 2 +- app/views/tenants/index.html.haml | 2 +- app/views/tenants/new.html.haml | 2 +- app/views/tenants/show.html.haml | 2 +- .../user_group_memberships/_index_core.html.haml | 2 +- app/views/user_group_memberships/edit.html.haml | 2 +- app/views/user_group_memberships/index.html.haml | 2 +- app/views/user_group_memberships/new.html.haml | 2 +- app/views/user_group_memberships/show.html.haml | 2 +- app/views/user_groups/_index_core.html.haml | 2 +- app/views/user_groups/edit.html.haml | 2 +- app/views/user_groups/index.html.haml | 2 +- app/views/user_groups/new.html.haml | 2 +- app/views/user_groups/show.html.haml | 2 +- app/views/users/_index_core.html.haml | 2 +- app/views/users/edit.html.haml | 2 +- app/views/users/index.html.haml | 2 +- app/views/users/new.html.haml | 2 +- app/views/users/show.html.haml | 8 +- app/views/voicemail_messages/_index_core.html.haml | 2 +- app/views/voicemail_messages/index.html.haml | 4 +- app/views/voicemail_settings/edit.html.haml | 2 +- app/views/voicemail_settings/show.html.haml | 2 +- app/views/whitelists/_index_core.html.haml | 2 +- app/views/whitelists/edit.html.haml | 2 +- app/views/whitelists/index.html.haml | 2 +- app/views/whitelists/new.html.haml | 2 +- app/views/whitelists/show.html.haml | 2 +- config/application.rb | 1 + config/environments/development.rb | 2 +- lib/bootstrap_breadcrumbs_builder.rb | 32 + .../templates/views/haml/edit.html.haml | 2 +- .../templates/views/haml/login.html.haml | 2 +- .../templates/views/haml/signup.html.haml | 2 +- .../templates/views/haml/_index_core.html.haml | 2 +- .../scaffold/templates/views/haml/edit.html.haml | 2 +- .../scaffold/templates/views/haml/index.html.haml | 2 +- .../scaffold/templates/views/haml/new.html.haml | 2 +- .../scaffold/templates/views/haml/show.html.haml | 2 +- 360 files changed, 9496 insertions(+), 6283 deletions(-) delete mode 100644 app/assets/images/amooma-logo.png delete mode 100644 app/assets/images/bg-body.png delete mode 100644 app/assets/images/gradients/light-to-dark-blue-x63.png delete mode 100644 app/assets/images/gradients/white-gray-x29-reverse.png delete mode 100644 app/assets/images/gradients/white-gray-x29.png delete mode 100644 app/assets/images/gradients/white-texture-x63.png delete mode 100644 app/assets/images/icons/cellphone-32x.png delete mode 100644 app/assets/images/icons/clock-32x.png delete mode 100644 app/assets/images/icons/cross-16x.png delete mode 100644 app/assets/images/icons/facebook-32x.png delete mode 100644 app/assets/images/icons/fax-32x.png create mode 100644 app/assets/images/icons/glyphicons-halflings-white.png create mode 100644 app/assets/images/icons/glyphicons-halflings.png delete mode 100644 app/assets/images/icons/gs_envelope_16x.png delete mode 100644 app/assets/images/icons/gs_forward_16x.png delete mode 100644 app/assets/images/icons/gs_missed_16x.png delete mode 100644 app/assets/images/icons/gs_placed_16x.png delete mode 100644 app/assets/images/icons/gs_received_16x.png delete mode 100644 app/assets/images/icons/headphones-16x.png delete mode 100644 app/assets/images/icons/headphones-32x.png delete mode 100644 app/assets/images/icons/house-32x.png delete mode 100644 app/assets/images/icons/mic-32x.png delete mode 100644 app/assets/images/icons/microphone-16x.png delete mode 100644 app/assets/images/icons/microphone-32x.png delete mode 100644 app/assets/images/icons/mute-16x.png delete mode 100644 app/assets/images/icons/phone-down-32x.png delete mode 100644 app/assets/images/icons/phone-down-green-32x.png delete mode 100644 app/assets/images/icons/phone-down-grey-32x.png delete mode 100644 app/assets/images/icons/phone-down-red-32x.png delete mode 100644 app/assets/images/icons/phone-mobile-32x.png delete mode 100644 app/assets/images/icons/phone-up-32x.png delete mode 100644 app/assets/images/icons/search-13x16.png delete mode 100644 app/assets/images/icons/skype-32x.png delete mode 100644 app/assets/images/icons/star-16x.png delete mode 100644 app/assets/images/icons/suitcase-32x.png delete mode 100644 app/assets/images/icons/tag-16x.png delete mode 100644 app/assets/images/icons/twitter-32x.png delete mode 100644 app/assets/images/icons/unmute-16x.png delete mode 100644 app/assets/images/icons/user-16x.png delete mode 100644 app/assets/images/icons/user-female-16x.png delete mode 100644 app/assets/images/icons/user-male-16x.png delete mode 100644 app/assets/images/logo.png create mode 100644 app/assets/images/phones/snom/Visio_snom300.png create mode 100644 app/assets/images/phones/snom/Visio_snom320.png create mode 100644 app/assets/images/phones/snom/Visio_snom360.png create mode 100644 app/assets/images/phones/snom/Visio_snom370.png create mode 100644 app/assets/images/phones/snom/Visio_snom820.png create mode 100644 app/assets/images/phones/snom/Visio_snom821.png create mode 100644 app/assets/images/phones/snom/Visio_snom870.png create mode 100644 app/assets/images/screenshots/gs5/gs5_boot_menu.png create mode 100644 app/assets/images/screenshots/gs5/gs5_conferences_new.png create mode 100644 app/assets/images/screenshots/gs5/gs5_login.png create mode 100644 app/assets/images/screenshots/gs5/gs5_phone_book_entries.png create mode 100644 app/assets/images/screenshots/gs5/gs5_phones_new.png create mode 100644 app/assets/images/screenshots/gs5/gs5_setup_admin.png create mode 100644 app/assets/images/screenshots/gs5/gs5_tenants_new.png create mode 100644 app/assets/images/stefan-wintermeyer-klein.jpg create mode 100644 app/assets/images/stefan-wintermeyer.jpg delete mode 100644 app/assets/images/stubs/user-36x.jpg delete mode 100644 app/assets/images/user.png delete mode 100644 app/assets/javascripts/api/rows.js.coffee create mode 100644 app/assets/javascripts/bootstrap.js delete mode 100644 app/assets/javascripts/config_siemens.js.coffee delete mode 100644 app/assets/javascripts/core.coffee delete mode 100644 app/assets/javascripts/phones.js.coffee delete mode 100644 app/assets/javascripts/softkeys.js.coffee delete mode 100644 app/assets/javascripts/vendor/autoresize.jquery.js delete mode 100755 app/assets/javascripts/vendor/fancybox/jquery.easing-1.3.pack.js delete mode 100755 app/assets/javascripts/vendor/fancybox/jquery.fancybox-1.3.4.pack.js delete mode 100755 app/assets/javascripts/vendor/fancybox/jquery.mousewheel-3.0.4.pack.js delete mode 100644 app/assets/javascripts/vendor/html5boilerplate.js delete mode 100755 app/assets/javascripts/vendor/jquery-1.6.2.min.js delete mode 100644 app/assets/javascripts/vendor/jquery.condom.js delete mode 100644 app/assets/javascripts/vendor/jquery.easy-slider-1.7.js delete mode 100644 app/assets/javascripts/vendor/jquery.survival-kit.coffee delete mode 100644 app/assets/javascripts/vendor/jquery.tmpl.js delete mode 100755 app/assets/javascripts/vendor/modernizr-2.0.6.min.js delete mode 100644 app/assets/stylesheets/api/rows.css.scss delete mode 100644 app/assets/stylesheets/app/layouts/_app.scss delete mode 100644 app/assets/stylesheets/app/layouts/_conference.scss delete mode 100644 app/assets/stylesheets/app/layouts/_phone-book-entry.scss delete mode 100644 app/assets/stylesheets/app/pages/_phone_book.scss delete mode 100644 app/assets/stylesheets/app/shared/_contents.scss delete mode 100644 app/assets/stylesheets/app/shared/_footers.scss delete mode 100644 app/assets/stylesheets/app/shared/_handheld.scss delete mode 100644 app/assets/stylesheets/app/shared/_headers.scss delete mode 100644 app/assets/stylesheets/app/shared/_ie.scss delete mode 100644 app/assets/stylesheets/app/shared/_media.scss delete mode 100644 app/assets/stylesheets/app/shared/_print.scss create mode 100644 app/assets/stylesheets/application.css delete mode 100644 app/assets/stylesheets/application.css.scss create mode 100644 app/assets/stylesheets/bootstrap/bootstrap-responsive.css create mode 100644 app/assets/stylesheets/bootstrap/bootstrap.css.erb create mode 100644 app/assets/stylesheets/gemeinschaft-generic.css.scss delete mode 100644 app/assets/stylesheets/scaffolds.css.scss delete mode 100644 app/assets/stylesheets/vendor/README delete mode 100644 app/assets/stylesheets/vendor/boilerplate-1.0/README delete mode 100644 app/assets/stylesheets/vendor/boilerplate-1.0/_reset.scss delete mode 100644 app/assets/stylesheets/vendor/boilerplate-1.0/_styles.scss delete mode 100644 app/assets/stylesheets/vendor/boilerplate-2.0/README delete mode 100644 app/assets/stylesheets/vendor/boilerplate-2.0/_styles.scss delete mode 100644 app/assets/stylesheets/vendor/easy-slider/_numeric.scss delete mode 100644 app/assets/stylesheets/vendor/facebox/_facebox.scss delete mode 100644 app/assets/stylesheets/vendor/fancy-box/README delete mode 100755 app/assets/stylesheets/vendor/fancy-box/_fancy-box.scss delete mode 100644 app/assets/stylesheets/vendor/fancy-buttons/README delete mode 100644 app/assets/stylesheets/vendor/fancy-buttons/_fancy-buttons.scss delete mode 100644 app/assets/stylesheets/vendor/fancy-buttons/_fancy-gradient.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_blog.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_effects.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_forms.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_headers.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_images.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_lists.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_loader.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_navigation.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_secure.scss delete mode 100644 app/assets/stylesheets/vendor/survival-kit/_tools.scss create mode 100644 app/views/layouts/_footer.html.haml create mode 100644 app/views/layouts/_navbar.html.haml create mode 100644 app/views/layouts/old-application.html.haml create mode 100644 app/views/layouts/old_navbar.html.haml create mode 100644 app/views/layouts/test.haml delete mode 100644 app/views/shared/_flash.html.haml delete mode 100644 app/views/shared/_system_message.html.haml create mode 100644 lib/bootstrap_breadcrumbs_builder.rb diff --git a/app/assets/images/amooma-logo.png b/app/assets/images/amooma-logo.png deleted file mode 100644 index 11096ff..0000000 Binary files a/app/assets/images/amooma-logo.png and /dev/null differ diff --git a/app/assets/images/bg-body.png b/app/assets/images/bg-body.png deleted file mode 100644 index 777eff6..0000000 Binary files a/app/assets/images/bg-body.png and /dev/null differ diff --git a/app/assets/images/gradients/light-to-dark-blue-x63.png b/app/assets/images/gradients/light-to-dark-blue-x63.png deleted file mode 100644 index 7eb020f..0000000 Binary files a/app/assets/images/gradients/light-to-dark-blue-x63.png and /dev/null differ diff --git a/app/assets/images/gradients/white-gray-x29-reverse.png b/app/assets/images/gradients/white-gray-x29-reverse.png deleted file mode 100644 index 7b7e879..0000000 Binary files a/app/assets/images/gradients/white-gray-x29-reverse.png and /dev/null differ diff --git a/app/assets/images/gradients/white-gray-x29.png b/app/assets/images/gradients/white-gray-x29.png deleted file mode 100644 index a1671d0..0000000 Binary files a/app/assets/images/gradients/white-gray-x29.png and /dev/null differ diff --git a/app/assets/images/gradients/white-texture-x63.png b/app/assets/images/gradients/white-texture-x63.png deleted file mode 100644 index 1576e8f..0000000 Binary files a/app/assets/images/gradients/white-texture-x63.png and /dev/null differ diff --git a/app/assets/images/icons/cellphone-32x.png b/app/assets/images/icons/cellphone-32x.png deleted file mode 100644 index cfc41f5..0000000 Binary files a/app/assets/images/icons/cellphone-32x.png and /dev/null differ diff --git a/app/assets/images/icons/clock-32x.png b/app/assets/images/icons/clock-32x.png deleted file mode 100644 index c076042..0000000 Binary files a/app/assets/images/icons/clock-32x.png and /dev/null differ diff --git a/app/assets/images/icons/cross-16x.png b/app/assets/images/icons/cross-16x.png deleted file mode 100644 index e22ed6f..0000000 Binary files a/app/assets/images/icons/cross-16x.png and /dev/null differ diff --git a/app/assets/images/icons/facebook-32x.png b/app/assets/images/icons/facebook-32x.png deleted file mode 100644 index 08fa0f7..0000000 Binary files a/app/assets/images/icons/facebook-32x.png and /dev/null differ diff --git a/app/assets/images/icons/fax-32x.png b/app/assets/images/icons/fax-32x.png deleted file mode 100644 index b05ee59..0000000 Binary files a/app/assets/images/icons/fax-32x.png and /dev/null differ diff --git a/app/assets/images/icons/glyphicons-halflings-white.png b/app/assets/images/icons/glyphicons-halflings-white.png new file mode 100644 index 0000000..3bf6484 Binary files /dev/null and b/app/assets/images/icons/glyphicons-halflings-white.png differ diff --git a/app/assets/images/icons/glyphicons-halflings.png b/app/assets/images/icons/glyphicons-halflings.png new file mode 100644 index 0000000..a996999 Binary files /dev/null and b/app/assets/images/icons/glyphicons-halflings.png differ diff --git a/app/assets/images/icons/gs_envelope_16x.png b/app/assets/images/icons/gs_envelope_16x.png deleted file mode 100644 index 6a82ade..0000000 Binary files a/app/assets/images/icons/gs_envelope_16x.png and /dev/null differ diff --git a/app/assets/images/icons/gs_forward_16x.png b/app/assets/images/icons/gs_forward_16x.png deleted file mode 100644 index 13c57eb..0000000 Binary files a/app/assets/images/icons/gs_forward_16x.png and /dev/null differ diff --git a/app/assets/images/icons/gs_missed_16x.png b/app/assets/images/icons/gs_missed_16x.png deleted file mode 100644 index 0b3b706..0000000 Binary files a/app/assets/images/icons/gs_missed_16x.png and /dev/null differ diff --git a/app/assets/images/icons/gs_placed_16x.png b/app/assets/images/icons/gs_placed_16x.png deleted file mode 100644 index b5065e9..0000000 Binary files a/app/assets/images/icons/gs_placed_16x.png and /dev/null differ diff --git a/app/assets/images/icons/gs_received_16x.png b/app/assets/images/icons/gs_received_16x.png deleted file mode 100644 index cd40c1a..0000000 Binary files a/app/assets/images/icons/gs_received_16x.png and /dev/null differ diff --git a/app/assets/images/icons/headphones-16x.png b/app/assets/images/icons/headphones-16x.png deleted file mode 100644 index dee8346..0000000 Binary files a/app/assets/images/icons/headphones-16x.png and /dev/null differ diff --git a/app/assets/images/icons/headphones-32x.png b/app/assets/images/icons/headphones-32x.png deleted file mode 100644 index 89a5df7..0000000 Binary files a/app/assets/images/icons/headphones-32x.png and /dev/null differ diff --git a/app/assets/images/icons/house-32x.png b/app/assets/images/icons/house-32x.png deleted file mode 100644 index b112915..0000000 Binary files a/app/assets/images/icons/house-32x.png and /dev/null differ diff --git a/app/assets/images/icons/mic-32x.png b/app/assets/images/icons/mic-32x.png deleted file mode 100644 index 30c4531..0000000 Binary files a/app/assets/images/icons/mic-32x.png and /dev/null differ diff --git a/app/assets/images/icons/microphone-16x.png b/app/assets/images/icons/microphone-16x.png deleted file mode 100644 index b62422d..0000000 Binary files a/app/assets/images/icons/microphone-16x.png and /dev/null differ diff --git a/app/assets/images/icons/microphone-32x.png b/app/assets/images/icons/microphone-32x.png deleted file mode 100644 index 30c4531..0000000 Binary files a/app/assets/images/icons/microphone-32x.png and /dev/null differ diff --git a/app/assets/images/icons/mute-16x.png b/app/assets/images/icons/mute-16x.png deleted file mode 100644 index 0656f3f..0000000 Binary files a/app/assets/images/icons/mute-16x.png and /dev/null differ diff --git a/app/assets/images/icons/phone-down-32x.png b/app/assets/images/icons/phone-down-32x.png deleted file mode 100644 index 38c3560..0000000 Binary files a/app/assets/images/icons/phone-down-32x.png and /dev/null differ diff --git a/app/assets/images/icons/phone-down-green-32x.png b/app/assets/images/icons/phone-down-green-32x.png deleted file mode 100644 index 9f21d45..0000000 Binary files a/app/assets/images/icons/phone-down-green-32x.png and /dev/null differ diff --git a/app/assets/images/icons/phone-down-grey-32x.png b/app/assets/images/icons/phone-down-grey-32x.png deleted file mode 100644 index 2b604ce..0000000 Binary files a/app/assets/images/icons/phone-down-grey-32x.png and /dev/null differ diff --git a/app/assets/images/icons/phone-down-red-32x.png b/app/assets/images/icons/phone-down-red-32x.png deleted file mode 100644 index f4cbde7..0000000 Binary files a/app/assets/images/icons/phone-down-red-32x.png and /dev/null differ diff --git a/app/assets/images/icons/phone-mobile-32x.png b/app/assets/images/icons/phone-mobile-32x.png deleted file mode 100644 index b373e1a..0000000 Binary files a/app/assets/images/icons/phone-mobile-32x.png and /dev/null differ diff --git a/app/assets/images/icons/phone-up-32x.png b/app/assets/images/icons/phone-up-32x.png deleted file mode 100644 index 9b765c7..0000000 Binary files a/app/assets/images/icons/phone-up-32x.png and /dev/null differ diff --git a/app/assets/images/icons/search-13x16.png b/app/assets/images/icons/search-13x16.png deleted file mode 100644 index 16aa3c6..0000000 Binary files a/app/assets/images/icons/search-13x16.png and /dev/null differ diff --git a/app/assets/images/icons/skype-32x.png b/app/assets/images/icons/skype-32x.png deleted file mode 100644 index c3b0978..0000000 Binary files a/app/assets/images/icons/skype-32x.png and /dev/null differ diff --git a/app/assets/images/icons/star-16x.png b/app/assets/images/icons/star-16x.png deleted file mode 100644 index 6b16932..0000000 Binary files a/app/assets/images/icons/star-16x.png and /dev/null differ diff --git a/app/assets/images/icons/suitcase-32x.png b/app/assets/images/icons/suitcase-32x.png deleted file mode 100644 index f53daa9..0000000 Binary files a/app/assets/images/icons/suitcase-32x.png and /dev/null differ diff --git a/app/assets/images/icons/tag-16x.png b/app/assets/images/icons/tag-16x.png deleted file mode 100644 index b4522d7..0000000 Binary files a/app/assets/images/icons/tag-16x.png and /dev/null differ diff --git a/app/assets/images/icons/twitter-32x.png b/app/assets/images/icons/twitter-32x.png deleted file mode 100644 index 51351a7..0000000 Binary files a/app/assets/images/icons/twitter-32x.png and /dev/null differ diff --git a/app/assets/images/icons/unmute-16x.png b/app/assets/images/icons/unmute-16x.png deleted file mode 100644 index e9dfde0..0000000 Binary files a/app/assets/images/icons/unmute-16x.png and /dev/null differ diff --git a/app/assets/images/icons/user-16x.png b/app/assets/images/icons/user-16x.png deleted file mode 100644 index 909403a..0000000 Binary files a/app/assets/images/icons/user-16x.png and /dev/null differ diff --git a/app/assets/images/icons/user-female-16x.png b/app/assets/images/icons/user-female-16x.png deleted file mode 100644 index 38dde34..0000000 Binary files a/app/assets/images/icons/user-female-16x.png and /dev/null differ diff --git a/app/assets/images/icons/user-male-16x.png b/app/assets/images/icons/user-male-16x.png deleted file mode 100644 index e03fd0f..0000000 Binary files a/app/assets/images/icons/user-male-16x.png and /dev/null differ diff --git a/app/assets/images/logo.png b/app/assets/images/logo.png deleted file mode 100644 index e4432b8..0000000 Binary files a/app/assets/images/logo.png and /dev/null differ diff --git a/app/assets/images/phones/snom/Visio_snom300.png b/app/assets/images/phones/snom/Visio_snom300.png new file mode 100644 index 0000000..42e7a87 Binary files /dev/null and b/app/assets/images/phones/snom/Visio_snom300.png differ diff --git a/app/assets/images/phones/snom/Visio_snom320.png b/app/assets/images/phones/snom/Visio_snom320.png new file mode 100644 index 0000000..9e91a57 Binary files /dev/null and b/app/assets/images/phones/snom/Visio_snom320.png differ diff --git a/app/assets/images/phones/snom/Visio_snom360.png b/app/assets/images/phones/snom/Visio_snom360.png new file mode 100644 index 0000000..aeb9115 Binary files /dev/null and b/app/assets/images/phones/snom/Visio_snom360.png differ diff --git a/app/assets/images/phones/snom/Visio_snom370.png b/app/assets/images/phones/snom/Visio_snom370.png new file mode 100644 index 0000000..e900b34 Binary files /dev/null and b/app/assets/images/phones/snom/Visio_snom370.png differ diff --git a/app/assets/images/phones/snom/Visio_snom820.png b/app/assets/images/phones/snom/Visio_snom820.png new file mode 100644 index 0000000..3ec75c7 Binary files /dev/null and b/app/assets/images/phones/snom/Visio_snom820.png differ diff --git a/app/assets/images/phones/snom/Visio_snom821.png b/app/assets/images/phones/snom/Visio_snom821.png new file mode 100644 index 0000000..3ec75c7 Binary files /dev/null and b/app/assets/images/phones/snom/Visio_snom821.png differ diff --git a/app/assets/images/phones/snom/Visio_snom870.png b/app/assets/images/phones/snom/Visio_snom870.png new file mode 100644 index 0000000..1550591 Binary files /dev/null and b/app/assets/images/phones/snom/Visio_snom870.png differ diff --git a/app/assets/images/screenshots/gs5/gs5_boot_menu.png b/app/assets/images/screenshots/gs5/gs5_boot_menu.png new file mode 100644 index 0000000..0502d3a Binary files /dev/null and b/app/assets/images/screenshots/gs5/gs5_boot_menu.png differ diff --git a/app/assets/images/screenshots/gs5/gs5_conferences_new.png b/app/assets/images/screenshots/gs5/gs5_conferences_new.png new file mode 100644 index 0000000..e0369af Binary files /dev/null and b/app/assets/images/screenshots/gs5/gs5_conferences_new.png differ diff --git a/app/assets/images/screenshots/gs5/gs5_login.png b/app/assets/images/screenshots/gs5/gs5_login.png new file mode 100644 index 0000000..97d6bbe Binary files /dev/null and b/app/assets/images/screenshots/gs5/gs5_login.png differ diff --git a/app/assets/images/screenshots/gs5/gs5_phone_book_entries.png b/app/assets/images/screenshots/gs5/gs5_phone_book_entries.png new file mode 100644 index 0000000..9a4be07 Binary files /dev/null and b/app/assets/images/screenshots/gs5/gs5_phone_book_entries.png differ diff --git a/app/assets/images/screenshots/gs5/gs5_phones_new.png b/app/assets/images/screenshots/gs5/gs5_phones_new.png new file mode 100644 index 0000000..d9024e6 Binary files /dev/null and b/app/assets/images/screenshots/gs5/gs5_phones_new.png differ diff --git a/app/assets/images/screenshots/gs5/gs5_setup_admin.png b/app/assets/images/screenshots/gs5/gs5_setup_admin.png new file mode 100644 index 0000000..f97ff8f Binary files /dev/null and b/app/assets/images/screenshots/gs5/gs5_setup_admin.png differ diff --git a/app/assets/images/screenshots/gs5/gs5_tenants_new.png b/app/assets/images/screenshots/gs5/gs5_tenants_new.png new file mode 100644 index 0000000..0f6a6e2 Binary files /dev/null and b/app/assets/images/screenshots/gs5/gs5_tenants_new.png differ diff --git a/app/assets/images/stefan-wintermeyer-klein.jpg b/app/assets/images/stefan-wintermeyer-klein.jpg new file mode 100644 index 0000000..3b62099 Binary files /dev/null and b/app/assets/images/stefan-wintermeyer-klein.jpg differ diff --git a/app/assets/images/stefan-wintermeyer.jpg b/app/assets/images/stefan-wintermeyer.jpg new file mode 100644 index 0000000..4fdeb30 Binary files /dev/null and b/app/assets/images/stefan-wintermeyer.jpg differ diff --git a/app/assets/images/stubs/user-36x.jpg b/app/assets/images/stubs/user-36x.jpg deleted file mode 100644 index 8a391a0..0000000 Binary files a/app/assets/images/stubs/user-36x.jpg and /dev/null differ diff --git a/app/assets/images/user.png b/app/assets/images/user.png deleted file mode 100644 index c0e33c7..0000000 Binary files a/app/assets/images/user.png and /dev/null differ diff --git a/app/assets/javascripts/api/rows.js.coffee b/app/assets/javascripts/api/rows.js.coffee deleted file mode 100644 index 7615679..0000000 --- a/app/assets/javascripts/api/rows.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 1762043..9097d83 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,14 +1,15 @@ -// This is a manifest file that'll be compiled into including all the files listed below. -// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically -// be included in the compiled file accessible from http://example.com/assets/application.js +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // the compiled file. // +// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD +// GO AFTER THE REQUIRES BELOW. +// //= require jquery //= require jquery_ujs -//= require core -//= require vendor/modernizr-2.0.6.min.js -//= require vendor/jquery.condom.js -//= require vendor/jquery.survival-kit -//= require phones -//= require softkeys +//= require_tree . diff --git a/app/assets/javascripts/bootstrap.js b/app/assets/javascripts/bootstrap.js new file mode 100644 index 0000000..c753bd6 --- /dev/null +++ b/app/assets/javascripts/bootstrap.js @@ -0,0 +1,2025 @@ +/* =================================================== + * bootstrap-transition.js v2.2.1 + * http://twitter.github.com/bootstrap/javascript.html#transitions + * =================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* CSS TRANSITION SUPPORT (http://www.modernizr.com/) + * ======================================================= */ + + $(function () { + + $.support.transition = (function () { + + var transitionEnd = (function () { + + var el = document.createElement('bootstrap') + , transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + } + , name + + for (name in transEndEventNames){ + if (el.style[name] !== undefined) { + return transEndEventNames[name] + } + } + + }()) + + return transitionEnd && { + end: transitionEnd + } + + })() + + }) + +}(window.jQuery);/* ========================================================== + * bootstrap-alert.js v2.2.1 + * http://twitter.github.com/bootstrap/javascript.html#alerts + * ========================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* ALERT CLASS DEFINITION + * ====================== */ + + var dismiss = '[data-dismiss="alert"]' + , Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + , selector = $this.attr('data-target') + , $parent + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = $(selector) + + e && e.preventDefault() + + $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) + + $parent.trigger(e = $.Event('close')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent + .trigger('closed') + .remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent.on($.support.transition.end, removeElement) : + removeElement() + } + + + /* ALERT PLUGIN DEFINITION + * ======================= */ + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('alert') + if (!data) $this.data('alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + /* ALERT DATA-API + * ============== */ + + $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery);/* ============================================================ + * bootstrap-button.js v2.2.1 + * http://twitter.github.com/bootstrap/javascript.html#buttons + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* BUTTON PUBLIC CLASS DEFINITION + * ============================== */ + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, $.fn.button.defaults, options) + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + , $el = this.$element + , data = $el.data() + , val = $el.is('input') ? 'val' : 'html' + + state = state + 'Text' + data.resetText || $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d) + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons-radio"]') + + $parent && $parent + .find('.active') + .removeClass('active') + + this.$element.toggleClass('active') + } + + + /* BUTTON PLUGIN DEFINITION + * ======================== */ + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('button') + , options = typeof option == 'object' && option + if (!data) $this.data('button', (data = new Button(this, options))) + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.defaults = { + loadingText: 'loading...' + } + + $.fn.button.Constructor = Button + + + /* BUTTON DATA-API + * =============== */ + + $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + }) + +}(window.jQuery);/* ========================================================== + * bootstrap-carousel.js v2.2.1 + * http://twitter.github.com/bootstrap/javascript.html#carousel + * ========================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* CAROUSEL CLASS DEFINITION + * ========================= */ + + var Carousel = function (element, options) { + this.$element = $(element) + this.options = options + this.options.slide && this.slide(this.options.slide) + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.prototype = { + + cycle: function (e) { + if (!e) this.paused = false + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + return this + } + + , to: function (pos) { + var $active = this.$element.find('.item.active') + , children = $active.parent().children() + , activePos = children.index($active) + , that = this + + if (pos > (children.length - 1) || pos < 0) return + + if (this.sliding) { + return this.$element.one('slid', function () { + that.to(pos) + }) + } + + if (activePos == pos) { + return this.pause().cycle() + } + + return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos])) + } + + , pause: function (e) { + if (!e) this.paused = true + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle() + } + clearInterval(this.interval) + this.interval = null + return this + } + + , next: function () { + if (this.sliding) return + return this.slide('next') + } + + , prev: function () { + if (this.sliding) return + return this.slide('prev') + } + + , slide: function (type, next) { + var $active = this.$element.find('.item.active') + , $next = next || $active[type]() + , isCycling = this.interval + , direction = type == 'next' ? 'left' : 'right' + , fallback = type == 'next' ? 'first' : 'last' + , that = this + , e + + this.sliding = true + + isCycling && this.pause() + + $next = $next.length ? $next : this.$element.find('.item')[fallback]() + + e = $.Event('slide', { + relatedTarget: $next[0] + }) + + if ($next.hasClass('active')) return + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + this.$element.one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') + } + + isCycling && this.cycle() + + return this + } + + } + + + /* CAROUSEL PLUGIN DEFINITION + * ========================== */ + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('carousel') + , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option) + , action = typeof option == 'string' ? option : options.slide + if (!data) $this.data('carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.cycle() + }) + } + + $.fn.carousel.defaults = { + interval: 5000 + , pause: 'hover' + } + + $.fn.carousel.Constructor = Carousel + + + /* CAROUSEL DATA-API + * ================= */ + + $(document).on('click.carousel.data-api', '[data-slide]', function (e) { + var $this = $(this), href + , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + , options = $.extend({}, $target.data(), $this.data()) + $target.carousel(options) + e.preventDefault() + }) + +}(window.jQuery);/* ============================================================= + * bootstrap-collapse.js v2.2.1 + * http://twitter.github.com/bootstrap/javascript.html#collapse + * ============================================================= + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* COLLAPSE PUBLIC CLASS DEFINITION + * ================================ */ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, $.fn.collapse.defaults, options) + + if (this.options.parent) { + this.$parent = $(this.options.parent) + } + + this.options.toggle && this.toggle() + } + + Collapse.prototype = { + + constructor: Collapse + + , dimension: function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + , show: function () { + var dimension + , scroll + , actives + , hasData + + if (this.transitioning) return + + dimension = this.dimension() + scroll = $.camelCase(['scroll', dimension].join('-')) + actives = this.$parent && this.$parent.find('> .accordion-group > .in') + + if (actives && actives.length) { + hasData = actives.data('collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('collapse', null) + } + + this.$element[dimension](0) + this.transition('addClass', $.Event('show'), 'shown') + $.support.transition && this.$element[dimension](this.$element[0][scroll]) + } + + , hide: function () { + var dimension + if (this.transitioning) return + dimension = this.dimension() + this.reset(this.$element[dimension]()) + this.transition('removeClass', $.Event('hide'), 'hidden') + this.$element[dimension](0) + } + + , reset: function (size) { + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + [dimension](size || 'auto') + [0].offsetWidth + + this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') + + return this + } + + , transition: function (method, startEvent, completeEvent) { + var that = this + , complete = function () { + if (startEvent.type == 'show') that.reset() + that.transitioning = 0 + that.$element.trigger(completeEvent) + } + + this.$element.trigger(startEvent) + + if (startEvent.isDefaultPrevented()) return + + this.transitioning = 1 + + this.$element[method]('in') + + $.support.transition && this.$element.hasClass('collapse') ? + this.$element.one($.support.transition.end, complete) : + complete() + } + + , toggle: function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + } + + + /* COLLAPSIBLE PLUGIN DEFINITION + * ============================== */ + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('collapse') + , options = typeof option == 'object' && option + if (!data) $this.data('collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.defaults = { + toggle: true + } + + $.fn.collapse.Constructor = Collapse + + + /* COLLAPSIBLE DATA-API + * ==================== */ + + $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + , target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + , option = $(target).data('collapse') ? 'toggle' : $this.data() + $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + $(target).collapse(option) + }) + +}(window.jQuery);/* ============================================================ + * bootstrap-dropdown.js v2.2.1 + * http://twitter.github.com/bootstrap/javascript.html#dropdowns + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* DROPDOWN CLASS DEFINITION + * ========================= */ + + var toggle = '[data-toggle=dropdown]' + , Dropdown = function (element) { + var $el = $(element).on('click.dropdown.data-api', this.toggle) + $('html').on('click.dropdown.data-api', function () { + $el.parent().removeClass('open') + }) + } + + Dropdown.prototype = { + + constructor: Dropdown + + , toggle: function (e) { + var $this = $(this) + , $parent + , isActive + + if ($this.is('.disabled, :disabled')) return + + $parent = getParent($this) + + isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + $parent.toggleClass('open') + $this.focus() + } + + return false + } + + , keydown: function (e) { + var $this + , $items + , $active + , $parent + , isActive + , index + + if (!/(38|40|27)/.test(e.keyCode)) return + + $this = $(this) + + e.preventDefault() + e.stopPropagation() + + if ($this.is('.disabled, :disabled')) return + + $parent = getParent($this) + + isActive = $parent.hasClass('open') + + if (!isActive || (isActive && e.keyCode == 27)) return $this.click() + + $items = $('[role=menu] li:not(.divider) a', $parent) + + if (!$items.length) return + + index = $items.index($items.filter(':focus')) + + if (e.keyCode == 38 && index > 0) index-- // up + if (e.keyCode == 40 && index < $items.length - 1) index++ // down + if (!~index) index = 0 + + $items + .eq(index) + .focus() + } + + } + + function clearMenus() { + $(toggle).each(function () { + getParent($(this)).removeClass('open') + }) + } + + function getParent($this) { + var selector = $this.attr('data-target') + , $parent + + if (!selector) { + selector = $this.attr('href') + selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = $(selector) + $parent.length || ($parent = $this.parent()) + + return $parent + } + + + /* DROPDOWN PLUGIN DEFINITION + * ========================== */ + + $.fn.dropdown = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('dropdown') + if (!data) $this.data('dropdown', (data = new Dropdown(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.dropdown.Constructor = Dropdown + + + /* APPLY TO STANDARD DROPDOWN ELEMENTS + * =================================== */ + + $(document) + .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) + .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) + .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) + .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) + +}(window.jQuery);/* ========================================================= + * bootstrap-modal.js v2.2.1 + * http://twitter.github.com/bootstrap/javascript.html#modals + * ========================================================= + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================= */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* MODAL CLASS DEFINITION + * ====================== */ + + var Modal = function (element, options) { + this.options = options + this.$element = $(element) + .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) + this.options.remote && this.$element.find('.modal-body').load(this.options.remote) + } + + Modal.prototype = { + + constructor: Modal + + , toggle: function () { + return this[!this.isShown ? 'show' : 'hide']() + } + + , show: function () { + var that = this + , e = $.Event('show') + + this.$element.trigger(e) + + if (this.isShown || e.isDefaultPrevented()) return + + this.isShown = true + + this.escape() + + this.backdrop(function () { + var transition = $.support.transition && that.$element.hasClass('fade') + + if (!that.$element.parent().length) { + that.$element.appendTo(document.body) //don't move modals dom position + } + + that.$element + .show() + + if (transition) { + that.$element[0].offsetWidth // force reflow + } + + that.$element + .addClass('in') + .attr('aria-hidden', false) + + that.enforceFocus() + + transition ? + that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : + that.$element.focus().trigger('shown') + + }) + } + + , hide: function (e) { + e && e.preventDefault() + + var that = this + + e = $.Event('hide') + + this.$element.trigger(e) + + if (!this.isShown || e.isDefaultPrevented()) return + + this.isShown = false + + this.escape() + + $(document).off('focusin.modal') + + this.$element + .removeClass('in') + .attr('aria-hidden', true) + + $.support.transition && this.$element.hasClass('fade') ? + this.hideWithTransition() : + this.hideModal() + } + + , enforceFocus: function () { + var that = this + $(document).on('focusin.modal', function (e) { + if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { + that.$element.focus() + } + }) + } + + , escape: function () { + var that = this + if (this.isShown && this.options.keyboard) { + this.$element.on('keyup.dismiss.modal', function ( e ) { + e.which == 27 && that.hide() + }) + } else if (!this.isShown) { + this.$element.off('keyup.dismiss.modal') + } + } + + , hideWithTransition: function () { + var that = this + , timeout = setTimeout(function () { + that.$element.off($.support.transition.end) + that.hideModal() + }, 500) + + this.$element.one($.support.transition.end, function () { + clearTimeout(timeout) + that.hideModal() + }) + } + + , hideModal: function (that) { + this.$element + .hide() + .trigger('hidden') + + this.backdrop() + } + + , removeBackdrop: function () { + this.$backdrop.remove() + this.$backdrop = null + } + + , backdrop: function (callback) { + var that = this + , animate = this.$element.hasClass('fade') ? 'fade' : '' + + if (this.isShown && this.options.backdrop) { + var doAnimate = $.support.transition && animate + + this.$backdrop = $('