summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-26 15:51:35 +0100
committerPeter Kozak <spag@golwen.net>2013-03-26 15:51:35 +0100
commit3833ac1506fb336cd617ec41d25e35c34e74064e (patch)
tree7f865a6529ae42a7e878b34eca8f99b7e65575f2 /app
parent78948fc995786dcd1beae8e98573ec8ccba3ae9d (diff)
voicemail refactored
Diffstat (limited to 'app')
-rw-r--r--app/controllers/sip_accounts_controller.rb7
-rw-r--r--app/controllers/voicemail_accounts_controller.rb68
-rw-r--r--app/controllers/voicemail_settings_controller.rb85
-rw-r--r--app/helpers/voicemail_accounts_helper.rb2
-rw-r--r--app/models/sip_account.rb24
-rw-r--r--app/models/user.rb2
-rw-r--r--app/models/voicemail_account.rb20
-rw-r--r--app/models/voicemail_setting.rb52
-rw-r--r--app/views/sip_accounts/_form_core.html.haml1
-rw-r--r--app/views/sip_accounts/show.html.haml5
-rw-r--r--app/views/voicemail_accounts/_form.html.haml7
-rw-r--r--app/views/voicemail_accounts/_form_core.html.haml3
-rw-r--r--app/views/voicemail_accounts/_index_core.html.haml15
-rw-r--r--app/views/voicemail_accounts/edit.html.haml3
-rw-r--r--app/views/voicemail_accounts/index.html.haml6
-rw-r--r--app/views/voicemail_accounts/new.html.haml3
-rw-r--r--app/views/voicemail_accounts/show.html.haml19
-rw-r--r--app/views/voicemail_settings/_form.html.haml3
-rw-r--r--app/views/voicemail_settings/_form_core.html.haml17
-rw-r--r--app/views/voicemail_settings/_index_core.html.haml14
-rw-r--r--app/views/voicemail_settings/edit.html.haml2
-rw-r--r--app/views/voicemail_settings/index.html.haml6
-rw-r--r--app/views/voicemail_settings/new.html.haml3
-rw-r--r--app/views/voicemail_settings/show.html.haml33
24 files changed, 280 insertions, 120 deletions
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