summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2012-12-29 17:42:35 +0100
committerspag <spag@golwen.net>2012-12-29 17:42:35 +0100
commit5cf46b6467679ea0367cc0c00787f6f1c86560e4 (patch)
treeb3f314d1ba574e328f1ce5a27aeadb6ae32980d5
parent929e7a391f139ed827e9bd3bea339789a82de6d4 (diff)
parent8d20201910b1915cffa495e6474d50f9c8e8331d (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
-rw-r--r--app/assets/javascripts/application.js1
-rw-r--r--app/assets/javascripts/phones.js.coffee5
-rw-r--r--app/controllers/phones_controller.rb14
-rw-r--r--app/models/phone.rb2
-rw-r--r--app/views/layouts/application.html.haml7
-rw-r--r--app/views/phones/_form_core.html.haml11
-rw-r--r--app/views/phones/new.html.haml6
-rw-r--r--app/views/phones/show.html.haml14
-rw-r--r--config/initializers/gemeinschaft_parameters.rb2
-rw-r--r--config/locales/views/phones/de.yml1
-rw-r--r--config/locales/views/phones/en.yml1
-rw-r--r--db/migrate/20121228101454_update_tenant_id.rb16
-rw-r--r--db/schema.rb4
13 files changed, 63 insertions, 21 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 2e0b0d8..1762043 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -10,4 +10,5 @@
//= require vendor/modernizr-2.0.6.min.js
//= require vendor/jquery.condom.js
//= require vendor/jquery.survival-kit
+//= require phones
//= require softkeys
diff --git a/app/assets/javascripts/phones.js.coffee b/app/assets/javascripts/phones.js.coffee
new file mode 100644
index 0000000..ff54777
--- /dev/null
+++ b/app/assets/javascripts/phones.js.coffee
@@ -0,0 +1,5 @@
+jQuery ->
+ $(".fallback_sip_account_dropdown").hide()
+
+ $("#phone_hot_deskable").change ->
+ $(".fallback_sip_account_dropdown").show("slow")
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb
index b865cb1..f1dcd3e 100644
--- a/app/controllers/phones_controller.rb
+++ b/app/controllers/phones_controller.rb
@@ -13,9 +13,10 @@ 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
+ set_fallback_sip_accounts
+
@phone = @phoneable.phones.build()
+
# Use the last phone.phone_model as the default.
#
@phone.phone_model_id = Phone.last.try(:phone_model).try(:id)
@@ -31,13 +32,13 @@ class PhonesController < ApplicationController
m = method( :"#{@phoneable.class.name.underscore}_phone_path" )
redirect_to m.( @phoneable, @phone ), :notice => t('phones.controller.successfuly_created')
else
+ set_fallback_sip_accounts
render :new
end
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
+ set_fallback_sip_accounts
end
def update
@@ -75,5 +76,10 @@ class PhonesController < ApplicationController
add_breadcrumb @phone, method( :"#{@phone.phoneable.class.name.underscore}_phone_path" ).(@phone.phoneable, @phone)
end
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)
+ end
end
diff --git a/app/models/phone.rb b/app/models/phone.rb
index 9e5766a..1f3c497 100644
--- a/app/models/phone.rb
+++ b/app/models/phone.rb
@@ -33,7 +33,7 @@ class Phone < ActiveRecord::Base
validates_presence_of :phone_model
validates_presence_of :phoneable
- validates_uniqueness_of :fallback_sip_account_id
+ validates_uniqueness_of :fallback_sip_account_id, :allow_nil => true
before_save :save_last_ip_address
before_save :destroy_phones_sip_accounts_if_phoneable_changed
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index f2aff0a..2c7faec 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -20,7 +20,6 @@
%body
#container
= render :partial => "shared/header"
- = render :partial => "shared/system_message"
= render :partial => "shared/flash", :locals => { :flash => flash}
#content{:role => 'main'}
@@ -33,14 +32,16 @@
%footer#main
%ul
+ %li
+ %a{:href => "http://amooma.de/gemeinschaft/gs5"} Gemeinschaft #{GEMEINSCHAFT_VERSION}
- if GuiFunction.display?('amooma_commercial_support_link_in_footer', current_user)
%li
- %a{:href => "http://www.amooma.de"} Kommerzieller Support und Consulting
+ %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://www.amooma.de/" } Amooma
+ %a{ :target => '_blank', :href => "http://amooma.de/" } Amooma
diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml
index 96e53e6..fd69690 100644
--- a/app/views/phones/_form_core.html.haml
+++ b/app/views/phones/_form_core.html.haml
@@ -1,8 +1,11 @@
.inputs
- = 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
+ = f.input :mac_address, :label => t('phones.form.mac_address.label'), :hint => conditional_hint('phones.form.mac_address.hint'), :autofocus => true
+ = f.association :phone_model, :label => t('phones.form.phone_model_id.label'), :hint => conditional_hint('phones.form.phone_model_id.hint'), :include_blank => false
+ - if @fallback_sip_accounts.any?
+ = f.input :hot_deskable, :label => t('phones.form.hot_deskable.label'), :hint => conditional_hint('phones.form.hot_deskable.hint')
+ .fallback_sip_account_dropdown
+ = 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 => false
+
- 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/new.html.haml b/app/views/phones/new.html.haml
index 61923cc..ae0a539 100644
--- a/app/views/phones/new.html.haml
+++ b/app/views/phones/new.html.haml
@@ -1,3 +1,9 @@
- title t("phones.new.page_title")
+- if !@fallback_sip_accounts.any? && can?(:create, current_user.current_tenant.sip_accounts.build)
+ %p
+ = t("phones.new.you_need_to_have_at_least_one_available_fallback_sip_account_for_hotdesking")
+ = link_to t("sip_accounts.index.actions.create_for", :resource => current_user.current_tenant), new_tenant_sip_account_path(current_user.current_tenant)
+
= render "form"
+
diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml
index 7629fb9..090323e 100644
--- a/app/views/phones/show.html.haml
+++ b/app/views/phones/show.html.haml
@@ -6,13 +6,13 @@
%p
%strong= t('phones.show.phone_model_id') + ":"
= @phone.phone_model
-%p
- %strong= t('phones.show.hot_deskable') + ":"
- = @phone.hot_deskable
-
-%p
- %strong= t('phones.show.fallback_sip_account_id') + ":"
- = @phone.fallback_sip_account
+- if @phone.hot_deskable == true
+ %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
diff --git a/config/initializers/gemeinschaft_parameters.rb b/config/initializers/gemeinschaft_parameters.rb
index fbe9c56..ffb8fee 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'
+GEMEINSCHAFT_VERSION = '5.0.1'
SUPER_TENANT_NAME = 'Super-Tenant'
# System defaults
diff --git a/config/locales/views/phones/de.yml b/config/locales/views/phones/de.yml
index 2b655bd..dafe279 100644
--- a/config/locales/views/phones/de.yml
+++ b/config/locales/views/phones/de.yml
@@ -42,6 +42,7 @@ de:
new:
page_title: 'Neues Telefon'
actions:
+ you_need_to_have_at_least_one_available_fallback_sip_account_for_hotdesking: 'Sie benötigen mindestens einen nicht benutzen und hotdeskfähigen SIP-Account, damit die Option für Hotdesking in diesem Formular angezeigt wird. '
edit:
page_title: 'Telefondaten bearbeiten'
form:
diff --git a/config/locales/views/phones/en.yml b/config/locales/views/phones/en.yml
index a441e34..ecd5a91 100644
--- a/config/locales/views/phones/en.yml
+++ b/config/locales/views/phones/en.yml
@@ -42,6 +42,7 @@ en:
new:
page_title: 'New phone'
actions:
+ you_need_to_have_at_least_one_available_fallback_sip_account_for_hotdesking: 'You need to have at least one unconnected SIP account to see a hotdesking option in this form. '
edit:
page_title: 'Editing Phone'
form:
diff --git a/db/migrate/20121228101454_update_tenant_id.rb b/db/migrate/20121228101454_update_tenant_id.rb
new file mode 100644
index 0000000..dc2f37c
--- /dev/null
+++ b/db/migrate/20121228101454_update_tenant_id.rb
@@ -0,0 +1,16 @@
+class UpdateTenantId < ActiveRecord::Migration
+ def up
+ Phone.all.each do |phone|
+ phone.tenant_id = Tenant.last.id
+ phone.save
+ end
+
+ Phone.where(:hot_deskable => true).each do |phone|
+ phone.fallback_sip_account = phone.sip_accounts.where(:sip_accountable_type => 'Tenant').first
+ phone.save
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1395e1b..804ff5f 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 => 20121125084447) do
+ActiveRecord::Schema.define(:version => 20121228101454) do
create_table "access_authorizations", :force => true do |t|
t.string "access_authorizationable_type"
@@ -738,6 +738,8 @@ ActiveRecord::Schema.define(:version => 20121125084447) do
t.boolean "nightly_reboot"
t.string "provisioning_key"
t.boolean "provisioning_key_active"
+ t.integer "tenant_id"
+ t.integer "fallback_sip_account_id"
end
create_table "registrations", :id => false, :force => true do |t|