From a6d6c880f909af56e345eff1bd33db4c4b76b63d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 12:08:03 +0100 Subject: Updates some needed attributes of old installations. closes #32 --- db/migrate/20121228101454_update_tenant_id.rb | 12 ++++++++++++ db/schema.rb | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20121228101454_update_tenant_id.rb diff --git a/db/migrate/20121228101454_update_tenant_id.rb b/db/migrate/20121228101454_update_tenant_id.rb new file mode 100644 index 0000000..5c46b04 --- /dev/null +++ b/db/migrate/20121228101454_update_tenant_id.rb @@ -0,0 +1,12 @@ +class UpdateTenantId < ActiveRecord::Migration + def up + Phone.where(:hot_deskable => true).each do |phone| + phone.tenant_id = Tenant.last.id + 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| -- cgit v1.2.3 From e19843740a9c45c47d6dd65bc337353bb6826d4d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 12:45:14 +0100 Subject: Fixed validation. --- app/models/phone.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From 9190c997fe17ed1c680d2b073c8d2e21ac864b57 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 12:57:24 +0100 Subject: Update some Phone attributes. Which where introduced with 9101b20cc5ca4e0553cfb4a503f0d2d51863ba37 --- db/migrate/20121228101454_update_tenant_id.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20121228101454_update_tenant_id.rb b/db/migrate/20121228101454_update_tenant_id.rb index 5c46b04..dc2f37c 100644 --- a/db/migrate/20121228101454_update_tenant_id.rb +++ b/db/migrate/20121228101454_update_tenant_id.rb @@ -1,7 +1,11 @@ class UpdateTenantId < ActiveRecord::Migration def up - Phone.where(:hot_deskable => true).each do |phone| + 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 -- cgit v1.2.3 From 3b07751150c0cd70eee4e750dd7a3670120a8675 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 19:31:31 +0100 Subject: Fallback SIP Accounts are only shown when the hotdeskable field is checked. --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/phones.js.coffee | 5 +++++ app/controllers/phones_controller.rb | 6 ++++-- app/views/layouts/application.html.haml | 1 - app/views/phones/_form_core.html.haml | 8 +++++--- app/views/phones/show.html.haml | 14 +++++++------- 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 app/assets/javascripts/phones.js.coffee 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..b23a589 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -13,9 +13,11 @@ 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 + 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) + @phone = @phoneable.phones.build() + # Use the last phone.phone_model as the default. # @phone.phone_model_id = Phone.last.try(:phone_model).try(:id) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f2aff0a..8ab9039 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'} diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml index 96e53e6..20ea054 100644 --- a/app/views/phones/_form_core.html.haml +++ b/app/views/phones/_form_core.html.haml @@ -1,8 +1,10 @@ .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.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/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 -- cgit v1.2.3 From 1985d77138ec8c3efe01673d019947a6cd3361af Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 20:01:29 +0100 Subject: Improved the UI for a new phone. --- app/views/phones/_form_core.html.haml | 3 ++- app/views/phones/new.html.haml | 6 ++++++ config/locales/views/phones/de.yml | 1 + config/locales/views/phones/en.yml | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml index 20ea054..fd69690 100644 --- a/app/views/phones/_form_core.html.haml +++ b/app/views/phones/_form_core.html.haml @@ -1,10 +1,11 @@ .inputs - = f.input :mac_address, :label => t('phones.form.mac_address.label'), :hint => conditional_hint('phones.form.mac_address.hint') + = 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/config/locales/views/phones/de.yml b/config/locales/views/phones/de.yml index 2b655bd..e8221a9 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 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: -- cgit v1.2.3 From 2cfe480a334019619d243823c030b9315cb3ea2a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 20:10:36 +0100 Subject: Refactored the controller. --- app/controllers/phones_controller.rb | 12 ++++++++---- config/locales/views/phones/de.yml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index b23a589..f1dcd3e 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -13,8 +13,7 @@ class PhonesController < ApplicationController end def new - 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) + set_fallback_sip_accounts @phone = @phoneable.phones.build() @@ -33,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 @@ -77,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/config/locales/views/phones/de.yml b/config/locales/views/phones/de.yml index e8221a9..dafe279 100644 --- a/config/locales/views/phones/de.yml +++ b/config/locales/views/phones/de.yml @@ -42,7 +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 SIP-Account, damit die Option für Hotdesking in diesem Formular angezeigt wird. ' + 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: -- cgit v1.2.3 From 43ed8d1b73fe9e1d7ec93ca1d5264fe62d1cdbdb Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 20:18:36 +0100 Subject: Added the version number in the footer. closes #9 --- app/views/layouts/application.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8ab9039..2c7faec 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -32,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 -- cgit v1.2.3 From 8d20201910b1915cffa495e6474d50f9c8e8331d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 28 Dec 2012 20:26:00 +0100 Subject: Release 5.0.1 --- 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 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 -- cgit v1.2.3