From 3833ac1506fb336cd617ec41d25e35c34e74064e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Mar 2013 15:51:35 +0100 Subject: voicemail refactored --- app/controllers/sip_accounts_controller.rb | 7 ++ app/controllers/voicemail_accounts_controller.rb | 68 +++++++++++ app/controllers/voicemail_settings_controller.rb | 85 ++++--------- app/helpers/voicemail_accounts_helper.rb | 2 + app/models/sip_account.rb | 24 +--- app/models/user.rb | 2 + app/models/voicemail_account.rb | 20 +++ app/models/voicemail_setting.rb | 52 ++++++-- app/views/sip_accounts/_form_core.html.haml | 1 + app/views/sip_accounts/show.html.haml | 5 + app/views/voicemail_accounts/_form.html.haml | 7 ++ app/views/voicemail_accounts/_form_core.html.haml | 3 + app/views/voicemail_accounts/_index_core.html.haml | 15 +++ app/views/voicemail_accounts/edit.html.haml | 3 + app/views/voicemail_accounts/index.html.haml | 6 + app/views/voicemail_accounts/new.html.haml | 3 + app/views/voicemail_accounts/show.html.haml | 19 +++ app/views/voicemail_settings/_form.html.haml | 3 +- app/views/voicemail_settings/_form_core.html.haml | 17 ++- app/views/voicemail_settings/_index_core.html.haml | 14 +++ app/views/voicemail_settings/edit.html.haml | 2 +- app/views/voicemail_settings/index.html.haml | 6 + app/views/voicemail_settings/new.html.haml | 3 + app/views/voicemail_settings/show.html.haml | 33 ++--- config/locales/views/voicemail_accounts/de.yml | 65 ++++++++++ config/locales/views/voicemail_accounts/en.yml | 65 ++++++++++ config/locales/views/voicemail_settings/de.yml | 83 ++++++++----- config/locales/views/voicemail_settings/en.yml | 91 ++++++++------ .../20130322081621_create_voicemail_accounts.rb | 17 +++ ...533_add_voicemail_account_id_to_sip_accounts.rb | 5 + .../20130326064557_create_voicemail_settings.rb | 16 +++ misc/freeswitch/conf/freeswitch.xml | 136 +++++++++++++++++++++ test/unit/voicemail_account_test.rb | 7 ++ 33 files changed, 695 insertions(+), 190 deletions(-) create mode 100644 app/controllers/voicemail_accounts_controller.rb create mode 100644 app/helpers/voicemail_accounts_helper.rb create mode 100644 app/models/voicemail_account.rb create mode 100644 app/views/voicemail_accounts/_form.html.haml create mode 100644 app/views/voicemail_accounts/_form_core.html.haml create mode 100644 app/views/voicemail_accounts/_index_core.html.haml create mode 100644 app/views/voicemail_accounts/edit.html.haml create mode 100644 app/views/voicemail_accounts/index.html.haml create mode 100644 app/views/voicemail_accounts/new.html.haml create mode 100644 app/views/voicemail_accounts/show.html.haml create mode 100644 app/views/voicemail_settings/_index_core.html.haml create mode 100644 app/views/voicemail_settings/index.html.haml create mode 100644 app/views/voicemail_settings/new.html.haml create mode 100644 config/locales/views/voicemail_accounts/de.yml create mode 100644 config/locales/views/voicemail_accounts/en.yml create mode 100644 db/migrate/20130322081621_create_voicemail_accounts.rb create mode 100644 db/migrate/20130322102533_add_voicemail_account_id_to_sip_accounts.rb create mode 100644 db/migrate/20130326064557_create_voicemail_settings.rb create mode 100644 test/unit/voicemail_account_test.rb diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 0d34109..8208a29 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -36,6 +36,7 @@ class SipAccountsController < ApplicationController break unless SipAccount.exists?(:auth_name => @sip_account.auth_name) end @sip_account.password = SecureRandom.hex(GsParameter.get('DEFAULT_LENGTH_SIP_PASSWORD')) + possible_voicemail_accounts end def create @@ -61,6 +62,7 @@ class SipAccountsController < ApplicationController end def edit + possible_voicemail_accounts end def update @@ -101,4 +103,9 @@ class SipAccountsController < ApplicationController end end + def possible_voicemail_accounts + @possible_voicemail_accounts = @sip_account.voicemail_accounts + @possible_voicemail_accounts = @possible_voicemail_accounts + @sip_account.sip_accountable.voicemail_accounts + end + end diff --git a/app/controllers/voicemail_accounts_controller.rb b/app/controllers/voicemail_accounts_controller.rb new file mode 100644 index 0000000..7e00131 --- /dev/null +++ b/app/controllers/voicemail_accounts_controller.rb @@ -0,0 +1,68 @@ +class VoicemailAccountsController < ApplicationController + load_resource :sip_account + load_resource :conference + load_resource :hunt_group + load_resource :automatic_call_distributor + load_resource :user + load_resource :tenant + load_resource :voicemail_account + + load_and_authorize_resource :phone_number, :through => [:sip_account, :conference, :hunt_group, :automatic_call_distributor, :user, :tenant] + + before_filter :set_and_authorize_parent + + def index + @voicemail_accounts = @parent.voicemail_accounts + end + + def show + + end + + def new + @voicemail_account = @parent.voicemail_accounts.build(:active => true) + if @parent.class == SipAccount && VoicemailAccount.where(:name => @parent.auth_name).count == 0 + @voicemail_account.name = @parent.auth_name + else + @voicemail_account.name = SecureRandom.hex(GsParameter.get('DEFAULT_LENGTH_SIP_AUTH_NAME')) + end + end + + def create + @voicemail_account = @parent.voicemail_accounts.new(params[:voicemail_account]) + if @voicemail_account.save + m = method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ) + redirect_to m.( @parent ), :notice => t('voicemail_accounts.controller.successfuly_created') + else + render :new + end + end + + def edit + @voicemail_account = VoicemailAccount.find(params[:id]) + end + + def update + @voicemail_account = VoicemailAccount.find(params[:id]) + if @voicemail_account.update_attributes(params[:voicemail_account]) + m = method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ) + redirect_to m.( @parent ), :notice => t('voicemail_accounts.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @voicemail_account = VoicemailAccount.find(params[:id]) + @voicemail_account.destroy + m = method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ) + redirect_to m.( @parent ), :notice => t('voicemail_accounts.controller.successfuly_destroyed') + end + + private + def set_and_authorize_parent + @parent = @sip_account || @conference || @hunt_group || @automatic_call_distributor || @user || @tenant + + authorize! :read, @parent + end +end diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb index 5de0c35..ee8e36b 100644 --- a/app/controllers/voicemail_settings_controller.rb +++ b/app/controllers/voicemail_settings_controller.rb @@ -1,92 +1,53 @@ class VoicemailSettingsController < ApplicationController - load_resource :sip_account - load_and_authorize_resource :voicemail_setting, :through => :sip_account, :singleton => true - - before_filter :set_and_authorize_parent - before_filter :spread_breadcrumbs - before_filter :voicemail_defaults, :only => [:index, :show, :new, :create, :edit] + load_and_authorize_resource :voicemail_account + load_and_authorize_resource :voicemail_setting, :through => [:voicemail_account] def index - render :edit + @voicemail_settings = @voicemail_account.voicemail_settings end def show - render :edit end def new - render :edit end def create - @sip_account = SipAccount.where(:id => params[:sip_account_id]).first - params[:voicemail_setting][:username] = @sip_account.auth_name - params[:voicemail_setting][:domain] = @sip_account.sip_domain.try(:host) - @voicemail_setting = VoicemailSetting.new(params[:voicemail_setting]) + @voicemail_setting = @voicemail_account.voicemail_settings.build(params[:voicemail_setting]) + @voicemail_setting.class_type = VoicemailSetting::VOICEMAIL_SETTINGS[@voicemail_setting.name] if @voicemail_setting.save - redirect_to sip_account_voicemail_settings_path(@sip_account), :notice => t('voicemail_settings.controller.successfuly_created') + m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) + redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_created') else - render :action => 'edit' + render :new end end def edit - + @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) + @no_edit = { + :name => { + :input => VoicemailSetting::VOICEMAIL_SETTINGS[@voicemail_setting.name][:input], + :name => @voicemail_setting.name + }, + :description => true + } end def update + @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) if @voicemail_setting.update_attributes(params[:voicemail_setting]) - redirect_to sip_account_voicemail_settings_path(@sip_account), :notice => t('voicemail_settings.controller.successfuly_updated') + m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) + redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_updated') else render :edit end end def destroy - - end - - private - def set_and_authorize_parent - @parent = @sip_account - - authorize! :read, @parent - - @show_path_method = method( :"#{@parent.class.name.underscore}_voicemail_setting_path" ) - @index_path_method = method( :"#{@parent.class.name.underscore}_voicemail_settings_path" ) - @new_path_method = method( :"new_#{@parent.class.name.underscore}_voicemail_setting_path" ) - @edit_path_method = method( :"edit_#{@parent.class.name.underscore}_voicemail_setting_path" ) - end - - def spread_breadcrumbs - if @parent.class == SipAccount - if @sip_account.sip_accountable.class == User - add_breadcrumb t("#{@sip_account.sip_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore.pluralize}_path" ).(@sip_account.tenant) - add_breadcrumb @sip_account.sip_accountable, method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore}_path" ).(@sip_account.tenant, @sip_account.sip_accountable) - end - add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_accounts_path" ).(@sip_account.sip_accountable) - add_breadcrumb @sip_account, method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_account_path" ).(@sip_account.sip_accountable, @sip_account) - add_breadcrumb t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(@sip_account) - end - end - - def voicemail_defaults - storage_dir = GsParameter.where(:entity => 'voicemail', :section => 'parameters', :name => 'storage-dir').first.try(:value) - path = "#{storage_dir}/#{@sip_account.sip_domain.host}/#{@sip_account.auth_name}/" - @greeting_files = Dir.glob("#{path}*greeting*.wav").collect {|r| [ File.basename(r), File.expand_path(r) ] } - @name_files = Dir.glob("#{path}*name*.wav").collect {|r| [ File.basename(r), File.expand_path(r) ] } - - if @voicemail_setting.blank? then - @voicemail_setting = @sip_account.voicemail_setting - end - - if @voicemail_setting.blank? - @voicemail_setting = VoicemailSetting.new - @voicemail_setting.notify = true - @voicemail_setting.attachment = true - @voicemail_setting.mark_read = true - @voicemail_setting.purge = false - end + @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) + @voicemail_setting.destroy + m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) + redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_destroyed') end - end diff --git a/app/helpers/voicemail_accounts_helper.rb b/app/helpers/voicemail_accounts_helper.rb new file mode 100644 index 0000000..5a75e18 --- /dev/null +++ b/app/helpers/voicemail_accounts_helper.rb @@ -0,0 +1,2 @@ +module VoicemailAccountsHelper +end diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 0c923be..77fe87a 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -6,7 +6,8 @@ class SipAccount < ActiveRecord::Base attr_accessible :auth_name, :caller_name, :password, :voicemail_pin, :tenant_id, :call_waiting, :clir, :clip_no_screening, :clip, :description, :callforward_rules_act_per_sip_account, - :hotdeskable, :gs_node_id, :language_code + :hotdeskable, :gs_node_id, :language_code, :voicemail_account_id + # Associations: # @@ -27,8 +28,6 @@ class SipAccount < ActiveRecord::Base has_many :call_histories, :as => :call_historyable, :dependent => :destroy - has_one :voicemail_setting, :class_name => "VoicemailSetting", :primary_key => 'auth_name', :foreign_key => 'username', :dependent => :destroy - belongs_to :gs_node belongs_to :language, :foreign_key => 'language_code', :primary_key => 'code' @@ -44,6 +43,9 @@ class SipAccount < ActiveRecord::Base has_many :acd_agents, :as => :destination, :dependent => :destroy has_many :switchboard_entries, :dependent => :destroy + has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + belongs_to :voicemail_account + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true @@ -58,15 +60,11 @@ class SipAccount < ActiveRecord::Base validate_sip_password :password - validates_format_of :voicemail_pin, :with => /[0-9]+/, - :allow_nil => true, :allow_blank => true - validates_uniqueness_of :auth_name, :scope => :sip_domain_id # Before and after hooks: # before_save :save_value_of_to_s - after_save :create_voicemail_setting, :if => :'voicemail_setting == nil' before_validation :find_and_set_tenant_id before_validation :set_sip_domain_id before_validation :convert_umlauts_in_caller_name @@ -279,18 +277,6 @@ class SipAccount < ActiveRecord::Base end end - def create_voicemail_setting - voicemail_setting = VoicemailSetting.new() - voicemail_setting.username = self.auth_name - voicemail_setting.domain = self.sip_domain.try(:host) - voicemail_setting.password = self.voicemail_pin - voicemail_setting.notify = true - voicemail_setting.attachment = true - voicemail_setting.mark_read = true - voicemail_setting.purge = false - voicemail_setting.save - end - def create_default_group_memberships default_groups = Hash.new() templates = GsParameter.get('SipAccount', 'group', 'default') diff --git a/app/models/user.rb b/app/models/user.rb index b74fc06..81d1622 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -94,6 +94,8 @@ class User < ActiveRecord::Base has_many :switchboards, :dependent => :destroy + has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + # Avatar like photo mount_uploader :image, ImageUploader diff --git a/app/models/voicemail_account.rb b/app/models/voicemail_account.rb new file mode 100644 index 0000000..02dc283 --- /dev/null +++ b/app/models/voicemail_account.rb @@ -0,0 +1,20 @@ +class VoicemailAccount < ActiveRecord::Base + attr_accessible :uuid, :name, :active, :gs_node_id, :voicemail_accountable_type, :voicemail_accountable_id + + belongs_to :voicemail_accountable, :polymorphic => true + has_many :voicemail_settings + + validates :name, + :presence => true, + :uniqueness => true + + validates :voicemail_accountable_id, + :presence => true + + validates :voicemail_accountable_type, + :presence => true + + def to_s + "#{voicemail_accountable.to_s}: #{name}" + end +end diff --git a/app/models/voicemail_setting.rb b/app/models/voicemail_setting.rb index a8bb304..4a9fbc9 100644 --- a/app/models/voicemail_setting.rb +++ b/app/models/voicemail_setting.rb @@ -1,12 +1,48 @@ -class VoicemailSetting < ActiveRecord::Base - self.table_name = 'voicemail_prefs' - self.primary_key = 'username' +class VoicemailSetting < ActiveRecord::Base + CLASS_TYPES = ['String', 'Integer', 'Boolean'] + VOICEMAIL_SETTINGS = { + 'password' => { :type => 'String', :characters => /[^0-9]/, :input => :password }, + 'notify' => { :type => 'Boolean', :input => :boolean }, + 'attachment' => { :type => 'Boolean', :input => :boolean }, + 'mark_read' => { :type => 'Boolean', :input => :boolean }, + 'purge' => { :type => 'Boolean', :input => :boolean }, + 'record_length_max' => { :type => 'Integer', :input => :integer }, + 'record_length_min' => { :type => 'Integer', :input => :integer }, + 'records_max' => { :type => 'Integer', :input => :integer }, + } - attr_accessible :username, :domain, :name_path, :greeting_path, :password, :notify, :attachment, :mark_read, :purge, :sip_account + attr_accessible :voicemail_account_id, :name, :value, :class_type, :description - has_one :sip_account, :foreign_key => 'auth_name' + belongs_to :voicemail_account - validates_presence_of :username - validates_presence_of :domain - validates :username, :uniqueness => {:scope => :domain} + validates :name, + :presence => true, + :uniqueness => {:scope => :voicemail_account_id} + + validates :class_type, + :presence => true, + :inclusion => { :in => CLASS_TYPES } + + before_validation :set_class_type_and_value + + def to_s + name + end + + def set_class_type_and_value + seting_pref = VOICEMAIL_SETTINGS[self.name] + if seting_pref + self.class_type = seting_pref[:type] + case self.class_type + when 'String' + if seting_pref[:characters] && self.class_type == 'String' + self.value = self.value.to_s.gsub(seting_pref[:characters], '') + end + when 'Integer' + self.value = self.value.to_i + when 'Boolean' + self.value = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(self.value) + end + end + end end diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index d7c65d0..2e4882e 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -14,3 +14,4 @@ = 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') = f.input :language_code, :collection => Language.all.collect{|l| [l.to_s, l.code]}, :label => t('sip_accounts.form.language_code.label'), :hint => conditional_hint('sip_accounts.form.language_id.hint'), :include_blank => false + = f.input :voicemail_account_id, :collection => @possible_voicemail_accounts.collect{|l| [l.to_s, l.id]}, :label => t('sip_accounts.form.voicemail_account_id.label'), :hint => conditional_hint('voicemail_accounts.form.sip_account_id.hint'), :include_blank => true diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index e79907f..a7cd3ce 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -37,6 +37,11 @@ %strong= t('sip_accounts.show.hotdeskable') + ":" %td = @sip_account.hotdeskable == true ? t('simple_form.yes') : t('simple_form.no') + %tr + %td + %strong= t('sip_accounts.show.voicemail_account') + ":" + %td + = @sip_account.voicemail_account - if @sip_account.registration.try(:network_ip) && @sip_account.registration.try(:network_port) %tr diff --git a/app/views/voicemail_accounts/_form.html.haml b/app/views/voicemail_accounts/_form.html.haml new file mode 100644 index 0000000..1e5ffc0 --- /dev/null +++ b/app/views/voicemail_accounts/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for([@parent, @voicemail_account]) do |f| + = f.error_notification + + = render "form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('voicemail_accounts.form.submit') diff --git a/app/views/voicemail_accounts/_form_core.html.haml b/app/views/voicemail_accounts/_form_core.html.haml new file mode 100644 index 0000000..a13ae51 --- /dev/null +++ b/app/views/voicemail_accounts/_form_core.html.haml @@ -0,0 +1,3 @@ +.inputs + = f.input :name, :label => t('voicemail_accounts.form.name.label'), :hint => conditional_hint('voicemail_accounts.form.name.hint') + = f.input :active, :label => t('voicemail_accounts.form.active.label'), :hint => conditional_hint('voicemail_accounts.form.active.hint') diff --git a/app/views/voicemail_accounts/_index_core.html.haml b/app/views/voicemail_accounts/_index_core.html.haml new file mode 100644 index 0000000..908c2b4 --- /dev/null +++ b/app/views/voicemail_accounts/_index_core.html.haml @@ -0,0 +1,15 @@ +%table.table.table-striped + %tr + %th + %th= t('voicemail_accounts.index.name') + + + - for voicemail_account in voicemail_accounts + %tr + %td + - if voicemail_account.active + %i.icon-ok + - else + %i.icon-ban-circle + %td= voicemail_account.name + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_account.voicemail_accountable, :child => voicemail_account} \ No newline at end of file diff --git a/app/views/voicemail_accounts/edit.html.haml b/app/views/voicemail_accounts/edit.html.haml new file mode 100644 index 0000000..8d1518e --- /dev/null +++ b/app/views/voicemail_accounts/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("voicemail_accounts.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/voicemail_accounts/index.html.haml b/app/views/voicemail_accounts/index.html.haml new file mode 100644 index 0000000..2bc8ae4 --- /dev/null +++ b/app/views/voicemail_accounts/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("voicemail_accounts.index.page_title") + +- if @voicemail_accounts && @voicemail_accounts.count > 0 + = render "index_core", :voicemail_accounts => @voicemail_accounts + += render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => VoicemailAccount} \ No newline at end of file diff --git a/app/views/voicemail_accounts/new.html.haml b/app/views/voicemail_accounts/new.html.haml new file mode 100644 index 0000000..193779d --- /dev/null +++ b/app/views/voicemail_accounts/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("voicemail_accounts.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/voicemail_accounts/show.html.haml b/app/views/voicemail_accounts/show.html.haml new file mode 100644 index 0000000..06b4d1a --- /dev/null +++ b/app/views/voicemail_accounts/show.html.haml @@ -0,0 +1,19 @@ +- content_for :title, t("voicemail_accounts.show.page_title") + +%p + %strong= t('voicemail_accounts.show.uuid') + ":" + = @voicemail_account.uuid +%p + %strong= t('voicemail_accounts.show.name') + ":" + = @voicemail_account.name +%p + %strong= t('voicemail_accounts.show.active') + ":" + = @voicemail_account.active + += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @voicemail_account } + +%h3= t('voicemail_settings.index.page_title') +- if @voicemail_account.voicemail_settings.any? + = render "voicemail_settings/index_core", :voicemail_settings => @voicemail_account.voicemail_settings + %br += render :partial => 'shared/create_link', :locals => { :parent => @voicemail_account, :child_class => VoicemailSetting } \ No newline at end of file diff --git a/app/views/voicemail_settings/_form.html.haml b/app/views/voicemail_settings/_form.html.haml index cd43b2d..08fc37b 100644 --- a/app/views/voicemail_settings/_form.html.haml +++ b/app/views/voicemail_settings/_form.html.haml @@ -1,4 +1,5 @@ -= simple_form_for([@sip_account,@voicemail_setting]) do |f| + += simple_form_for([@voicemail_account, @voicemail_setting]) do |f| = f.error_notification = render "form_core", :f => f diff --git a/app/views/voicemail_settings/_form_core.html.haml b/app/views/voicemail_settings/_form_core.html.haml index 08bdfc2..bf47e46 100644 --- a/app/views/voicemail_settings/_form_core.html.haml +++ b/app/views/voicemail_settings/_form_core.html.haml @@ -1,11 +1,10 @@ .inputs + - if !@no_edit or !@no_edit[:name] + = f.input :name, :collection => VoicemailSetting::VOICEMAIL_SETTINGS.keys.collect{|i, k| [t("voicemail_settings.settings.#{i}"), i]}, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :autofocus => true, :include_blank => false + = f.input :value, :label => t('voicemail_settings.form.value.label'), :hint => conditional_hint('voicemail_settings.form.value.hint') + - else + = f.input :value, :label => t("voicemail_settings.settings.#{@no_edit[:name][:name]}"), :hint => conditional_hint('voicemail_settings.form.value.hint'), :as => @no_edit[:name][:input] - = f.input :greeting_path, :as => :select, :label => t('voicemail_settings.form.greeting.label'), :hint => conditional_hint('voicemail_settings.form.greeting.hint'), :collection => @greeting_files - = f.input :name_path, :as => :select, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :collection => @name_files - - = f.input :password, :label => t('voicemail_settings.form.pin.label'), :hint => conditional_hint('voicemail_settings.form.pin.hint') - - = f.input :notify, :as => :boolean, :label => t('voicemail_settings.form.notify.label'), :hint => conditional_hint('voicemail_settings.form.notify.hint') - = f.input :attachment, :as => :boolean, :label => t('voicemail_settings.form.attachment.label'), :hint => conditional_hint('voicemail_settings.form.attachment.hint') - = f.input :mark_read, :as => :boolean, :label => t('voicemail_settings.form.mark_read.label'), :hint => conditional_hint('voicemail_settings.form.mark_read.hint') - = f.input :purge, :as => :boolean, :label => t('voicemail_settings.form.purge.label'), :hint => conditional_hint('voicemail_settings.form.purge.hint') + - if !@no_edit or !@no_edit[:description] + = f.input :description, :label => t('voicemail_settings.form.description.label'), :hint => conditional_hint('voicemail_settings.form.description.hint') + diff --git a/app/views/voicemail_settings/_index_core.html.haml b/app/views/voicemail_settings/_index_core.html.haml new file mode 100644 index 0000000..94ebfb1 --- /dev/null +++ b/app/views/voicemail_settings/_index_core.html.haml @@ -0,0 +1,14 @@ +%table.table.table-striped + %thead + %tr + %th= t('voicemail_settings.index.name') + %th= t('voicemail_settings.index.value') + %th= t('voicemail_settings.index.description') + + %tbody + - for voicemail_setting in voicemail_settings + %tr + %td= voicemail_setting.name + %td= voicemail_setting.value + %td= voicemail_setting.description + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_setting.voicemail_account, :child => voicemail_setting} diff --git a/app/views/voicemail_settings/edit.html.haml b/app/views/voicemail_settings/edit.html.haml index 56e5765..cb9924b 100644 --- a/app/views/voicemail_settings/edit.html.haml +++ b/app/views/voicemail_settings/edit.html.haml @@ -1,3 +1,3 @@ - content_for :title, t("voicemail_settings.edit.page_title") -= render "form" += render "form" \ No newline at end of file diff --git a/app/views/voicemail_settings/index.html.haml b/app/views/voicemail_settings/index.html.haml new file mode 100644 index 0000000..5eb9940 --- /dev/null +++ b/app/views/voicemail_settings/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("voicemail_settings.index.page_title") + +- if @voicemail_settings && @voicemail_settings.count > 0 + = render "index_core", :voicemail_settings => @voicemail_settings + += render :partial => 'shared/create_link', :locals => {:parent => @voicemail_account, :child_class => VoicemailSetting} diff --git a/app/views/voicemail_settings/new.html.haml b/app/views/voicemail_settings/new.html.haml new file mode 100644 index 0000000..6eddc39 --- /dev/null +++ b/app/views/voicemail_settings/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("voicemail_settings.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/voicemail_settings/show.html.haml b/app/views/voicemail_settings/show.html.haml index e156d7b..f1a3e61 100644 --- a/app/views/voicemail_settings/show.html.haml +++ b/app/views/voicemail_settings/show.html.haml @@ -1,26 +1,19 @@ - content_for :title, t("voicemail_settings.show.page_title") %p - %strong= t('voicemail_settings.show.greeting_path') + ":" - = File.basename(@voicemail_setting.greeting_path.to_s) - + %strong= t('voicemail_settings.show.voicemail_id') + ":" + = @voicemail_setting.voicemail %p - %strong= t('voicemail_settings.show.name_path') + ":" - = File.basename(@voicemail_setting.name_path.to_s) - + %strong= t('voicemail_settings.show.name') + ":" + = @voicemail_setting.name +%p + %strong= t('voicemail_settings.show.value') + ":" + = @voicemail_setting.value +%p + %strong= t('voicemail_settings.show.class_type') + ":" + = @voicemail_setting.class_type %p - %strong= t('voicemail_settings.show.flags') + ":" - - if @voicemail_setting.notify - %br - = "- " + t('voicemail_settings.show.notify') - - if @voicemail_setting.attachment - %br - = "- " + t('voicemail_settings.show.attachment') - - if @voicemail_setting.mark_read - %br - = "- " + t('voicemail_settings.show.mark_read') - - if @voicemail_setting.purge - %br - = "- " + t('voicemail_settings.show.purge') + %strong= t('voicemail_settings.show.description') + ":" + = @voicemail_setting.description -= link_to t('voicemail_settings.actions.edit'), edit_sip_account_voicemail_setting_path(@sip_account, @voicemail_setting) += render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @voicemail_setting.voicemail_account, :child => @voicemail_setting} \ No newline at end of file diff --git a/config/locales/views/voicemail_accounts/de.yml b/config/locales/views/voicemail_accounts/de.yml new file mode 100644 index 0000000..989848b --- /dev/null +++ b/config/locales/views/voicemail_accounts/de.yml @@ -0,0 +1,65 @@ +de: + voicemail_accounts: + name: 'Voicemailaccount' + controller: + successfuly_created: 'Voicemailaccount wurde angelegt.' + successfuly_updated: 'Voicemailaccount wurde aktualisiert.' + successfuly_destroyed: 'Voicemailaccount wurde gelöscht.' + index: + page_title: 'Übersicht von Voicemailaccount' + uuid: 'Uuid' + name: 'Name' + active: 'Active' + gs_node_id: 'Gs node' + voicemail_accountable_type: 'Voicemail accountable type' + voicemail_accountable_id: 'Voicemail accountable' + actions: + confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Voicemailaccount' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Voicemailaccount neu anlegen für %{resource}' + show: + page_title: 'Voicemailaccount bearbeiten' + uuid: 'Uuid' + name: 'Name' + active: 'Active' + gs_node_id: 'Gs node' + voicemail_accountable_type: 'Voicemail accountable type' + voicemail_accountable_id: 'Voicemail accountable' + actions: + confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Voicemailaccount neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Voicemailaccount bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + uuid: + label: 'Uuid' + hint: '' + name: + label: 'Name' + hint: '' + active: + label: 'Active' + hint: '' + gs_node_id: + label: 'Gs node' + hint: '' + voicemail_accountable_type: + label: 'Voicemail accountable type' + hint: '' + voicemail_accountable_id: + label: 'Voicemail accountable' + hint: '' + submit: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/voicemail_accounts/en.yml b/config/locales/views/voicemail_accounts/en.yml new file mode 100644 index 0000000..58491cd --- /dev/null +++ b/config/locales/views/voicemail_accounts/en.yml @@ -0,0 +1,65 @@ +en: + voicemail_accounts: + name: 'Voicemailaccount' + controller: + successfuly_created: 'Successfully created Voicemailaccount.' + successfuly_updated: 'Successfully updated Voicemailaccount.' + successfuly_destroyed: 'Successfully destroyed Voicemailaccount.' + index: + page_title: 'Listing Voicemailaccount' + uuid: 'Uuid' + name: 'Name' + active: 'Active' + gs_node_id: 'Gs node' + voicemail_accountable_type: 'Voicemail accountable type' + voicemail_accountable_id: 'Voicemail accountable' + actions: + confirm_destroy: 'Are you sure you want to delete this Voicemailaccount?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Voicemailaccount for %{resource}' + show: + page_title: 'Show Voicemailaccount' + uuid: 'Uuid' + name: 'Name' + active: 'Active' + gs_node_id: 'Gs node' + voicemail_accountable_type: 'Voicemail accountable type' + voicemail_accountable_id: 'Voicemail accountable' + actions: + confirm_destroy: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Voicemailaccount' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Voicemailaccount' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + uuid: + label: 'Uuid' + hint: '' + name: + label: 'Name' + hint: '' + active: + label: 'Active' + hint: '' + gs_node_id: + label: 'Gs node' + hint: '' + voicemail_accountable_type: + label: 'Voicemail accountable type' + hint: '' + voicemail_accountable_id: + label: 'Voicemail accountable' + hint: '' + submit: 'Submit' \ No newline at end of file diff --git a/config/locales/views/voicemail_settings/de.yml b/config/locales/views/voicemail_settings/de.yml index 52edd4b..bb48720 100644 --- a/config/locales/views/voicemail_settings/de.yml +++ b/config/locales/views/voicemail_settings/de.yml @@ -1,52 +1,69 @@ de: voicemail_settings: - name: 'Anrufbeantworter Einstellungen' + name: 'Voicemail Einstellungen' + settigs: + password: 'PIN' + notify: 'Notify' + attachment: 'Attachment' + mark_read: 'Mark read' + purge: 'Purge' + record_length_max: 'Record max.' + record_length_min: 'Record min.' + records_max: 'Records max.' controller: - successfuly_destroyed: 'Einstellungen wurden gelöscht.' - successfuly_created: 'Einstellungen wurden erstellt.' - successfuly_updated: 'Einstellungen wurden aktuallisiert.' + successfuly_created: 'Voicemail Einstellung wurde angelegt.' + successfuly_updated: 'Voicemail Einstellung wurde aktualisiert.' + successfuly_destroyed: 'Voicemail Einstellung wurde gelöscht.' index: - page_title: 'Anrufbeantworter Einstellungen' + page_title: 'Voicemail Einstellungen' + voicemail_account_id: 'Voicemail' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Beschreibung' actions: - confirm_destroy: 'Sind Sie sicher, dass Sie die Einstellungen löschen möchten?' + confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Voicemail Einstellungen' destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Voicemail Einstellungen neu anlegen für %{resource}' show: - page_title: 'Anrufbeantworter Einstellungen' - greeting_path: 'Begrüßung' - name_path: 'Name' - flags: 'Flags' - notify: 'Benachrichtigung' - attachment: 'Datei anfügen' - mark_read: 'Als gelesen markieren' - purge: 'Löschen' + page_title: 'Voicemail Einstellungen bearbeiten' + voicemail_account_id: 'Voicemail' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Beschreibung' actions: - confirm_destroy: 'Sind Sie sicher, dass Sie die Einstellungen löschen möchten?' + confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' destroy: 'Löschen' edit: 'Bearbeiten' + view_all: 'Alle anzeigen' new: - page_title: 'Anrufbeantworter Einstellungen' + page_title: 'Voicemail Einstellungen neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' edit: - page_title: 'Anrufbeantworter Einstellungen' + page_title: 'Voicemail Einstellungen bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' form: - greeting: - label: 'Begrüßung' + voicemail_account_id: + label: 'Voicemail' hint: '' name: label: 'Name' hint: '' - pin: - label: 'Anrufbeantworter PIN' + value: + label: 'Value' + hint: '' + class_type: + label: 'Class type' + hint: '' + description: + label: 'Beschreibung' hint: '' - notify: - label: 'Benachrichtigung' - hint: 'Benachrichtigung per E-Mail' - attachment: - label: 'Datei anfügen' - hint: 'Datei an E-Mail anfügen' - mark_read: - label: 'Als gelesen markieren' - hint: 'Markieren als gelesen' - purge: - label: 'Löschen' - hint: 'Nachricht löschen' submit: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/voicemail_settings/en.yml b/config/locales/views/voicemail_settings/en.yml index 5995544..1c8cad4 100644 --- a/config/locales/views/voicemail_settings/en.yml +++ b/config/locales/views/voicemail_settings/en.yml @@ -1,52 +1,69 @@ en: voicemail_settings: - name: 'Voicemail Settings' + name: 'Voicemailsetting' + settigs: + password: 'PIN' + notify: 'Notify' + attachment: 'Attachment' + mark_read: 'Mark read' + purge: 'Purge' + record_length_max: 'Record max.' + record_length_min: 'Record min.' + records_max: 'Records max.' controller: - successfuly_destroyed: 'Successfully destroyed voicemail settings.' - successfuly_created: 'Successfully created voicemail settings.' - successfuly_updated: 'Successfully updated voicemail settings.' + successfuly_created: 'Successfully created entry.' + successfuly_updated: 'Successfully updated entry.' + successfuly_destroyed: 'Successfully destroyed entry.' index: - page_title: 'Voicemail Settings' + page_title: 'Voicemail settings' + voicemail_account_id: 'Voicemail' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' actions: - confirm_destroy: 'Are you sure you want to delete voicemail settings?' + confirm_destroy: 'Are you sure you want to delete this entry?' destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New settings entry for %{resource}' show: - page_title: 'Voicemail Settings' - greeting_path: 'Greeting' - name_path: 'Name' - flags: 'Flags' - notify: 'Notify by email' - attachment: 'Attach file' - mark_read: 'Mark read' - purge: 'Delete' + page_title: 'Show Voicemailsetting' + voicemail_account_id: 'Voicemail' + name: 'Name' + value: 'Value' + class_type: 'Class type' + description: 'Description' actions: - confirm_destroy: 'Are you sure you want to delete voicemail settings?' + confirm_destroy: 'Are you sure you want to delete this element?' destroy: 'Delete' edit: 'Edit' + view_all: 'View All' new: - page_title: 'Voicemail Settings' + page_title: 'New Voicemail settings entry' + actions: + back_to_list: 'Back to Index' edit: - page_title: 'Voicemail Settings' + page_title: 'Editing Voicemail settings' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' form: - greeting: - label: 'Greeting' - hint: 'Voicemail greeting' + voicemail_account_id: + label: 'Voicemail' + hint: '' name: label: 'Name' - hint: 'Voicemail name' - pin: - label: 'Voicemail PIN' - hint: 'Voicemail PIN' - notify: - label: 'Notify by email' - hint: 'Notify user by email' - attachment: - label: 'Attach file' - hint: 'Attach file to notification email' - mark_read: - label: 'Mark read' - hint: 'Mark message read after notification is sent' - purge: - label: 'Delete' - hint: 'Delete message after notification is sent' - submit: 'Submit' + hint: '' + value: + label: 'Value' + hint: '' + class_type: + label: 'Class type' + hint: '' + description: + label: 'Description' + hint: '' + submit: 'Submit' \ No newline at end of file diff --git a/db/migrate/20130322081621_create_voicemail_accounts.rb b/db/migrate/20130322081621_create_voicemail_accounts.rb new file mode 100644 index 0000000..8567adb --- /dev/null +++ b/db/migrate/20130322081621_create_voicemail_accounts.rb @@ -0,0 +1,17 @@ +class CreateVoicemailAccounts < ActiveRecord::Migration + def self.up + create_table :voicemail_accounts do |t| + t.string :uuid + t.string :name + t.boolean :active + t.integer :gs_node_id + t.string :voicemail_accountable_type + t.integer :voicemail_accountable_id + t.timestamps + end + end + + def self.down + drop_table :voicemail_accounts + end +end diff --git a/db/migrate/20130322102533_add_voicemail_account_id_to_sip_accounts.rb b/db/migrate/20130322102533_add_voicemail_account_id_to_sip_accounts.rb new file mode 100644 index 0000000..60f5883 --- /dev/null +++ b/db/migrate/20130322102533_add_voicemail_account_id_to_sip_accounts.rb @@ -0,0 +1,5 @@ +class AddVoicemailAccountIdToSipAccounts < ActiveRecord::Migration + def change + add_column :sip_accounts, :voicemail_account_id, :integer + end +end diff --git a/db/migrate/20130326064557_create_voicemail_settings.rb b/db/migrate/20130326064557_create_voicemail_settings.rb new file mode 100644 index 0000000..45b6573 --- /dev/null +++ b/db/migrate/20130326064557_create_voicemail_settings.rb @@ -0,0 +1,16 @@ +class CreateVoicemailSettings < ActiveRecord::Migration + def self.up + create_table :voicemail_settings do |t| + t.integer :voicemail_account_id + t.string :name + t.string :value + t.string :class_type + t.string :description + t.timestamps + end + end + + def self.down + drop_table :voicemail_settings + end +end diff --git a/misc/freeswitch/conf/freeswitch.xml b/misc/freeswitch/conf/freeswitch.xml index 97e027d..025641b 100644 --- a/misc/freeswitch/conf/freeswitch.xml +++ b/misc/freeswitch/conf/freeswitch.xml @@ -73,6 +73,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -250,6 +314,14 @@ + + + + + + + + @@ -599,6 +671,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit/voicemail_account_test.rb b/test/unit/voicemail_account_test.rb new file mode 100644 index 0000000..b878c67 --- /dev/null +++ b/test/unit/voicemail_account_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class VoicemailAccountTest < ActiveSupport::TestCase + def test_should_be_valid + assert VoicemailAccount.new.valid? + end +end -- cgit v1.2.3