summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/phones_controller.rb4
-rw-r--r--app/models/phone.rb2
-rw-r--r--app/views/phones/_form_core.html.haml1
-rw-r--r--app/views/phones/show.html.haml5
-rw-r--r--config/locales/views/phones/de.yml4
-rw-r--r--config/locales/views/phones/en.yml4
6 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb
index 0b765e8..b865cb1 100644
--- a/app/controllers/phones_controller.rb
+++ b/app/controllers/phones_controller.rb
@@ -13,6 +13,8 @@ class PhonesController < ApplicationController
end
def new
+ used_sip_account_ids = Phone.where('fallback_sip_account_id IS NOT NULL').collect {|r| r.fallback_sip_account }
+ @fallback_sip_accounts = SipAccount.where('sip_accountable_type = "Tenant" AND id NOT IN (?)', used_sip_account_ids).all
@phone = @phoneable.phones.build()
# Use the last phone.phone_model as the default.
#
@@ -34,6 +36,8 @@ class PhonesController < ApplicationController
end
def edit
+ used_sip_account_ids = Phone.where('fallback_sip_account_id IS NOT NULL AND id != ?', @phone.id).collect {|r| r.fallback_sip_account_id }
+ @fallback_sip_accounts = SipAccount.where('sip_accountable_type = "Tenant" AND id NOT IN (?)', used_sip_account_ids).all
end
def update
diff --git a/app/models/phone.rb b/app/models/phone.rb
index bd6e3f6..f78ebe2 100644
--- a/app/models/phone.rb
+++ b/app/models/phone.rb
@@ -4,7 +4,7 @@ class Phone < ActiveRecord::Base
attr_accessible :mac_address, :ip_address, :http_user, :http_password,
:phone_model_id, :hot_deskable, :nightly_reboot,
- :provisioning_key, :provisioning_key_active
+ :provisioning_key, :provisioning_key_active, :fallback_sip_account_id, :tenant
# Associations
#
diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml
index 51ceff5..96e53e6 100644
--- a/app/views/phones/_form_core.html.haml
+++ b/app/views/phones/_form_core.html.haml
@@ -2,6 +2,7 @@
= f.input :mac_address, :label => t('phones.form.mac_address.label'), :hint => conditional_hint('phones.form.mac_address.hint')
= f.association :phone_model, :label => t('phones.form.phone_model_id.label'), :hint => conditional_hint('phones.form.phone_model_id.hint')
= f.input :hot_deskable, :label => t('phones.form.hot_deskable.label'), :hint => conditional_hint('phones.form.hot_deskable.hint')
+ = f.association :fallback_sip_account, :collection => @fallback_sip_accounts, :label => t('phones.form.fallback_sip_account_id.label'), :hint => conditional_hint('phones.form.fallback_sip_account_id.hint'), :include_blank => true
- if defined? NIGHTLY_REBOOT_OF_PHONES && 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
diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml
index 2664ffa..7629fb9 100644
--- a/app/views/phones/show.html.haml
+++ b/app/views/phones/show.html.haml
@@ -9,6 +9,11 @@
%p
%strong= t('phones.show.hot_deskable') + ":"
= @phone.hot_deskable
+
+%p
+ %strong= t('phones.show.fallback_sip_account_id') + ":"
+ = @phone.fallback_sip_account
+
- if defined? NIGHTLY_REBOOT_OF_PHONES && NIGHTLY_REBOOT_OF_PHONES == true
%p
%strong= t('phones.show.nightly_reboot') + ":"
diff --git a/config/locales/views/phones/de.yml b/config/locales/views/phones/de.yml
index 3a0adea..2b655bd 100644
--- a/config/locales/views/phones/de.yml
+++ b/config/locales/views/phones/de.yml
@@ -33,6 +33,7 @@ de:
http_user: 'http user'
http_password: 'http password'
nightly_reboot: 'Nachts automatischer Reboot'
+ fallback_sip_account_id: 'Fallback SIP Account'
actions:
confirm: 'Sind Sie sicher, dass Sie diese Telefon aus Gemeinschaft entfernen möchten?'
destroy: 'Löschen'
@@ -71,6 +72,9 @@ de:
provisioning_key_active:
label: 'Provisioning Schlüssel aktiv'
hint: ''
+ fallback_sip_account_id:
+ label: 'Fallback SIP Account'
+ hint: ''
button: 'Absenden'
sip_accounts:
title: 'Auf dem Telefon eingetragene SIP-Konten'
diff --git a/config/locales/views/phones/en.yml b/config/locales/views/phones/en.yml
index afcf9b5..a441e34 100644
--- a/config/locales/views/phones/en.yml
+++ b/config/locales/views/phones/en.yml
@@ -33,6 +33,7 @@ en:
http_password: 'http password'
nightly_reboot: 'Nightly reboot'
provisioning_key_active: 'Provisioning key active'
+ fallback_sip_account_id: 'Fallback SIP Account'
actions:
confirm: 'Are you sure you want to delete this phone?'
destroy: 'Delete phone'
@@ -71,6 +72,9 @@ en:
provisioning_key_active:
label: 'Provisioning key active'
hint: ''
+ fallback_sip_account_id:
+ label: 'Fallback SIP Account'
+ hint: ''
button: 'Submit'
sip_accounts:
title: 'Listing of connected SIP accounts'